-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
191 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
grai-frontend/src/components/graph/drawer/filters-inline/AddButton.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import userEvent from "@testing-library/user-event" | ||
import { render, screen, waitFor } from "testing" | ||
import AddButton from "./AddButton" | ||
|
||
const defaultProps = { | ||
fields: [ | ||
{ | ||
value: "test", | ||
label: "test", | ||
operators: [], | ||
}, | ||
], | ||
onAdd: () => {}, | ||
} | ||
|
||
test("renders", async () => { | ||
render(<AddButton {...defaultProps} />, { | ||
path: ":organisationName/:workspaceName/graph", | ||
route: "/default/demo/graph", | ||
}) | ||
|
||
await waitFor(() => { | ||
expect(screen.getByTestId("AddIcon")).toBeInTheDocument() | ||
}) | ||
}) | ||
|
||
test("click", async () => { | ||
render(<AddButton {...defaultProps} />, { | ||
path: ":organisationName/:workspaceName/graph", | ||
route: "/default/demo/graph", | ||
}) | ||
|
||
await waitFor(() => { | ||
expect(screen.getByTestId("AddIcon")).toBeInTheDocument() | ||
}) | ||
|
||
await userEvent.click(screen.getByTestId("AddIcon")) | ||
|
||
await waitFor(() => { | ||
expect(screen.getByText("Choose data field to add")).toBeInTheDocument() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
grai-frontend/src/components/graph/drawer/filters-inline/PopperComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from "react" | ||
import { autocompleteClasses, styled } from "@mui/material" | ||
|
||
const StyledAutocompletePopper = styled("div")(({ theme }) => ({ | ||
[`& .${autocompleteClasses.paper}`]: { | ||
boxShadow: "none", | ||
margin: 0, | ||
color: "inherit", | ||
fontSize: 13, | ||
}, | ||
[`& .${autocompleteClasses.listbox}`]: { | ||
backgroundColor: theme.palette.mode === "light" ? "#fff" : "#1c2128", | ||
padding: 0, | ||
[`& .${autocompleteClasses.option}`]: { | ||
minHeight: "auto", | ||
alignItems: "flex-start", | ||
padding: 8, | ||
borderBottom: `1px solid ${ | ||
theme.palette.mode === "light" ? " #eaecef" : "#30363d" | ||
}`, | ||
'&[aria-selected="true"]': { | ||
backgroundColor: "transparent", | ||
}, | ||
[`&.${autocompleteClasses.focused}, &.${autocompleteClasses.focused}[aria-selected="true"]`]: | ||
{ | ||
backgroundColor: theme.palette.action.hover, | ||
}, | ||
}, | ||
}, | ||
[`&.${autocompleteClasses.popperDisablePortal}`]: { | ||
position: "relative", | ||
}, | ||
})) | ||
|
||
interface PopperComponentProps { | ||
anchorEl?: any | ||
disablePortal?: boolean | ||
open: boolean | ||
} | ||
|
||
const PopperComponent: React.FC<PopperComponentProps> = props => { | ||
const { disablePortal, anchorEl, open, ...other } = props | ||
return <StyledAutocompletePopper {...other} /> | ||
} | ||
|
||
export default PopperComponent |
29 changes: 29 additions & 0 deletions
29
grai-frontend/src/components/graph/drawer/filters-inline/StyledInput.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { InputBase, styled } from "@mui/material" | ||
|
||
const StyledInput = styled(InputBase)(({ theme }) => ({ | ||
padding: 10, | ||
width: "100%", | ||
borderBottom: `1px solid ${ | ||
theme.palette.mode === "light" ? "#eaecef" : "#30363d" | ||
}`, | ||
"& input": { | ||
borderRadius: 4, | ||
backgroundColor: theme.palette.mode === "light" ? "#fff" : "#0d1117", | ||
padding: 8, | ||
transition: theme.transitions.create(["border-color", "box-shadow"]), | ||
border: `1px solid ${ | ||
theme.palette.mode === "light" ? "#eaecef" : "#30363d" | ||
}`, | ||
fontSize: 14, | ||
"&:focus": { | ||
boxShadow: `0px 0px 0px 3px ${ | ||
theme.palette.mode === "light" | ||
? "rgba(3, 102, 214, 0.3)" | ||
: "rgb(12, 45, 107)" | ||
}`, | ||
borderColor: theme.palette.mode === "light" ? "#0366d6" : "#388bfd", | ||
}, | ||
}, | ||
})) | ||
|
||
export default StyledInput |
16 changes: 16 additions & 0 deletions
16
grai-frontend/src/components/graph/drawer/filters-inline/StyledPopper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Popper, styled } from "@mui/material" | ||
|
||
const StyledPopper = styled(Popper)(({ theme }) => ({ | ||
border: `1px solid ${theme.palette.mode === "light" ? "#e1e4e8" : "#30363d"}`, | ||
boxShadow: `0 8px 24px ${ | ||
theme.palette.mode === "light" ? "rgba(149, 157, 165, 0.2)" : "rgb(1, 4, 9)" | ||
}`, | ||
borderRadius: 6, | ||
width: 300, | ||
zIndex: theme.zIndex.modal, | ||
fontSize: 13, | ||
color: theme.palette.mode === "light" ? "#24292e" : "#c9d1d9", | ||
backgroundColor: theme.palette.mode === "light" ? "#fff" : "#1c2128", | ||
})) | ||
|
||
export default StyledPopper |