Open History to see the last commit
1import { useApplicationMode, useReady } from '../store/project'
2
3import SelectedAddOns from './sidebar-items/add-ons'
4import RunAddOns from './sidebar-items/run-add-ons'
5import RunCreateApp from './sidebar-items/run-create-app'
6import ProjectName from './sidebar-items/project-name'
7import ModeSelector from './sidebar-items/mode-selector'
8import TypescriptSwitch from './sidebar-items/typescript-switch'
9import StarterDialog from './sidebar-items/starter'
10import SidebarGroup from './sidebar-items/sidebar-group'
11
12export interface SidebarProps {
13 slots?: {
14 actions: React.ReactNode
15 }
16}
17
18export const DefaultAppSidebarActions = () => (
19 <div className="mt-5">
20 <RunAddOns />
21 <RunCreateApp />
22 </div>
23)
24
25const defaultSlots: SidebarProps['slots'] = {
26 actions: <DefaultAppSidebarActions />,
27}
28
29export function AppSidebar(props: SidebarProps) {
30 const ready = useReady()
31 const mode = useApplicationMode()
32 const slots = Object.assign({}, defaultSlots, props.slots)
33
34 return (
35 <div className="flex flex-col gap-2">
36 {ready && (
37 <>
38 {mode === 'setup' && (
39 <SidebarGroup>
40 <ProjectName />
41 <ModeSelector />
42 <TypescriptSwitch />
43 </SidebarGroup>
44 )}
45 <SidebarGroup>
46 <SelectedAddOns />
47 </SidebarGroup>
48 {mode === 'setup' && (
49 <SidebarGroup>
50 <StarterDialog />
51 </SidebarGroup>
52 )}
53 </>
54 )}
55 {slots.actions}
56 </div>
57 )
58}