MCPcopy Create free account
hub / github.com/SplootCode/splootcode / CategoryView

Function CategoryView

packages/editor/src/components/tray/category.tsx:62–112  ·  view source on GitHub ↗
(props: CategoryProps)

Source from the content-addressed store, hash-verified

60export const MicroNode = React.memo(MicroNodeInternal)
61
62const CategoryView = (props: CategoryProps) => {
63 const { category, startDrag } = props
64 return (
65 <Accordion defaultIndex={[]} allowToggle>
66 {category.entries.map((listing) => {
67 if ('category' in listing) {
68 return (
69 <AccordionItem key={listing.category} border={'none'} isDisabled={listing.entries.length === 0} py={0}>
70 {({ isExpanded }) => (
71 <>
72 <AccordionButton border={'none'} px={0} py={1} mb={1} fontSize={'14px'} _hover={{ bg: 'gray.700' }}>
73 {isExpanded ? (
74 <ChevronDownIcon textColor={'gray.400'} mr={0.5} />
75 ) : (
76 <ChevronRightIcon textColor={'gray.400'} mr={0.5} />
77 )}
78 {listing.category}
79 </AccordionButton>
80 <AccordionPanel pt={0} pr={0} pb={1} pl={2} mb={1} ml={2} className={'tray-expanded-category'}>
81 <Category category={listing} startDrag={startDrag} />
82 </AccordionPanel>
83 </>
84 )}
85 </AccordionItem>
86 )
87 }
88 const fragment = getSingleNodeFragment(listing.serializedNode, false)
89 return (
90 <AccordionItem key={listing.key} border={'none'}>
91 {({ isExpanded }) => (
92 <>
93 <AccordionButton border={'none'} px={0} py={1} mb={1} fontSize={'14px'} _hover={{ bg: 'gray.700' }}>
94 {isExpanded ? (
95 <ChevronDownIcon textColor={'gray.400'} mr={0.5} />
96 ) : (
97 <ChevronRightIcon textColor={'gray.400'} mr={0.5} />
98 )}
99 <MicroNode fragment={fragment} startDrag={startDrag} />
100 <Text pl={1}>{listing.title}</Text>
101 </AccordionButton>
102 <AccordionPanel p={0} pl={0} ml={1} pb={1} mt={0} mb={3} className={'tray-expanded-entry'}>
103 <Entry entry={listing} startDrag={startDrag} />
104 </AccordionPanel>
105 </>
106 )}
107 </AccordionItem>
108 )
109 })}
110 </Accordion>
111 )
112}
113
114export const Category = React.memo(CategoryView)

Callers

nothing calls this directly

Calls 1

getSingleNodeFragmentFunction · 0.85

Tested by

no test coverage detected