-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: toggle node images and data fields on editor graph (#3789)
- Loading branch information
1 parent
3932adb
commit d2fe0cc
Showing
10 changed files
with
203 additions
and
3 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
33 changes: 33 additions & 0 deletions
33
editor.planx.uk/src/pages/FlowEditor/components/Flow/components/DataField.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,33 @@ | ||
import Box from "@mui/material/Box"; | ||
import { useStore } from "pages/FlowEditor/lib/store"; | ||
import React from "react"; | ||
|
||
export const DataField: React.FC<{ | ||
value: string; | ||
variant: "parent" | "child"; | ||
}> = ({ value, variant }) => { | ||
const showDataFields = useStore((state) => state.showDataFields); | ||
if (!showDataFields) return null; | ||
|
||
return ( | ||
<Box | ||
sx={(theme) => ({ | ||
fontFamily: theme.typography.data.fontFamily, | ||
fontSize: theme.typography.data, | ||
backgroundColor: "#f0f0f0", | ||
borderColor: | ||
variant === "parent" | ||
? theme.palette.common.black | ||
: theme.palette.grey[400], | ||
borderWidth: | ||
variant === "parent" ? "0 1px 1px 1px" : "1px 0 0 0", | ||
borderStyle: "solid", | ||
width: "100%", | ||
p: 0.5, | ||
textAlign: "center", | ||
})} | ||
> | ||
{value} | ||
</Box> | ||
); | ||
}; |
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
24 changes: 24 additions & 0 deletions
24
editor.planx.uk/src/pages/FlowEditor/components/Flow/components/Thumbnail.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,24 @@ | ||
import Box from "@mui/material/Box"; | ||
import { useStore } from "pages/FlowEditor/lib/store"; | ||
import React from "react"; | ||
|
||
export const Thumbnail: React.FC<{ | ||
imageSource: string; | ||
imageAltText?: string; | ||
}> = ({ imageSource, imageAltText }) => { | ||
const showImages = useStore((state) => state.showImages); | ||
if (!showImages) return null; | ||
|
||
return ( | ||
<Box | ||
sx={{ | ||
maxWidth: "220px", | ||
maxHeight: "220px", | ||
margin: "auto", | ||
}} | ||
component="img" | ||
src={imageSource} | ||
alt={imageAltText} | ||
/> | ||
); | ||
}; |
44 changes: 44 additions & 0 deletions
44
editor.planx.uk/src/pages/FlowEditor/components/FlowEditor/ToggleDataFieldsButton.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,44 @@ | ||
import DataFieldIcon from "@mui/icons-material/Code"; | ||
import DataFieldOffIcon from "@mui/icons-material/CodeOff"; | ||
import Box from "@mui/material/Box"; | ||
import IconButton from "@mui/material/IconButton"; | ||
import Tooltip from "@mui/material/Tooltip"; | ||
import { useStore } from "pages/FlowEditor/lib/store"; | ||
import React from "react"; | ||
|
||
export const ToggleDataFieldsButton: React.FC = () => { | ||
const [showDataFields, toggleShowDataFields] = useStore((state) => [ | ||
state.showDataFields, | ||
state.toggleShowDataFields, | ||
]); | ||
|
||
return ( | ||
<Box | ||
sx={(theme) => ({ | ||
position: "fixed", | ||
bottom: theme.spacing(6), | ||
left: theme.spacing(7), | ||
zIndex: theme.zIndex.appBar, | ||
border: `1px solid ${theme.palette.border.main}`, | ||
borderRadius: "3px", | ||
background: theme.palette.background.paper, | ||
})} | ||
> | ||
<Tooltip title="Toggle data fields" placement="right"> | ||
<IconButton | ||
aria-label="Toggle data fields" | ||
onClick={toggleShowDataFields} | ||
size="large" | ||
sx={(theme) => ({ | ||
padding: theme.spacing(1), | ||
color: showDataFields | ||
? theme.palette.text.primary | ||
: theme.palette.text.disabled, | ||
})} | ||
> | ||
{showDataFields ? <DataFieldIcon /> : <DataFieldOffIcon />} | ||
</IconButton> | ||
</Tooltip> | ||
</Box> | ||
); | ||
}; |
44 changes: 44 additions & 0 deletions
44
editor.planx.uk/src/pages/FlowEditor/components/FlowEditor/ToggleImagesButton.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,44 @@ | ||
import ImageOffIcon from "@mui/icons-material/HideImage"; | ||
import ImageIcon from "@mui/icons-material/Image"; | ||
import Box from "@mui/material/Box"; | ||
import IconButton from "@mui/material/IconButton"; | ||
import Tooltip from "@mui/material/Tooltip"; | ||
import { useStore } from "pages/FlowEditor/lib/store"; | ||
import React from "react"; | ||
|
||
export const ToggleImagesButton: React.FC = () => { | ||
const [showImages, toggleShowImages] = useStore((state) => [ | ||
state.showImages, | ||
state.toggleShowImages, | ||
]); | ||
|
||
return ( | ||
<Box | ||
sx={(theme) => ({ | ||
position: "fixed", | ||
bottom: theme.spacing(10), | ||
left: theme.spacing(7), | ||
zIndex: theme.zIndex.appBar, | ||
border: `1px solid ${theme.palette.border.main}`, | ||
borderRadius: "3px", | ||
background: theme.palette.background.paper, | ||
})} | ||
> | ||
<Tooltip title="Toggle images" placement="right"> | ||
<IconButton | ||
aria-label="Toggle images" | ||
onClick={toggleShowImages} | ||
size="large" | ||
sx={(theme) => ({ | ||
padding: theme.spacing(1), | ||
color: showImages | ||
? theme.palette.text.primary | ||
: theme.palette.text.disabled, | ||
})} | ||
> | ||
{showImages ? <ImageIcon /> : <ImageOffIcon />} | ||
</IconButton> | ||
</Tooltip> | ||
</Box> | ||
); | ||
}; |
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
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