@tanstack/cta-ui 0.10.0-alpha.19 → 0.10.0-alpha.20
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.
- package/lib/index.ts +16 -7
- package/lib-dist/index.d.ts +6 -1
- package/lib-dist/index.js +6 -3
- package/package.json +20 -7
- package/public/tailwind.svg +1 -0
- package/public/tanstack.png +0 -0
- package/public/typescript.svg +1 -0
- package/src/components/StatusList.tsx +22 -0
- package/src/components/add-on-info-dialog.tsx +39 -0
- package/src/components/cta-sidebar.tsx +55 -0
- package/src/components/custom-add-on-dialog.tsx +79 -0
- package/src/components/file-navigator.tsx +205 -0
- package/src/components/file-tree.tsx +18 -60
- package/src/components/file-viewer.tsx +11 -3
- package/src/components/sidebar-items/add-ons.tsx +91 -0
- package/src/components/sidebar-items/mode-selector.tsx +55 -0
- package/src/components/sidebar-items/project-name.tsx +29 -0
- package/src/components/sidebar-items/run-add-ons.tsx +71 -0
- package/src/components/sidebar-items/run-create-app.tsx +82 -0
- package/src/components/sidebar-items/starter.tsx +115 -0
- package/src/components/sidebar-items/typescript-switch.tsx +52 -0
- package/src/components/toaster.tsx +29 -0
- package/src/components/ui/button.tsx +21 -19
- package/src/components/ui/dialog.tsx +25 -20
- package/src/components/ui/dropdown-menu.tsx +255 -0
- package/src/components/ui/input.tsx +21 -0
- package/src/components/ui/label.tsx +22 -0
- package/src/components/ui/popover.tsx +46 -0
- package/src/components/ui/separator.tsx +28 -0
- package/src/components/ui/sheet.tsx +137 -0
- package/src/components/ui/sidebar.tsx +726 -0
- package/src/components/ui/skeleton.tsx +13 -0
- package/src/components/ui/sonner.tsx +23 -0
- package/src/components/ui/switch.tsx +29 -0
- package/src/components/ui/toggle-group.tsx +11 -11
- package/src/components/ui/toggle.tsx +15 -13
- package/src/components/ui/tooltip.tsx +61 -0
- package/src/components/ui/tree-view.tsx +17 -12
- package/src/engine-handling/add-to-app-wrapper.ts +114 -0
- package/src/engine-handling/create-app-wrapper.ts +107 -0
- package/src/engine-handling/file-helpers.ts +25 -0
- package/src/engine-handling/framework-registration.ts +11 -0
- package/src/engine-handling/generate-initial-payload.ts +93 -0
- package/src/engine-handling/server-environment.ts +13 -0
- package/src/file-classes.ts +54 -0
- package/src/hooks/use-mobile.ts +19 -0
- package/src/hooks/use-streaming-status.ts +70 -0
- package/src/lib/api.ts +90 -0
- package/src/routeTree.gen.ts +4 -27
- package/src/routes/__root.tsx +36 -7
- package/src/routes/api/add-to-app.ts +21 -0
- package/src/routes/api/create-app.ts +21 -0
- package/src/routes/api/dry-run-add-to-app.ts +16 -0
- package/src/routes/api/dry-run-create-app.ts +16 -0
- package/src/routes/api/initial-payload.ts +10 -0
- package/src/routes/api/load-remote-add-on.ts +42 -0
- package/src/routes/api/load-starter.ts +47 -0
- package/src/routes/api/shutdown.ts +11 -0
- package/src/routes/index.tsx +3 -210
- package/src/store/add-ons.ts +81 -0
- package/src/store/project.ts +268 -0
- package/src/styles.css +47 -0
- package/src/types.d.ts +87 -0
- package/tests/store/add-ons.test.ts +222 -0
- package/vitest.config.ts +6 -0
- package/.cursorrules +0 -7
- package/src/components/Header.tsx +0 -13
- package/src/components/applied-add-on.tsx +0 -149
- package/src/lib/server-fns.ts +0 -78
- package/src/routes/api.demo-names.ts +0 -11
- package/src/routes/demo.tanstack-query.tsx +0 -28
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { useMemo, useState } from 'react'
|
|
2
|
+
import { InfoIcon } from 'lucide-react'
|
|
3
|
+
|
|
4
|
+
import type { AddOnInfo } from '@/types'
|
|
5
|
+
|
|
6
|
+
import { Switch } from '@/components/ui/switch'
|
|
7
|
+
import { Label } from '@/components/ui/label'
|
|
8
|
+
|
|
9
|
+
import { useAddOns } from '@/store/project'
|
|
10
|
+
|
|
11
|
+
import ImportCustomAddOn from '@/components/custom-add-on-dialog'
|
|
12
|
+
import AddOnInfoDialog from '@/components/add-on-info-dialog'
|
|
13
|
+
|
|
14
|
+
const addOnTypeLabels: Record<string, string> = {
|
|
15
|
+
toolchain: 'Toolchain',
|
|
16
|
+
'add-on': 'Add-on',
|
|
17
|
+
example: 'Example',
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default function SelectedAddOns() {
|
|
21
|
+
const { availableAddOns, addOnState, toggleAddOn } = useAddOns()
|
|
22
|
+
|
|
23
|
+
const sortedAddOns = useMemo(() => {
|
|
24
|
+
return availableAddOns.sort((a, b) => {
|
|
25
|
+
return a.name.localeCompare(b.name)
|
|
26
|
+
})
|
|
27
|
+
}, [availableAddOns])
|
|
28
|
+
|
|
29
|
+
const [infoAddOn, setInfoAddOn] = useState<AddOnInfo>()
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<>
|
|
33
|
+
<AddOnInfoDialog
|
|
34
|
+
addOn={infoAddOn}
|
|
35
|
+
onClose={() => setInfoAddOn(undefined)}
|
|
36
|
+
/>
|
|
37
|
+
{Object.keys(addOnTypeLabels).map((type) => (
|
|
38
|
+
<div key={type}>
|
|
39
|
+
{sortedAddOns.filter((addOn) => addOn.type === type).length > 0 && (
|
|
40
|
+
<h1 className="text-sm text-center border-b-2">
|
|
41
|
+
{addOnTypeLabels[type]}
|
|
42
|
+
</h1>
|
|
43
|
+
)}
|
|
44
|
+
<div className="flex flex-row flex-wrap">
|
|
45
|
+
{sortedAddOns
|
|
46
|
+
.filter((addOn) => addOn.type === type)
|
|
47
|
+
.map((addOn) => (
|
|
48
|
+
<div
|
|
49
|
+
key={addOn.id}
|
|
50
|
+
className="w-1/2 flex flex-row justify-between pr-4"
|
|
51
|
+
>
|
|
52
|
+
<div className="p-1 flex flex-row items-center">
|
|
53
|
+
<Switch
|
|
54
|
+
id={addOn.id}
|
|
55
|
+
checked={addOnState[addOn.id].selected}
|
|
56
|
+
disabled={!addOnState[addOn.id].enabled}
|
|
57
|
+
onCheckedChange={() => {
|
|
58
|
+
toggleAddOn(addOn.id)
|
|
59
|
+
}}
|
|
60
|
+
/>
|
|
61
|
+
<Label
|
|
62
|
+
htmlFor={addOn.id}
|
|
63
|
+
className="pl-2 font-semibold text-gray-300"
|
|
64
|
+
>
|
|
65
|
+
{addOn.smallLogo && (
|
|
66
|
+
<img
|
|
67
|
+
src={`data:image/svg+xml,${encodeURIComponent(
|
|
68
|
+
addOn.smallLogo,
|
|
69
|
+
)}`}
|
|
70
|
+
alt={addOn.name}
|
|
71
|
+
className="w-5"
|
|
72
|
+
/>
|
|
73
|
+
)}
|
|
74
|
+
{addOn.name}
|
|
75
|
+
</Label>
|
|
76
|
+
<InfoIcon
|
|
77
|
+
className="ml-2 w-4 text-gray-600"
|
|
78
|
+
onClick={() => setInfoAddOn(addOn)}
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
))}
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
))}
|
|
86
|
+
<div className="mt-4">
|
|
87
|
+
<ImportCustomAddOn />
|
|
88
|
+
</div>
|
|
89
|
+
</>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { CodeIcon, FileIcon } from 'lucide-react'
|
|
2
|
+
|
|
3
|
+
import type { Mode } from '@tanstack/cta-engine'
|
|
4
|
+
|
|
5
|
+
import { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group'
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
setRouterMode,
|
|
9
|
+
useApplicationMode,
|
|
10
|
+
useModeEditable,
|
|
11
|
+
useRouterMode,
|
|
12
|
+
} from '@/store/project'
|
|
13
|
+
|
|
14
|
+
export default function ModeSelector() {
|
|
15
|
+
const mode = useApplicationMode()
|
|
16
|
+
const enableMode = useModeEditable()
|
|
17
|
+
const routerMode = useRouterMode()
|
|
18
|
+
|
|
19
|
+
if (mode !== 'setup') {
|
|
20
|
+
return null
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<>
|
|
25
|
+
<div className="flex flex-row justify-center items-center mt-4">
|
|
26
|
+
<ToggleGroup
|
|
27
|
+
type="single"
|
|
28
|
+
value={routerMode}
|
|
29
|
+
onValueChange={(v: string) => {
|
|
30
|
+
if (v) {
|
|
31
|
+
setRouterMode(v as Mode)
|
|
32
|
+
}
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
<ToggleGroupItem
|
|
36
|
+
value="code-router"
|
|
37
|
+
className="px-8"
|
|
38
|
+
disabled={!enableMode}
|
|
39
|
+
>
|
|
40
|
+
<CodeIcon className="w-4 h-4" />
|
|
41
|
+
Code Router
|
|
42
|
+
</ToggleGroupItem>
|
|
43
|
+
<ToggleGroupItem
|
|
44
|
+
value="file-router"
|
|
45
|
+
className="px-4"
|
|
46
|
+
disabled={!enableMode}
|
|
47
|
+
>
|
|
48
|
+
<FileIcon className="w-4 h-4" />
|
|
49
|
+
File Router
|
|
50
|
+
</ToggleGroupItem>
|
|
51
|
+
</ToggleGroup>
|
|
52
|
+
</div>
|
|
53
|
+
</>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Input } from '@/components/ui/input'
|
|
2
|
+
import { SidebarGroupLabel } from '@/components/ui/sidebar'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
setProjectName,
|
|
6
|
+
useApplicationMode,
|
|
7
|
+
useProjectName,
|
|
8
|
+
} from '@/store/project'
|
|
9
|
+
|
|
10
|
+
export default function ProjectName() {
|
|
11
|
+
const name = useProjectName()
|
|
12
|
+
const mode = useApplicationMode()
|
|
13
|
+
|
|
14
|
+
if (mode !== 'setup') {
|
|
15
|
+
return null
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<>
|
|
20
|
+
<SidebarGroupLabel>Project Name</SidebarGroupLabel>
|
|
21
|
+
<Input
|
|
22
|
+
value={name}
|
|
23
|
+
placeholder="my-app"
|
|
24
|
+
onChange={(e) => setProjectName(e.target.value)}
|
|
25
|
+
className="w-full"
|
|
26
|
+
/>
|
|
27
|
+
</>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import { Button } from '@/components/ui/button'
|
|
4
|
+
import {
|
|
5
|
+
Dialog,
|
|
6
|
+
DialogContent,
|
|
7
|
+
DialogFooter,
|
|
8
|
+
DialogHeader,
|
|
9
|
+
DialogTitle,
|
|
10
|
+
} from '@/components/ui/dialog'
|
|
11
|
+
|
|
12
|
+
import { useAddOns, useApplicationMode } from '@/store/project'
|
|
13
|
+
import useStreamingStatus from '@/hooks/use-streaming-status'
|
|
14
|
+
import StatusList from '@/components/StatusList'
|
|
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 '@/components/ui/button'
|
|
5
|
+
import {
|
|
6
|
+
Dialog,
|
|
7
|
+
DialogContent,
|
|
8
|
+
DialogFooter,
|
|
9
|
+
DialogHeader,
|
|
10
|
+
DialogTitle,
|
|
11
|
+
} from '@/components/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 '@/components/StatusList'
|
|
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,115 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { FileBoxIcon, TrashIcon } from 'lucide-react'
|
|
3
|
+
|
|
4
|
+
import { toast } from 'sonner'
|
|
5
|
+
|
|
6
|
+
import { Button } from '@/components/ui/button'
|
|
7
|
+
import { Input } from '@/components/ui/input'
|
|
8
|
+
import {
|
|
9
|
+
Dialog,
|
|
10
|
+
DialogContent,
|
|
11
|
+
DialogFooter,
|
|
12
|
+
DialogHeader,
|
|
13
|
+
DialogTitle,
|
|
14
|
+
} from '@/components/ui/dialog'
|
|
15
|
+
|
|
16
|
+
import {
|
|
17
|
+
setProjectStarter,
|
|
18
|
+
useApplicationMode,
|
|
19
|
+
useProjectStarter,
|
|
20
|
+
} from '@/store/project'
|
|
21
|
+
import { loadRemoteStarter } from '@/lib/api'
|
|
22
|
+
|
|
23
|
+
export default function Starter() {
|
|
24
|
+
const [url, setUrl] = useState('')
|
|
25
|
+
const [open, setOpen] = useState(false)
|
|
26
|
+
|
|
27
|
+
const mode = useApplicationMode()
|
|
28
|
+
|
|
29
|
+
const { projectStarter } = useProjectStarter()
|
|
30
|
+
|
|
31
|
+
if (mode !== 'setup') {
|
|
32
|
+
return null
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function onImport() {
|
|
36
|
+
const data = await loadRemoteStarter(url)
|
|
37
|
+
|
|
38
|
+
if ('error' in data) {
|
|
39
|
+
toast.error('Failed to load starter', {
|
|
40
|
+
description: data.error,
|
|
41
|
+
})
|
|
42
|
+
} else {
|
|
43
|
+
setProjectStarter(data)
|
|
44
|
+
setOpen(false)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<>
|
|
50
|
+
{projectStarter?.banner && (
|
|
51
|
+
<div className="flex justify-center mb-4">
|
|
52
|
+
<div className="p-2 bg-gray-300 rounded-lg shadow-xl shadow-gray-800">
|
|
53
|
+
<img
|
|
54
|
+
src={projectStarter.banner}
|
|
55
|
+
alt="Starter Banner"
|
|
56
|
+
className="w-40 max-w-full"
|
|
57
|
+
/>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
)}
|
|
61
|
+
{projectStarter?.name && (
|
|
62
|
+
<div className="text-md mb-4">
|
|
63
|
+
<Button
|
|
64
|
+
variant="outline"
|
|
65
|
+
size="sm"
|
|
66
|
+
className="mr-2"
|
|
67
|
+
onClick={() => {
|
|
68
|
+
setProjectStarter(undefined)
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
<TrashIcon className="w-4 h-4" />
|
|
72
|
+
</Button>
|
|
73
|
+
<span className="font-bold">Starter: </span>
|
|
74
|
+
{projectStarter.name}
|
|
75
|
+
</div>
|
|
76
|
+
)}
|
|
77
|
+
<div>
|
|
78
|
+
<Button
|
|
79
|
+
variant="secondary"
|
|
80
|
+
className="w-full"
|
|
81
|
+
onClick={() => {
|
|
82
|
+
setUrl('')
|
|
83
|
+
setOpen(true)
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
<FileBoxIcon className="w-4 h-4" />
|
|
87
|
+
Set Project Starter
|
|
88
|
+
</Button>
|
|
89
|
+
<Dialog modal open={open}>
|
|
90
|
+
<DialogContent className="sm:min-w-[425px] sm:max-w-fit">
|
|
91
|
+
<DialogHeader>
|
|
92
|
+
<DialogTitle>Project Starter URL</DialogTitle>
|
|
93
|
+
</DialogHeader>
|
|
94
|
+
<div>
|
|
95
|
+
<Input
|
|
96
|
+
value={url}
|
|
97
|
+
onChange={(e) => setUrl(e.target.value)}
|
|
98
|
+
placeholder="https://github.com/myorg/myproject/starter.json"
|
|
99
|
+
className="min-w-lg w-full"
|
|
100
|
+
onKeyDown={(e) => {
|
|
101
|
+
if (e.key === 'Enter') {
|
|
102
|
+
onImport()
|
|
103
|
+
}
|
|
104
|
+
}}
|
|
105
|
+
/>
|
|
106
|
+
</div>
|
|
107
|
+
<DialogFooter>
|
|
108
|
+
<Button onClick={onImport}>Load</Button>
|
|
109
|
+
</DialogFooter>
|
|
110
|
+
</DialogContent>
|
|
111
|
+
</Dialog>
|
|
112
|
+
</div>
|
|
113
|
+
</>
|
|
114
|
+
)
|
|
115
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Label } from '@/components/ui/label'
|
|
2
|
+
import { Switch } from '@/components/ui/switch'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
setTailwind,
|
|
6
|
+
setTypeScript,
|
|
7
|
+
useApplicationMode,
|
|
8
|
+
useProjectOptions,
|
|
9
|
+
useTailwindEditable,
|
|
10
|
+
useTypeScriptEditable,
|
|
11
|
+
} from '@/store/project'
|
|
12
|
+
|
|
13
|
+
export default function TypescriptSwitch() {
|
|
14
|
+
const typescript = useProjectOptions((state) => state.typescript)
|
|
15
|
+
const tailwind = useProjectOptions((state) => state.tailwind)
|
|
16
|
+
const mode = useApplicationMode()
|
|
17
|
+
const enableTailwind = useTailwindEditable()
|
|
18
|
+
const enableTypeScript = useTypeScriptEditable()
|
|
19
|
+
|
|
20
|
+
if (mode !== 'setup') {
|
|
21
|
+
return null
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div className="flex mt-4">
|
|
26
|
+
<div className="w-1/2 flex flex-row items-center">
|
|
27
|
+
<Switch
|
|
28
|
+
id="typescript-switch"
|
|
29
|
+
checked={typescript}
|
|
30
|
+
onCheckedChange={(checked) => setTypeScript(checked)}
|
|
31
|
+
disabled={!enableTypeScript}
|
|
32
|
+
/>
|
|
33
|
+
<Label htmlFor="typescript-switch" className="ml-2">
|
|
34
|
+
<img src="/typescript.svg" className="w-5" />
|
|
35
|
+
TypeScript
|
|
36
|
+
</Label>
|
|
37
|
+
</div>
|
|
38
|
+
<div className="w-1/2 flex flex-row items-center">
|
|
39
|
+
<Switch
|
|
40
|
+
id="tailwind-switch"
|
|
41
|
+
checked={tailwind}
|
|
42
|
+
onCheckedChange={(checked) => setTailwind(checked)}
|
|
43
|
+
disabled={!enableTailwind}
|
|
44
|
+
/>
|
|
45
|
+
<Label htmlFor="tailwind-switch" className="ml-2">
|
|
46
|
+
<img src="/tailwind.svg" className="w-5" />
|
|
47
|
+
Tailwind
|
|
48
|
+
</Label>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
@@ -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 }
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { Slot } from
|
|
3
|
-
import { cva
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { Slot } from '@radix-ui/react-slot'
|
|
3
|
+
import { cva } from 'class-variance-authority'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import type { VariantProps } from 'class-variance-authority'
|
|
6
|
+
|
|
7
|
+
import { cn } from '@/lib/utils'
|
|
6
8
|
|
|
7
9
|
const buttonVariants = cva(
|
|
8
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",
|
|
@@ -10,29 +12,29 @@ const buttonVariants = cva(
|
|
|
10
12
|
variants: {
|
|
11
13
|
variant: {
|
|
12
14
|
default:
|
|
13
|
-
|
|
15
|
+
'bg-primary text-primary-foreground shadow-xs hover:bg-primary/90',
|
|
14
16
|
destructive:
|
|
15
|
-
|
|
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',
|
|
16
18
|
outline:
|
|
17
|
-
|
|
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',
|
|
18
20
|
secondary:
|
|
19
|
-
|
|
21
|
+
'bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80',
|
|
20
22
|
ghost:
|
|
21
|
-
|
|
22
|
-
link:
|
|
23
|
+
'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',
|
|
24
|
+
link: 'text-primary underline-offset-4 hover:underline',
|
|
23
25
|
},
|
|
24
26
|
size: {
|
|
25
|
-
default:
|
|
26
|
-
sm:
|
|
27
|
-
lg:
|
|
28
|
-
icon:
|
|
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',
|
|
29
31
|
},
|
|
30
32
|
},
|
|
31
33
|
defaultVariants: {
|
|
32
|
-
variant:
|
|
33
|
-
size:
|
|
34
|
+
variant: 'default',
|
|
35
|
+
size: 'default',
|
|
34
36
|
},
|
|
35
|
-
}
|
|
37
|
+
},
|
|
36
38
|
)
|
|
37
39
|
|
|
38
40
|
function Button({
|
|
@@ -41,11 +43,11 @@ function Button({
|
|
|
41
43
|
size,
|
|
42
44
|
asChild = false,
|
|
43
45
|
...props
|
|
44
|
-
}: React.ComponentProps<
|
|
46
|
+
}: React.ComponentProps<'button'> &
|
|
45
47
|
VariantProps<typeof buttonVariants> & {
|
|
46
48
|
asChild?: boolean
|
|
47
49
|
}) {
|
|
48
|
-
const Comp = asChild ? Slot :
|
|
50
|
+
const Comp = asChild ? Slot : 'button'
|
|
49
51
|
|
|
50
52
|
return (
|
|
51
53
|
<Comp
|