-
Notifications
You must be signed in to change notification settings - Fork 5
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
1 parent
f22eed1
commit 77de5d3
Showing
7 changed files
with
187 additions
and
94 deletions.
There are no files selected for viewing
79 changes: 0 additions & 79 deletions
79
wondrous-bot-admin/src/components/AddFormEntity/components/ComponentOptionsModal.tsx
This file was deleted.
Oops, something went wrong.
116 changes: 116 additions & 0 deletions
116
...n/src/components/AddFormEntity/components/ComponentOptionsModal/ComponentOptionsModal.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,116 @@ | ||
import { Button, Grid, Stack, Typography, useTheme } from "@mui/material"; | ||
import { COMPONENT_CATEGORIES } from "components/AddFormEntity/constants"; | ||
import SafeImage from "components/SafeImage"; | ||
import Modal from "components/Shared/Modal"; | ||
import { Container, OptionsColumnContainer } from "./styles"; | ||
|
||
const chooseIcon = (icon, category) => { | ||
if (!icon) { | ||
// in case icon is not provided, particularly for custom integrations, return a default icon | ||
return <img src={"/wonder.svg"} alt={icon} style={{ width: "25px", height: "25px", borderRadius: "6px" }} />; | ||
} | ||
if (category === COMPONENT_CATEGORIES.CUSTOM) { | ||
return ( | ||
<SafeImage | ||
src={icon} | ||
alt="icon" | ||
style={{ width: "25px", height: "25px", borderRadius: "6px", objectFit: "cover" }} | ||
/> | ||
); | ||
} | ||
return <img src={icon} alt={icon} />; | ||
}; | ||
|
||
const OptionsColumn = ({ colOptions, options, onClick, onClose, showBorder }) => { | ||
return ( | ||
<OptionsColumnContainer $showBorder={showBorder}> | ||
{colOptions.map((category) => ( | ||
<Stack spacing={2} key={category}> | ||
<Typography | ||
fontWeight={600} | ||
color="#737373" | ||
textTransform="capitalize" | ||
sx={{ | ||
paddingLeft: "8px", | ||
}} | ||
> | ||
{category} | ||
</Typography> | ||
<Stack alignItems="start"> | ||
{options[category].map((option) => ( | ||
<Button | ||
disableRipple | ||
onClick={() => { | ||
onClick(option.value); | ||
onClose(); | ||
}} | ||
sx={{ | ||
textTransform: "capitalize", | ||
gap: 1, | ||
borderRadius: "6px", | ||
"&:hover": { | ||
backgroundColor: "#EDEDED", | ||
}, | ||
alignItems: "flex-start", | ||
}} | ||
> | ||
{chooseIcon(option.icon, category)} | ||
<Typography key={option.value} color="#262627" textAlign="left"> | ||
{option.label} | ||
</Typography> | ||
</Button> | ||
))} | ||
</Stack> | ||
</Stack> | ||
))} | ||
</OptionsColumnContainer> | ||
); | ||
}; | ||
|
||
const ComponentOptionsModal = ({ open, onClose, onClick, options }) => { | ||
const groupedOptionsByCategory = options.reduce((acc, option) => { | ||
if (!acc[option.category]) { | ||
acc[option.category] = []; | ||
} | ||
acc[option.category].push(option); | ||
return acc; | ||
}, {}); | ||
|
||
const leftColOptions = [COMPONENT_CATEGORIES.ACTION, COMPONENT_CATEGORIES.TWITTER]; | ||
const midColOptions = [COMPONENT_CATEGORIES.DISCORD, COMPONENT_CATEGORIES.YOUTUBE, COMPONENT_CATEGORIES.CRYPTO]; | ||
const rightColOptions = [COMPONENT_CATEGORIES.CUSTOM]; | ||
|
||
const hasCustomComponent = options.some((option) => option.category === COMPONENT_CATEGORIES.CUSTOM); | ||
|
||
return ( | ||
<Modal open={open} onClose={onClose} maxWidth={hasCustomComponent ? 1200 : 800}> | ||
<Container> | ||
<OptionsColumn | ||
colOptions={leftColOptions} | ||
options={groupedOptionsByCategory} | ||
onClose={onClose} | ||
onClick={onClick} | ||
showBorder={false} | ||
/> | ||
<OptionsColumn | ||
colOptions={midColOptions} | ||
options={groupedOptionsByCategory} | ||
onClose={onClose} | ||
onClick={onClick} | ||
showBorder | ||
/> | ||
{hasCustomComponent && ( | ||
<OptionsColumn | ||
colOptions={rightColOptions} | ||
options={groupedOptionsByCategory} | ||
onClose={onClose} | ||
onClick={onClick} | ||
showBorder | ||
/> | ||
)} | ||
</Container> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default ComponentOptionsModal; |
29 changes: 29 additions & 0 deletions
29
wondrous-bot-admin/src/components/AddFormEntity/components/ComponentOptionsModal/styles.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,29 @@ | ||
import { Box, Grid } from "@mui/material"; | ||
import { styled } from "@mui/system"; | ||
|
||
export const Container = styled(Box)` | ||
&& { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 24px; | ||
${({ theme }) => theme.breakpoints.up("md")} { | ||
gap: 0; | ||
flex-direction: row; | ||
justify-content: center; | ||
} | ||
} | ||
`; | ||
|
||
export const OptionsColumnContainer = styled(Box)<{ $showBorder?: boolean }>` | ||
&& { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 24px; | ||
${({ theme }) => theme.breakpoints.up("md")} { | ||
border-left: ${({ $showBorder }) => ($showBorder ? "1px solid #EEEEEE" : "none")}; | ||
padding: 24px; | ||
} | ||
} | ||
`; |
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
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