@tanstack/cta-ui-base 0.15.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/LICENSE +21 -0
  2. package/components.json +21 -0
  3. package/dist/app.d.ts +1 -0
  4. package/dist/app.js +10 -0
  5. package/dist/components/add-on-info-dialog.d.ts +5 -0
  6. package/dist/components/add-on-info-dialog.js +5 -0
  7. package/dist/components/background-animation.d.ts +1 -0
  8. package/dist/components/background-animation.js +144 -0
  9. package/dist/components/cta-provider.d.ts +3 -0
  10. package/dist/components/cta-provider.js +11 -0
  11. package/dist/components/cta-sidebar.d.ts +1 -0
  12. package/dist/components/cta-sidebar.js +15 -0
  13. package/dist/components/custom-add-on-dialog.d.ts +1 -0
  14. package/dist/components/custom-add-on-dialog.js +38 -0
  15. package/dist/components/file-navigator.d.ts +2 -0
  16. package/dist/components/file-navigator.js +86 -0
  17. package/dist/components/file-tree.d.ts +5 -0
  18. package/dist/components/file-tree.js +14 -0
  19. package/dist/components/file-viewer.d.ts +5 -0
  20. package/dist/components/file-viewer.js +40 -0
  21. package/dist/components/header.d.ts +1 -0
  22. package/dist/components/header.js +5 -0
  23. package/dist/components/icons/tailwind.d.ts +3 -0
  24. package/dist/components/icons/tailwind.js +5 -0
  25. package/dist/components/icons/tanstack.d.ts +3 -0
  26. package/dist/components/icons/tanstack.js +5 -0
  27. package/dist/components/icons/typescript.d.ts +3 -0
  28. package/dist/components/icons/typescript.js +5 -0
  29. package/dist/components/query-provider.d.ts +3 -0
  30. package/dist/components/query-provider.js +7 -0
  31. package/dist/components/sidebar-items/add-ons.d.ts +1 -0
  32. package/dist/components/sidebar-items/add-ons.js +27 -0
  33. package/dist/components/sidebar-items/mode-selector.d.ts +1 -0
  34. package/dist/components/sidebar-items/mode-selector.js +19 -0
  35. package/dist/components/sidebar-items/project-name.d.ts +1 -0
  36. package/dist/components/sidebar-items/project-name.js +12 -0
  37. package/dist/components/sidebar-items/run-add-ons.d.ts +1 -0
  38. package/dist/components/sidebar-items/run-add-ons.js +25 -0
  39. package/dist/components/sidebar-items/run-create-app.d.ts +1 -0
  40. package/dist/components/sidebar-items/run-create-app.js +28 -0
  41. package/dist/components/sidebar-items/sidebar-container.d.ts +3 -0
  42. package/dist/components/sidebar-items/sidebar-container.js +4 -0
  43. package/dist/components/sidebar-items/sidebar-group.d.ts +3 -0
  44. package/dist/components/sidebar-items/sidebar-group.js +4 -0
  45. package/dist/components/sidebar-items/starter.d.ts +1 -0
  46. package/dist/components/sidebar-items/starter.js +42 -0
  47. package/dist/components/sidebar-items/typescript-switch.d.ts +1 -0
  48. package/dist/components/sidebar-items/typescript-switch.js +18 -0
  49. package/dist/components/starters-carousel.d.ts +3 -0
  50. package/dist/components/starters-carousel.js +12 -0
  51. package/dist/components/startup-dialog.d.ts +1 -0
  52. package/dist/components/startup-dialog.js +30 -0
  53. package/dist/components/status-list.d.ts +5 -0
  54. package/dist/components/status-list.js +4 -0
  55. package/dist/components/toaster.d.ts +4 -0
  56. package/dist/components/toaster.js +15 -0
  57. package/dist/components/ui/button.d.ts +10 -0
  58. package/dist/components/ui/button.js +32 -0
  59. package/dist/components/ui/carousel.d.ts +20 -0
  60. package/dist/components/ui/carousel.js +90 -0
  61. package/dist/components/ui/checkbox.d.ts +4 -0
  62. package/dist/components/ui/checkbox.js +9 -0
  63. package/dist/components/ui/dialog.d.ts +15 -0
  64. package/dist/components/ui/dialog.js +36 -0
  65. package/dist/components/ui/dropdown-menu.d.ts +25 -0
  66. package/dist/components/ui/dropdown-menu.js +51 -0
  67. package/dist/components/ui/input.d.ts +3 -0
  68. package/dist/components/ui/input.js +7 -0
  69. package/dist/components/ui/label.d.ts +4 -0
  70. package/dist/components/ui/label.js +8 -0
  71. package/dist/components/ui/popover.d.ts +7 -0
  72. package/dist/components/ui/popover.js +17 -0
  73. package/dist/components/ui/separator.d.ts +4 -0
  74. package/dist/components/ui/separator.js +9 -0
  75. package/dist/components/ui/sheet.d.ts +13 -0
  76. package/dist/components/ui/sheet.js +40 -0
  77. package/dist/components/ui/skeleton.d.ts +2 -0
  78. package/dist/components/ui/skeleton.js +6 -0
  79. package/dist/components/ui/sonner.d.ts +3 -0
  80. package/dist/components/ui/sonner.js +12 -0
  81. package/dist/components/ui/switch.d.ts +4 -0
  82. package/dist/components/ui/switch.js +8 -0
  83. package/dist/components/ui/table.d.ts +10 -0
  84. package/dist/components/ui/table.js +28 -0
  85. package/dist/components/ui/tabs.d.ts +7 -0
  86. package/dist/components/ui/tabs.js +17 -0
  87. package/dist/components/ui/toggle-group.d.ts +7 -0
  88. package/dist/components/ui/toggle-group.js +20 -0
  89. package/dist/components/ui/toggle.d.ts +9 -0
  90. package/dist/components/ui/toggle.js +27 -0
  91. package/dist/components/ui/tooltip.d.ts +7 -0
  92. package/dist/components/ui/tooltip.js +18 -0
  93. package/dist/components/ui/tree-view.d.ts +25 -0
  94. package/dist/components/ui/tree-view.js +151 -0
  95. package/dist/file-classes.d.ts +8 -0
  96. package/dist/file-classes.js +41 -0
  97. package/dist/hooks/use-mounted.d.ts +1 -0
  98. package/dist/hooks/use-mounted.js +8 -0
  99. package/dist/hooks/use-preferred-reduced-motion.d.ts +5 -0
  100. package/dist/hooks/use-preferred-reduced-motion.js +20 -0
  101. package/dist/hooks/use-streaming-status.d.ts +6 -0
  102. package/dist/hooks/use-streaming-status.js +55 -0
  103. package/dist/index.d.ts +20 -0
  104. package/dist/index.js +20 -0
  105. package/dist/lib/api.d.ts +14 -0
  106. package/dist/lib/api.js +74 -0
  107. package/dist/lib/utils.d.ts +2 -0
  108. package/dist/lib/utils.js +5 -0
  109. package/dist/store/add-ons.d.ts +7 -0
  110. package/dist/store/add-ons.js +59 -0
  111. package/dist/store/project.d.ts +76 -0
  112. package/dist/store/project.js +269 -0
  113. package/package.json +50 -0
  114. package/src/app.tsx +28 -0
  115. package/src/components/add-on-info-dialog.tsx +39 -0
  116. package/src/components/background-animation.tsx +224 -0
  117. package/src/components/cta-provider.tsx +22 -0
  118. package/src/components/cta-sidebar.tsx +43 -0
  119. package/src/components/custom-add-on-dialog.tsx +79 -0
  120. package/src/components/file-navigator.tsx +207 -0
  121. package/src/components/file-tree.tsx +35 -0
  122. package/src/components/file-viewer.tsx +67 -0
  123. package/src/components/header.tsx +29 -0
  124. package/src/components/icons/tailwind.tsx +26 -0
  125. package/src/components/icons/tanstack.tsx +338 -0
  126. package/src/components/icons/typescript.tsx +23 -0
  127. package/src/components/query-provider.tsx +10 -0
  128. package/src/components/sidebar-items/add-ons.tsx +94 -0
  129. package/src/components/sidebar-items/mode-selector.tsx +56 -0
  130. package/src/components/sidebar-items/project-name.tsx +32 -0
  131. package/src/components/sidebar-items/run-add-ons.tsx +71 -0
  132. package/src/components/sidebar-items/run-create-app.tsx +82 -0
  133. package/src/components/sidebar-items/sidebar-container.tsx +11 -0
  134. package/src/components/sidebar-items/sidebar-group.tsx +11 -0
  135. package/src/components/sidebar-items/starter.tsx +123 -0
  136. package/src/components/sidebar-items/typescript-switch.tsx +58 -0
  137. package/src/components/starters-carousel.tsx +41 -0
  138. package/src/components/startup-dialog.tsx +72 -0
  139. package/src/components/status-list.tsx +22 -0
  140. package/src/components/toaster.tsx +29 -0
  141. package/src/components/ui/button.tsx +61 -0
  142. package/src/components/ui/carousel.tsx +239 -0
  143. package/src/components/ui/checkbox.tsx +30 -0
  144. package/src/components/ui/dialog.tsx +138 -0
  145. package/src/components/ui/dropdown-menu.tsx +255 -0
  146. package/src/components/ui/input.tsx +21 -0
  147. package/src/components/ui/label.tsx +22 -0
  148. package/src/components/ui/popover.tsx +46 -0
  149. package/src/components/ui/separator.tsx +28 -0
  150. package/src/components/ui/sheet.tsx +137 -0
  151. package/src/components/ui/skeleton.tsx +13 -0
  152. package/src/components/ui/sonner.tsx +24 -0
  153. package/src/components/ui/switch.tsx +29 -0
  154. package/src/components/ui/table.tsx +114 -0
  155. package/src/components/ui/tabs.tsx +64 -0
  156. package/src/components/ui/toggle-group.tsx +72 -0
  157. package/src/components/ui/toggle.tsx +49 -0
  158. package/src/components/ui/tooltip.tsx +61 -0
  159. package/src/components/ui/tree-view.tsx +497 -0
  160. package/src/file-classes.ts +54 -0
  161. package/src/hooks/use-mounted.ts +9 -0
  162. package/src/hooks/use-preferred-reduced-motion.ts +27 -0
  163. package/src/hooks/use-streaming-status.ts +70 -0
  164. package/src/index.ts +44 -0
  165. package/src/lib/api.ts +100 -0
  166. package/src/lib/utils.ts +8 -0
  167. package/src/store/add-ons.ts +81 -0
  168. package/src/store/project.ts +345 -0
  169. package/src/types.d.ts +109 -0
  170. package/tests/store/add-ons.test.ts +222 -0
  171. package/tsconfig.json +25 -0
  172. package/vitest.config.ts +6 -0
