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

Function ScopeTray

packages/editor/src/components/tray/scope_tray.tsx:70–117  ·  view source on GitHub ↗
(props: EntryProps)

Source from the content-addressed store, hash-verified

68}
69
70export const ScopeTray = (props: EntryProps) => {
71 const { rootNode, startDrag } = props
72 const [rootScopeWrapped, setRootScope] = useState({ s: rootNode.getScope() })
73
74 const rootScope = rootScopeWrapped.s
75
76 useEffect(() => {
77 const observer: ScopeObserver = {
78 handleScopeMutation: (mutation) => {
79 setRootScope({ s: rootNode.scope })
80 },
81 }
82 globalMutationDispatcher.registerScopeObserver(observer)
83 return () => {
84 globalMutationDispatcher.deregisterScopeObserver(observer)
85 }
86 }, [rootNode])
87
88 return (
89 <Accordion defaultIndex={[0]} allowToggle fontSize={'14px'}>
90 <AccordionItem 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 <Text>Variables</Text>
100 </AccordionButton>
101 <AccordionPanel pt={0} pr={0} pb={1} pl={2} mb={1} ml={2} className={'tray-expanded-category'}>
102 {rootScope.hasEntries() ? (
103 <Box borderY={'solid 1px'} borderColor={'gray.700'} py={2} mb={2}>
104 <Text textColor={'gray.400'} lineHeight={1.1} py={1} px={1}>
105 Global
106 </Text>
107 <ScopeTree scope={rootScope} startDrag={startDrag} />
108 </Box>
109 ) : null}
110 <Category category={AssignmentCategory} startDrag={startDrag} />
111 </AccordionPanel>
112 </>
113 )}
114 </AccordionItem>
115 </Accordion>
116 )
117}
118
119interface ScopeTreeProps {
120 scope: PythonScope

Callers

nothing calls this directly

Calls 4

getScopeMethod · 0.80
registerScopeObserverMethod · 0.80
hasEntriesMethod · 0.80

Tested by

no test coverage detected