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

Function Tray

packages/editor/src/components/tray/tray.tsx:46–118  ·  view source on GitHub ↗
(props: TrayProps)

Source from the content-addressed store, hash-verified

44}
45
46export function Tray(props: TrayProps) {
47 const { rootNode, startDrag, moduleTrayLoader } = props
48 const [listing, setListing] = useState(null)
49 const [tabIndex, setTabIndex] = useState(0)
50
51 const editorContext = useContext<EditorState>(EditorStateContext)
52
53 useEffect(() => {
54 setListing(getTrayListing(props.rootNode))
55 }, [props.rootNode])
56
57 const addModuleImport = useCallback(
58 (module: PythonModuleInfo) => {
59 if (module.isStandardLib) {
60 ;(rootNode as PythonFile).addModuleImport(module.name)
61 } else {
62 editorContext.project.putDependency({
63 name: module.name,
64 version: '',
65 })
66 }
67 setTabIndex(1)
68 },
69 [rootNode]
70 )
71
72 return (
73 <div className="tray">
74 <Tabs index={tabIndex} onChange={(index) => setTabIndex(index)} position="relative">
75 <HStack justifyContent={'space-between'} borderBottomColor={'gray.800'} borderBottomWidth={'2px'}>
76 <TabList borderBottom={'none'} color={'gray.400'}>
77 <Tab py={3} px={3} _selected={{ color: 'gray.200' }}>
78 <Text as={'h2'}>Python</Text>
79 </Tab>
80 <Tab py={3} _selected={{ color: 'gray.200' }}>
81 <Text as={'h2'}>Imports</Text>
82 </Tab>
83 </TabList>
84 <ButtonGroup px={2}>
85 <IconButton
86 size="sm"
87 aria-label="New variable"
88 icon={<AddIcon />}
89 onClick={() => {
90 setTabIndex(2)
91 }}
92 ></IconButton>
93 </ButtonGroup>
94 </HStack>
95 <TabIndicator mt="-1.5px" height="2px" bg="gray.400" borderRadius="1px" />
96 <TabPanels>
97 <TabPanel px={2} py={2}>
98 {rootNode ? <ScopeTray rootNode={rootNode as PythonNode} startDrag={startDrag} /> : null}
99 {listing ? <Category category={listing} startDrag={startDrag} /> : null}
100 </TabPanel>
101 <TabPanel px={2} py={2}>
102 <ImportsTray
103 rootNode={rootNode as PythonNode}

Callers

nothing calls this directly

Calls 3

getTrayListingFunction · 0.85
putDependencyMethod · 0.80
addModuleImportMethod · 0.45

Tested by

no test coverage detected