MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / StickyNote

Function StickyNote

packages/ui/src/views/agentflowsv2/StickyNote.jsx:36–130  ·  view source on GitHub ↗
({ data })

Source from the content-addressed store, hash-verified

34}))
35
36const StickyNote = ({ data }) => {
37 const theme = useTheme()
38 const customization = useSelector((state) => state.customization)
39 const ref = useRef(null)
40
41 const { reactFlowInstance, deleteNode, duplicateNode } = useContext(flowContext)
42 const [inputParam] = data.inputParams
43 const [isHovered, setIsHovered] = useState(false)
44
45 const defaultColor = '#666666' // fallback color if data.color is not present
46 const nodeColor = data.color || defaultColor
47
48 // Get different shades of the color based on state
49 const getStateColor = () => {
50 if (data.selected) return nodeColor
51 if (isHovered) return alpha(nodeColor, 0.8)
52 return alpha(nodeColor, 0.5)
53 }
54
55 const getBackgroundColor = () => {
56 if (customization.isDarkMode) {
57 return isHovered ? darken(nodeColor, 0.7) : darken(nodeColor, 0.8)
58 }
59 return isHovered ? lighten(nodeColor, 0.8) : lighten(nodeColor, 0.9)
60 }
61
62 return (
63 <div ref={ref} onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => setIsHovered(false)}>
64 <StyledNodeToolbar>
65 <ButtonGroup sx={{ gap: 1 }} variant='outlined' aria-label='Basic button group'>
66 <IconButton
67 size={'small'}
68 title='Duplicate'
69 onClick={() => {
70 duplicateNode(data.id)
71 }}
72 sx={{
73 color: customization.isDarkMode ? 'white' : 'inherit',
74 '&:hover': {
75 color: theme.palette.primary.main
76 }
77 }}
78 >
79 <IconCopy size={20} />
80 </IconButton>
81 <IconButton
82 size={'small'}
83 title='Delete'
84 onClick={() => {
85 deleteNode(data.id)
86 }}
87 sx={{
88 color: customization.isDarkMode ? 'white' : 'inherit',
89 '&:hover': {
90 color: theme.palette.error.main
91 }
92 }}
93 >

Callers

nothing calls this directly

Calls 4

duplicateNodeFunction · 0.85
deleteNodeFunction · 0.85
getStateColorFunction · 0.70
getBackgroundColorFunction · 0.70

Tested by

no test coverage detected