@@ -0,0 +1,32 @@
1
+ import { Input } from '../ui/input'
2
+
3
+ import {
4
+ setProjectName,
5
+ useApplicationMode,
6
+ useProjectName,
7
+ } from '../../store/project'
8
+
9
+ import SidebarContainer from './sidebar-container'
10
+
11
+ export default function ProjectName() {
12
+ const name = useProjectName()
13
+ const mode = useApplicationMode()
14
+
15
+ if (mode !== 'setup') {
16
+ return null
17
+ }
18
+
19
+ return (
20
+ <SidebarContainer>
21
+ <div className="flex flex-row gap-2 items-center">
22
+ <h3 className="font-medium whitespace-nowrap">Project Name</h3>
23
+ <Input
24
+ value={name}
25
+ placeholder="my-app"
26
+ onChange={(e) => setProjectName(e.target.value)}
27
+ className="w-full bg-gray-500/10 rounded-md px-2 py-1 min-w-[200px] text-sm"
28
+ />
29
+ </div>
30
+ </SidebarContainer>
31
+ )
32
+ }
@@ -0,0 +1,71 @@
1
+ import { useState } from 'react'
2
+
3
+ import { Button } from '../ui/button'
4
+ import {
5
+ Dialog,
6
+ DialogContent,
7
+ DialogFooter,
8
+ DialogHeader,
9
+ DialogTitle,
10
+ } from '../ui/dialog'
11
+
12
+ import { useAddOns, useApplicationMode } from '../../store/project'
13
+ import useStreamingStatus from '../../hooks/use-streaming-status'
14
+ import StatusList from '../status-list'
15
+ import { addToAppStreaming, shutdown } from '../../lib/api'
16
+
17
+ export default function RunAddOns() {
18
+ const { chosenAddOns } = useAddOns()
19
+ const [isRunning, setIsRunning] = useState(false)
20
+ const { streamItems, monitorStream, finished } = useStreamingStatus()
21
+
22
+ const mode = useApplicationMode()
23
+
24
+ if (mode !== 'add') {
25
+ return null
26
+ }
27
+
28
+ async function onAddToApp() {
29
+ setIsRunning(true)
30
+ monitorStream(await addToAppStreaming(chosenAddOns))
31
+ }
32
+
33
+ return (
34
+ <div>
35
+ <Dialog open={isRunning}>
36
+ <DialogContent
37
+ className="sm:min-w-[425px] sm:max-w-fit"
38
+ hideCloseButton
39
+ >
40
+ <DialogHeader>
41
+ <DialogTitle>Adding Add-Ons</DialogTitle>
42
+ </DialogHeader>
43
+ <StatusList streamItems={streamItems} finished={finished} />
44
+ <DialogFooter>
45
+ <Button
46
+ variant="default"
47
+ onClick={async () => {
48
+ await shutdown()
49
+ window.close()
50
+ }}
51
+ disabled={!finished}
52
+ >
53
+ Exit This Application
54
+ </Button>
55
+ </DialogFooter>
56
+ </DialogContent>
57
+ </Dialog>
58
+
59
+ <div className="flex flex-col gap-2">
60
+ <Button
61
+ variant="default"
62
+ onClick={onAddToApp}
63
+ disabled={chosenAddOns.length === 0 || isRunning}
64
+ className="w-full"
65
+ >
66
+ Add These Add-Ons To Your App
67
+ </Button>
68
+ </div>
69
+ </div>
70
+ )
71
+ }
@@ -0,0 +1,82 @@
1
+ import { useState } from 'react'
2
+ import { HammerIcon } from 'lucide-react'
3
+
4
+ import { Button } from '../ui/button'
5
+ import {
6
+ Dialog,
7
+ DialogContent,
8
+ DialogFooter,
9
+ DialogHeader,
10
+ DialogTitle,
11
+ } from '../ui/dialog'
12
+
13
+ import useStreamingStatus from '../../hooks/use-streaming-status'
14
+ import {
15
+ useAddOns,
16
+ useApplicationMode,
17
+ useProjectOptions,
18
+ useProjectStarter,
19
+ } from '../../store/project'
20
+ import StatusList from '../status-list'
21
+ import { createAppStreaming, shutdown } from '../../lib/api'
22
+
23
+ export default function RunCreateApp() {
24
+ const [isRunning, setIsRunning] = useState(false)
25
+ const { streamItems, monitorStream, finished } = useStreamingStatus()
26
+
27
+ const mode = useApplicationMode()
28
+ const options = useProjectOptions()
29
+ const { chosenAddOns } = useAddOns()
30
+ const { projectStarter } = useProjectStarter()
31
+
32
+ if (mode !== 'setup') {
33
+ return null
34
+ }
35
+
36
+ async function onAddToApp() {
37
+ setIsRunning(true)
38
+ monitorStream(
39
+ await createAppStreaming(options, chosenAddOns, projectStarter),
40
+ )
41
+ }
42
+
43
+ return (
44
+ <div>
45
+ <Dialog open={isRunning}>
46
+ <DialogContent
47
+ className="sm:min-w-[425px] sm:max-w-fit"
48
+ hideCloseButton
49
+ >
50
+ <DialogHeader>
51
+ <DialogTitle>Creating Your Application</DialogTitle>
52
+ </DialogHeader>
53
+ <StatusList streamItems={streamItems} finished={finished} />
54
+ <DialogFooter>
55
+ <Button
56
+ variant="default"
57
+ onClick={async () => {
58
+ await shutdown()
59
+ window.close()
60
+ }}
61
+ disabled={!finished}
62
+ >
63
+ Exit This Application
64
+ </Button>
65
+ </DialogFooter>
66
+ </DialogContent>
67
+ </Dialog>
68
+
69
+ <div className="flex flex-col gap-2">
70
+ <Button
71
+ variant="default"
72
+ onClick={onAddToApp}
73
+ disabled={isRunning}
74
+ className="w-full"
75
+ >
76
+ <HammerIcon className="w-4 h-4" />
77
+ Build Your App
78
+ </Button>
79
+ </div>
80
+ </div>
81
+ )
82
+ }
@@ -0,0 +1,11 @@
1
+ export default function SidebarContainer({
2
+ children,
3
+ }: {
4
+ children: React.ReactNode
5
+ }) {
6
+ return (
7
+ <div className="block p-4 bg-gray-500/10 hover:bg-gray-500/20 rounded-lg transition-colors space-y-4 active @container sidebar-container">
8
+ {children}
9
+ </div>
10
+ )
11
+ }
@@ -0,0 +1,11 @@
1
+ export default function SidebarGroup({
2
+ children,
3
+ }: {
4
+ children: React.ReactNode
5
+ }) {
6
+ return (
7
+ <div className="bg-white dark:bg-black/40 shadow-xl p-4 space-y-2 rounded-lg sidebar-group">
8
+ {children}
9
+ </div>
10
+ )
11
+ }
@@ -0,0 +1,123 @@
1
+ import { useState } from 'react'
2
+ import { FileBoxIcon, TrashIcon } from 'lucide-react'
3
+
4
+ import { toast } from 'sonner'
5
+
6
+ import { Button } from '../ui/button'
7
+ import { Input } from '../ui/input'
8
+ import {
9
+ Dialog,
10
+ DialogContent,
11
+ DialogFooter,
12
+ DialogHeader,
13
+ DialogTitle,
14
+ } from '../ui/dialog'
15
+ import {
16
+ setProjectStarter,
17
+ useApplicationMode,
18
+ useProjectStarter,
19
+ useRegistry,
20
+ } from '../../store/project'
21
+ import { loadRemoteStarter } from '../../lib/api'
22
+ import { StartersCarousel } from '../starters-carousel'
23
+
24
+ export default function Starter() {
25
+ const [url, setUrl] = useState('')
26
+ const [open, setOpen] = useState(false)
27
+
28
+ const mode = useApplicationMode()
29
+
30
+ const { projectStarter } = useProjectStarter()
31
+
32
+ if (mode !== 'setup') {
33
+ return null
34
+ }
35
+
36
+ async function onImport(registryUrl?: string) {
37
+ const data = await loadRemoteStarter(registryUrl || url)
38
+
39
+ if ('error' in data) {
40
+ toast.error('Failed to load starter', {
41
+ description: data.error,
42
+ })
43
+ } else {
44
+ setProjectStarter(data)
45
+ setOpen(false)
46
+ }
47
+ }
48
+
49
+ const registry = useRegistry()
50
+
51
+ return (
52
+ <>
53
+ {projectStarter?.banner && (
54
+ <div className="flex justify-center mb-4">
55
+ <div className="p-2 bg-gray-300 rounded-lg shadow-xl shadow-gray-800">
56
+ <img
57
+ src={projectStarter.banner}
58
+ alt="Starter Banner"
59
+ className="w-40 max-w-full"
60
+ />
61
+ </div>
62
+ </div>
63
+ )}
64
+ {projectStarter?.name && (
65
+ <div className="text-md mb-4">
66
+ <Button
67
+ variant="outline"
68
+ size="sm"
69
+ className="mr-2"
70
+ onClick={() => {
71
+ setProjectStarter(undefined)
72
+ }}
73
+ >
74
+ <TrashIcon className="w-4 h-4" />
75
+ </Button>
76
+ <span className="font-bold">Starter: </span>
77
+ {projectStarter.name}
78
+ </div>
79
+ )}
80
+ <div>
81
+ <Button
82
+ variant="secondary"
83
+ className="w-full"
84
+ onClick={() => {
85
+ setUrl('')
86
+ setOpen(true)
87
+ }}
88
+ >
89
+ <FileBoxIcon className="w-4 h-4" />
90
+ Set Project Starter
91
+ </Button>
92
+ <Dialog modal open={open} onOpenChange={setOpen}>
93
+ <DialogContent className="sm:min-w-[425px] sm:max-w-fit">
94
+ <DialogHeader>
95
+ <DialogTitle>Project Starter URL</DialogTitle>
96
+ </DialogHeader>
97
+ {registry?.starters && (
98
+ <div>
99
+ <StartersCarousel onImport={(url) => onImport(url)} />
100
+ </div>
101
+ )}
102
+ <div>
103
+ <Input
104
+ value={url}
105
+ onChange={(e) => setUrl(e.target.value)}
106
+ placeholder="https://github.com/myorg/myproject/starter.json"
107
+ className="min-w-lg w-full"
108
+ onKeyDown={(e) => {
109
+ if (e.key === 'Enter') {
110
+ onImport()
111
+ }
112
+ }}
113
+ />
114
+ </div>
115
+ <DialogFooter>
116
+ <Button onClick={() => onImport()}>Load</Button>
117
+ </DialogFooter>
118
+ </DialogContent>
119
+ </Dialog>
120
+ </div>
121
+ </>
122
+ )
123
+ }
@@ -0,0 +1,58 @@
1
+ import { Label } from '../ui/label'
2
+ import { Switch } from '../ui/switch'
3
+ import Typescript from '../icons/typescript'
4
+ import Tailwind from '../icons/tailwind'
5
+
6
+ import {
7
+ setTailwind,
8
+ setTypeScript,
9
+ useApplicationMode,
10
+ useProjectOptions,
11
+ useTailwindEditable,
12
+ useTypeScriptEditable,
13
+ } from '../../store/project'
14
+
15
+ import SidebarContainer from './sidebar-container'
16
+
17
+ export default function TypescriptSwitch() {
18
+ const typescript = useProjectOptions((state) => state.typescript)
19
+ const tailwind = useProjectOptions((state) => state.tailwind)
20
+ const mode = useApplicationMode()
21
+ const enableTailwind = useTailwindEditable()
22
+ const enableTypeScript = useTypeScriptEditable()
23
+
24
+ if (mode !== 'setup') {
25
+ return null
26
+ }
27
+
28
+ return (
29
+ <SidebarContainer>
30
+ <div className="flex">
31
+ <div className="w-1/2 flex flex-row items-center justify-center">
32
+ <Switch
33
+ id="typescript-switch"
34
+ checked={typescript}
35
+ onCheckedChange={(checked) => setTypeScript(checked)}
36
+ disabled={!enableTypeScript}
37
+ />
38
+ <Label htmlFor="typescript-switch" className="ml-2">
39
+ <Typescript className="w-5" />
40
+ TypeScript
41
+ </Label>
42
+ </div>
43
+ <div className="w-1/2 flex flex-row items-center justify-center">
44
+ <Switch
45
+ id="tailwind-switch"
46
+ checked={tailwind}
47
+ onCheckedChange={(checked) => setTailwind(checked)}
48
+ disabled={!enableTailwind}
49
+ />
50
+ <Label htmlFor="tailwind-switch" className="ml-2">
51
+ <Tailwind className="w-5" />
52
+ Tailwind
53
+ </Label>
54
+ </div>
55
+ </div>
56
+ </SidebarContainer>
57
+ )
58
+ }
@@ -0,0 +1,41 @@
1
+ import { useRegistry } from '../store/project'
2
+
3
+ import { Carousel, CarouselContent, CarouselItem } from './ui/carousel'
4
+
5
+ export function StartersCarousel({
6
+ onImport,
7
+ }: {
8
+ onImport: (url: string) => void
9
+ }) {
10
+ const registry = useRegistry()
11
+
12
+ if (!registry) {
13
+ return null
14
+ }
15
+
16
+ return (
17
+ <div>
18
+ <Carousel>
19
+ <CarouselContent>
20
+ {registry.starters.map((starter) => (
21
+ <CarouselItem className="basis-1/3" key={starter.url}>
22
+ <div
23
+ className="p-2 flex flex-col items-center hover:cursor-pointer hover:bg-gray-700/50 hover:text-white rounded-lg"
24
+ onClick={() => {
25
+ onImport(starter.url)
26
+ }}
27
+ >
28
+ <img
29
+ src={starter.banner}
30
+ alt={starter.name}
31
+ className="w-100 max-w-full"
32
+ />
33
+ <div className="text-md font-bold">{starter.name}</div>
34
+ </div>
35
+ </CarouselItem>
36
+ ))}
37
+ </CarouselContent>
38
+ </Carousel>
39
+ </div>
40
+ )
41
+ }
@@ -0,0 +1,72 @@
1
+ import { toast } from 'sonner'
2
+
3
+ import {
4
+ setProjectStarter,
5
+ useApplicationMode,
6
+ useRegistry,
7
+ useStartupDialog,
8
+ } from '../store/project'
9
+ import { loadRemoteStarter } from '../lib/api'
10
+
11
+ import {
12
+ Dialog,
13
+ DialogContent,
14
+ DialogFooter,
15
+ DialogHeader,
16
+ DialogTitle,
17
+ } from './ui/dialog'
18
+ import { StartersCarousel } from './starters-carousel'
19
+ import { Button } from './ui/button'
20
+ import { Switch } from './ui/switch'
21
+ import { Label } from './ui/label'
22
+
23
+ export default function StartupDialog() {
24
+ const mode = useApplicationMode()
25
+ const registry = useRegistry()
26
+ const { open, setOpen, dontShowAgain, setDontShowAgain } = useStartupDialog()
27
+
28
+ if (mode !== 'setup' || !registry || registry?.starters?.length === 0) {
29
+ return null
30
+ }
31
+
32
+ async function onImport(registryUrl: string) {
33
+ const data = await loadRemoteStarter(registryUrl)
34
+
35
+ if ('error' in data) {
36
+ toast.error('Failed to load starter', {
37
+ description: data.error,
38
+ })
39
+ } else {
40
+ setProjectStarter(data)
41
+ setOpen(false)
42
+ }
43
+ }
44
+
45
+ return (
46
+ <Dialog modal open={open} onOpenChange={setOpen}>
47
+ <DialogContent className="sm:min-w-[425px] sm:max-w-fit">
48
+ <DialogHeader>
49
+ <DialogTitle className="text-center text-2xl font-bold">
50
+ Would you like to use a starter project?
51
+ </DialogTitle>
52
+ </DialogHeader>
53
+ <div>
54
+ <StartersCarousel onImport={onImport} />
55
+ </div>
56
+ <DialogFooter className="flex sm:justify-between w-full">
57
+ <div className="flex items-center gap-2">
58
+ <Switch
59
+ id="show-startup-dialog"
60
+ checked={dontShowAgain}
61
+ onCheckedChange={setDontShowAgain}
62
+ />
63
+ <Label htmlFor="show-startup-dialog">Don't show this again</Label>
64
+ </div>
65
+ <Button onClick={() => setOpen(false)}>
66
+ No, I want to start from scratch
67
+ </Button>
68
+ </DialogFooter>
69
+ </DialogContent>
70
+ </Dialog>
71
+ )
72
+ }
@@ -0,0 +1,22 @@
1
+ import type { StreamItem } from '../types'
2
+
3
+ export default function StatusList({
4
+ streamItems,
5
+ finished,
6
+ }: {
7
+ streamItems: Array<StreamItem>
8
+ finished: boolean
9
+ }) {
10
+ return (
11
+ <div className="flex flex-col gap-2">
12
+ {streamItems.map((item, index) => (
13
+ <div key={item.id} className="flex items-center gap-2">
14
+ <item.icon
15
+ className={`w-4 h-4 ${index === streamItems.length - 1 && !finished ? 'text-green-500 animate-spin' : ''}`}
16
+ />
17
+ {item.message}
18
+ </div>
19
+ ))}
20
+ </div>
21
+ )
22
+ }
@@ -0,0 +1,29 @@
1
+ import { useTheme } from 'next-themes'
2
+ import { Toaster as Sonner } from 'sonner'
3
+
4
+ type ToasterProps = React.ComponentProps<typeof Sonner>
5
+
6
+ const Toaster = ({ ...props }: ToasterProps) => {
7
+ const { theme = 'system' } = useTheme()
8
+
9
+ return (
10
+ <Sonner
11
+ theme={theme as ToasterProps['theme']}
12
+ className="toaster group"
13
+ toastOptions={{
14
+ classNames: {
15
+ toast:
16
+ 'group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg',
17
+ description: 'group-[.toast]:text-muted-foreground',
18
+ actionButton:
19
+ 'group-[.toast]:bg-primary group-[.toast]:text-primary-foreground',
20
+ cancelButton:
21
+ 'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground',
22
+ },
23
+ }}
24
+ {...props}
25
+ />
26
+ )
27
+ }
28
+
29
+ export { Toaster }
@@ -0,0 +1,61 @@
1
+ import * as React from 'react'
2
+ import { Slot } from '@radix-ui/react-slot'
3
+ import { cva } from 'class-variance-authority'
4
+
5
+ import { cn } from '../../lib/utils'
6
+
7
+ import type { VariantProps } from 'class-variance-authority'
8
+
9
+ const buttonVariants = cva(
10
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
11
+ {
12
+ variants: {
13
+ variant: {
14
+ default:
15
+ 'bg-primary text-primary-foreground shadow-xs hover:bg-primary/90',
16
+ destructive:
17
+ 'bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',
18
+ outline:
19
+ 'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50',
20
+ secondary:
21
+ 'bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80',
22
+ ghost:
23
+ 'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',
24
+ link: 'text-primary underline-offset-4 hover:underline',
25
+ },
26
+ size: {
27
+ default: 'h-9 px-4 py-2 has-[>svg]:px-3',
28
+ sm: 'h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5',
29
+ lg: 'h-10 rounded-md px-6 has-[>svg]:px-4',
30
+ icon: 'size-9',
31
+ },
32
+ },
33
+ defaultVariants: {
34
+ variant: 'default',
35
+ size: 'default',
36
+ },
37
+ },
38
+ )
39
+
40
+ function Button({
41
+ className,
42
+ variant,
43
+ size,
44
+ asChild = false,
45
+ ...props
46
+ }: React.ComponentProps<'button'> &
47
+ VariantProps<typeof buttonVariants> & {
48
+ asChild?: boolean
49
+ }) {
50
+ const Comp = asChild ? Slot : 'button'
51
+
52
+ return (
53
+ <Comp
54
+ data-slot="button"
55
+ className={cn(buttonVariants({ variant, size, className }))}
56
+ {...props}
57
+ />
58
+ )
59
+ }
60
+
61
+ export { Button, buttonVariants }