From 42f80fade23c0799e311c13f9ff482306d13a7c2 Mon Sep 17 00:00:00 2001 From: Ilango Date: Fri, 12 Jan 2024 13:34:52 +0530 Subject: [PATCH] Add new node type for canvas - sticky note --- packages/ui/src/views/canvas/CardWrapper.js | 21 ++++ packages/ui/src/views/canvas/LightTooltip.js | 12 +++ packages/ui/src/views/canvas/StickyNote.js | 105 +++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 packages/ui/src/views/canvas/CardWrapper.js create mode 100644 packages/ui/src/views/canvas/LightTooltip.js create mode 100644 packages/ui/src/views/canvas/StickyNote.js diff --git a/packages/ui/src/views/canvas/CardWrapper.js b/packages/ui/src/views/canvas/CardWrapper.js new file mode 100644 index 00000000..3e010899 --- /dev/null +++ b/packages/ui/src/views/canvas/CardWrapper.js @@ -0,0 +1,21 @@ +// material-ui +import { styled } from '@mui/material/styles' + +// project imports +import MainCard from '../../ui-component/cards/MainCard' + +const CardWrapper = styled(MainCard)(({ theme }) => ({ + background: theme.palette.card.main, + color: theme.darkTextPrimary, + border: 'solid 1px', + borderColor: theme.palette.primary[200] + 75, + width: '300px', + height: 'auto', + padding: '10px', + boxShadow: '0 2px 14px 0 rgb(32 40 45 / 8%)', + '&:hover': { + borderColor: theme.palette.primary.main + } +})) + +export default CardWrapper diff --git a/packages/ui/src/views/canvas/LightTooltip.js b/packages/ui/src/views/canvas/LightTooltip.js new file mode 100644 index 00000000..32e34aae --- /dev/null +++ b/packages/ui/src/views/canvas/LightTooltip.js @@ -0,0 +1,12 @@ +import { styled } from '@mui/material/styles' +import Tooltip, { tooltipClasses } from '@mui/material/Tooltip' + +const LightTooltip = styled(({ className, ...props }) => )(({ theme }) => ({ + [`& .${tooltipClasses.tooltip}`]: { + backgroundColor: theme.palette.nodeToolTip.background, + color: theme.palette.nodeToolTip.color, + boxShadow: theme.shadows[1] + } +})) + +export default LightTooltip diff --git a/packages/ui/src/views/canvas/StickyNote.js b/packages/ui/src/views/canvas/StickyNote.js new file mode 100644 index 00000000..53406513 --- /dev/null +++ b/packages/ui/src/views/canvas/StickyNote.js @@ -0,0 +1,105 @@ +import PropTypes from 'prop-types' +import { useContext, useState } from 'react' +import { useSelector } from 'react-redux' + +// material-ui +import { useTheme } from '@mui/material/styles' + +// project imports +import CardWrapper from './CardWrapper' +import LightTooltip from './LightTooltip' +import { IconButton, Box } from '@mui/material' +import { IconCopy, IconTrash } from '@tabler/icons' +import { Input } from 'ui-component/input/Input' + +// const +import { flowContext } from '../../store/context/ReactFlowContext' + +const StickyNote = ({ data }) => { + const theme = useTheme() + const canvas = useSelector((state) => state.canvas) + const { deleteNode, duplicateNode } = useContext(flowContext) + const [inputParam] = data.inputParams + + const [open, setOpen] = useState(false) + + const handleClose = () => { + setOpen(false) + } + + const handleOpen = () => { + setOpen(true) + } + + console.log(data.id) + + return ( + <> + + + { + duplicateNode(data.id) + }} + sx={{ height: '35px', width: '35px', '&:hover': { color: theme?.palette.primary.main } }} + color={theme?.customization?.isDarkMode ? theme.colors?.paper : 'inherit'} + > + + + { + deleteNode(data.id) + }} + sx={{ height: '35px', width: '35px', '&:hover': { color: 'red' } }} + color={theme?.customization?.isDarkMode ? theme.colors?.paper : 'inherit'} + > + + + + } + placement='right-start' + > + + (data.inputs[inputParam.name] = newValue)} + value={data.inputs[inputParam.name] ?? inputParam.default ?? ''} + nodes={inputParam?.acceptVariable && reactFlowInstance ? reactFlowInstance.getNodes() : []} + edges={inputParam?.acceptVariable && reactFlowInstance ? reactFlowInstance.getEdges() : []} + nodeId={data.id} + /> + + + + + ) +} + +StickyNote.propTypes = { + data: PropTypes.object +} + +export default StickyNote