mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-16 04:11:34 +00:00
Compare commits
57 Commits
shadcn/cod
...
shadcn@4.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14bb486174 | ||
|
|
12b49c986f | ||
|
|
64c8cd99ee | ||
|
|
7d718ddaa9 | ||
|
|
5570b3e24a | ||
|
|
214b1b8479 | ||
|
|
8bd161d453 | ||
|
|
64b88b6cdb | ||
|
|
6a070bf8c5 | ||
|
|
124495f0df | ||
|
|
43f64065b7 | ||
|
|
8bec9c1234 | ||
|
|
ba6ac6ec63 | ||
|
|
b75796ed76 | ||
|
|
d82b4a7d98 | ||
|
|
5b79499d23 | ||
|
|
d78ff8b858 | ||
|
|
ef78384bfd | ||
|
|
d3ab7fb00b | ||
|
|
bebc4356af | ||
|
|
14bc966fee | ||
|
|
6a4b27b80d | ||
|
|
c5b4080649 | ||
|
|
408b25c82a | ||
|
|
228b0e3ecd | ||
|
|
f900bd57d0 | ||
|
|
6b190c6a18 | ||
|
|
c43bc4f5d6 | ||
|
|
9cd14a684f | ||
|
|
fc1675e54d | ||
|
|
a5abe1aa0f | ||
|
|
031998436f | ||
|
|
29cb65c26b | ||
|
|
179c0c0b23 | ||
|
|
03430e03bf | ||
|
|
169682d87a | ||
|
|
336eee688e | ||
|
|
32e4827559 | ||
|
|
7a81328b23 | ||
|
|
5b40b9de5a | ||
|
|
e327cef2c1 | ||
|
|
563d572ba0 | ||
|
|
687f09817b | ||
|
|
31dbc6fc91 | ||
|
|
8db2be8b09 | ||
|
|
a8bd00466a | ||
|
|
e78bb7b4f3 | ||
|
|
acaa0953df | ||
|
|
632e2c012e | ||
|
|
78f6a8b0f0 | ||
|
|
a9f997d00a | ||
|
|
dbe1fa76b3 | ||
|
|
74c4c7508b | ||
|
|
4809da6f9c | ||
|
|
7ffefce9e0 | ||
|
|
6cad522930 | ||
|
|
d683b05d7f |
22
.cursor/rules/registry-bases-parity.mdc
Normal file
22
.cursor/rules/registry-bases-parity.mdc
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
description: Keep registry base and radix trees in sync when editing shared UI
|
||||||
|
globs: apps/v4/registry/bases/**/*
|
||||||
|
alwaysApply: false
|
||||||
|
---
|
||||||
|
|
||||||
|
# Registry bases: Base UI ↔ Radix parity
|
||||||
|
|
||||||
|
`apps/v4/registry/bases/base` and `apps/v4/registry/bases/radix` are **parallel registries**. Anything that exists in both trees for the same purpose (preview blocks, mirrored examples, shared card layouts, etc.) **must stay in sync**.
|
||||||
|
|
||||||
|
## When editing
|
||||||
|
|
||||||
|
- If you change a file under **`bases/base/...`**, apply the **same behavioral and visual change** to the matching path under **`bases/radix/...`** (and the reverse).
|
||||||
|
- Only diverge where APIs differ (e.g. import paths like `@/registry/bases/base/ui/*` vs `@/registry/bases/radix/ui/*`, or Base UI vs Radix component props).
|
||||||
|
- Do **not** update only one side unless the user explicitly asks for a single-base change.
|
||||||
|
|
||||||
|
## Typical mirrored paths
|
||||||
|
|
||||||
|
- `blocks/preview/**` — preview cards and blocks
|
||||||
|
- Parallel `ui/*` components when both exist for the same component
|
||||||
|
|
||||||
|
After edits, briefly confirm both trees were updated (or state why one side is intentionally unchanged).
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -15,6 +15,7 @@ build
|
|||||||
|
|
||||||
# misc
|
# misc
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.eslintcache
|
||||||
*.pem
|
*.pem
|
||||||
|
|
||||||
# debug
|
# debug
|
||||||
@@ -43,3 +44,4 @@ tsconfig.tsbuildinfo
|
|||||||
.notes
|
.notes
|
||||||
.playwright-mcp
|
.playwright-mcp
|
||||||
shadcn-workspace
|
shadcn-workspace
|
||||||
|
.codex-artifacts
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import { Button } from "@/examples/radix/ui/button"
|
import { IconMinus, IconPlus } from "@tabler/icons-react"
|
||||||
import { ButtonGroup } from "@/examples/radix/ui/button-group"
|
|
||||||
|
import { Button } from "@/styles/radix-nova/ui/button"
|
||||||
|
import { ButtonGroup } from "@/styles/radix-nova/ui/button-group"
|
||||||
import {
|
import {
|
||||||
Field,
|
Field,
|
||||||
FieldContent,
|
FieldContent,
|
||||||
@@ -13,11 +15,10 @@ import {
|
|||||||
FieldSeparator,
|
FieldSeparator,
|
||||||
FieldSet,
|
FieldSet,
|
||||||
FieldTitle,
|
FieldTitle,
|
||||||
} from "@/examples/radix/ui/field"
|
} from "@/styles/radix-nova/ui/field"
|
||||||
import { Input } from "@/examples/radix/ui/input"
|
import { Input } from "@/styles/radix-nova/ui/input"
|
||||||
import { RadioGroup, RadioGroupItem } from "@/examples/radix/ui/radio-group"
|
import { RadioGroup, RadioGroupItem } from "@/styles/radix-nova/ui/radio-group"
|
||||||
import { Switch } from "@/examples/radix/ui/switch"
|
import { Switch } from "@/styles/radix-nova/ui/switch"
|
||||||
import { IconMinus, IconPlus } from "@tabler/icons-react"
|
|
||||||
|
|
||||||
export function AppearanceSettings() {
|
export function AppearanceSettings() {
|
||||||
const [gpuCount, setGpuCount] = React.useState(8)
|
const [gpuCount, setGpuCount] = React.useState(8)
|
||||||
|
|||||||
@@ -1,8 +1,20 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import { Button } from "@/examples/radix/ui/button"
|
import {
|
||||||
import { ButtonGroup } from "@/examples/radix/ui/button-group"
|
ArchiveIcon,
|
||||||
|
ArrowLeftIcon,
|
||||||
|
CalendarPlusIcon,
|
||||||
|
ClockIcon,
|
||||||
|
ListFilterIcon,
|
||||||
|
MailCheckIcon,
|
||||||
|
MoreHorizontalIcon,
|
||||||
|
TagIcon,
|
||||||
|
Trash2Icon,
|
||||||
|
} from "lucide-react"
|
||||||
|
|
||||||
|
import { Button } from "@/styles/radix-nova/ui/button"
|
||||||
|
import { ButtonGroup } from "@/styles/radix-nova/ui/button-group"
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
@@ -15,18 +27,7 @@ import {
|
|||||||
DropdownMenuSubContent,
|
DropdownMenuSubContent,
|
||||||
DropdownMenuSubTrigger,
|
DropdownMenuSubTrigger,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/examples/radix/ui/dropdown-menu"
|
} from "@/styles/radix-nova/ui/dropdown-menu"
|
||||||
import {
|
|
||||||
ArchiveIcon,
|
|
||||||
ArrowLeftIcon,
|
|
||||||
CalendarPlusIcon,
|
|
||||||
ClockIcon,
|
|
||||||
ListFilterIcon,
|
|
||||||
MailCheckIcon,
|
|
||||||
MoreHorizontalIcon,
|
|
||||||
TagIcon,
|
|
||||||
Trash2Icon,
|
|
||||||
} from "lucide-react"
|
|
||||||
|
|
||||||
export function ButtonGroupDemo() {
|
export function ButtonGroupDemo() {
|
||||||
const [label, setLabel] = React.useState("personal")
|
const [label, setLabel] = React.useState("personal")
|
||||||
|
|||||||
@@ -1,20 +1,21 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import { Button } from "@/examples/radix/ui/button"
|
import { AudioLinesIcon, PlusIcon } from "lucide-react"
|
||||||
import { ButtonGroup } from "@/examples/radix/ui/button-group"
|
|
||||||
|
import { Button } from "@/styles/radix-nova/ui/button"
|
||||||
|
import { ButtonGroup } from "@/styles/radix-nova/ui/button-group"
|
||||||
import {
|
import {
|
||||||
InputGroup,
|
InputGroup,
|
||||||
InputGroupAddon,
|
InputGroupAddon,
|
||||||
InputGroupButton,
|
InputGroupButton,
|
||||||
InputGroupInput,
|
InputGroupInput,
|
||||||
} from "@/examples/radix/ui/input-group"
|
} from "@/styles/radix-nova/ui/input-group"
|
||||||
import {
|
import {
|
||||||
Tooltip,
|
Tooltip,
|
||||||
TooltipContent,
|
TooltipContent,
|
||||||
TooltipTrigger,
|
TooltipTrigger,
|
||||||
} from "@/examples/radix/ui/tooltip"
|
} from "@/styles/radix-nova/ui/tooltip"
|
||||||
import { AudioLinesIcon, PlusIcon } from "lucide-react"
|
|
||||||
|
|
||||||
export function ButtonGroupInputGroup() {
|
export function ButtonGroupInputGroup() {
|
||||||
const [voiceEnabled, setVoiceEnabled] = React.useState(false)
|
const [voiceEnabled, setVoiceEnabled] = React.useState(false)
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { Button } from "@/examples/radix/ui/button"
|
|
||||||
import { ButtonGroup } from "@/examples/radix/ui/button-group"
|
|
||||||
import { ArrowLeftIcon, ArrowRightIcon } from "lucide-react"
|
import { ArrowLeftIcon, ArrowRightIcon } from "lucide-react"
|
||||||
|
|
||||||
|
import { Button } from "@/styles/radix-nova/ui/button"
|
||||||
|
import { ButtonGroup } from "@/styles/radix-nova/ui/button-group"
|
||||||
|
|
||||||
export function ButtonGroupNested() {
|
export function ButtonGroupNested() {
|
||||||
return (
|
return (
|
||||||
<ButtonGroup>
|
<ButtonGroup>
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
import { Button } from "@/examples/radix/ui/button"
|
import { BotIcon, ChevronDownIcon } from "lucide-react"
|
||||||
import { ButtonGroup } from "@/examples/radix/ui/button-group"
|
|
||||||
|
import { Button } from "@/styles/radix-nova/ui/button"
|
||||||
|
import { ButtonGroup } from "@/styles/radix-nova/ui/button-group"
|
||||||
import {
|
import {
|
||||||
Popover,
|
Popover,
|
||||||
PopoverContent,
|
PopoverContent,
|
||||||
PopoverTrigger,
|
PopoverTrigger,
|
||||||
} from "@/examples/radix/ui/popover"
|
} from "@/styles/radix-nova/ui/popover"
|
||||||
import { Separator } from "@/examples/radix/ui/separator"
|
import { Separator } from "@/styles/radix-nova/ui/separator"
|
||||||
import { Textarea } from "@/examples/radix/ui/textarea"
|
import { Textarea } from "@/styles/radix-nova/ui/textarea"
|
||||||
import { BotIcon, ChevronDownIcon } from "lucide-react"
|
|
||||||
|
|
||||||
export function ButtonGroupPopover() {
|
export function ButtonGroupPopover() {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
|
import { PlusIcon } from "lucide-react"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Avatar,
|
Avatar,
|
||||||
AvatarFallback,
|
AvatarFallback,
|
||||||
AvatarGroup,
|
AvatarGroup,
|
||||||
AvatarImage,
|
AvatarImage,
|
||||||
} from "@/examples/radix/ui/avatar"
|
} from "@/styles/radix-nova/ui/avatar"
|
||||||
import { Button } from "@/examples/radix/ui/button"
|
import { Button } from "@/styles/radix-nova/ui/button"
|
||||||
import {
|
import {
|
||||||
Empty,
|
Empty,
|
||||||
EmptyContent,
|
EmptyContent,
|
||||||
@@ -12,8 +14,7 @@ import {
|
|||||||
EmptyHeader,
|
EmptyHeader,
|
||||||
EmptyMedia,
|
EmptyMedia,
|
||||||
EmptyTitle,
|
EmptyTitle,
|
||||||
} from "@/examples/radix/ui/empty"
|
} from "@/styles/radix-nova/ui/empty"
|
||||||
import { PlusIcon } from "lucide-react"
|
|
||||||
|
|
||||||
export function EmptyAvatarGroup() {
|
export function EmptyAvatarGroup() {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Checkbox } from "@/examples/radix/ui/checkbox"
|
import { Checkbox } from "@/styles/radix-nova/ui/checkbox"
|
||||||
import { Field, FieldLabel } from "@/examples/radix/ui/field"
|
import { Field, FieldLabel } from "@/styles/radix-nova/ui/field"
|
||||||
|
|
||||||
export function FieldCheckbox() {
|
export function FieldCheckbox() {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Button } from "@/examples/radix/ui/button"
|
import { Button } from "@/styles/radix-nova/ui/button"
|
||||||
import { Checkbox } from "@/examples/radix/ui/checkbox"
|
import { Checkbox } from "@/styles/radix-nova/ui/checkbox"
|
||||||
import {
|
import {
|
||||||
Field,
|
Field,
|
||||||
FieldDescription,
|
FieldDescription,
|
||||||
@@ -8,8 +8,8 @@ import {
|
|||||||
FieldLegend,
|
FieldLegend,
|
||||||
FieldSeparator,
|
FieldSeparator,
|
||||||
FieldSet,
|
FieldSet,
|
||||||
} from "@/examples/radix/ui/field"
|
} from "@/styles/radix-nova/ui/field"
|
||||||
import { Input } from "@/examples/radix/ui/input"
|
import { Input } from "@/styles/radix-nova/ui/input"
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
@@ -17,8 +17,8 @@ import {
|
|||||||
SelectItem,
|
SelectItem,
|
||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
SelectValue,
|
SelectValue,
|
||||||
} from "@/examples/radix/ui/select"
|
} from "@/styles/radix-nova/ui/select"
|
||||||
import { Textarea } from "@/examples/radix/ui/textarea"
|
import { Textarea } from "@/styles/radix-nova/ui/textarea"
|
||||||
|
|
||||||
export function FieldDemo() {
|
export function FieldDemo() {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Card, CardContent } from "@/examples/radix/ui/card"
|
import { Card, CardContent } from "@/styles/radix-nova/ui/card"
|
||||||
import { Checkbox } from "@/examples/radix/ui/checkbox"
|
import { Checkbox } from "@/styles/radix-nova/ui/checkbox"
|
||||||
import {
|
import {
|
||||||
Field,
|
Field,
|
||||||
FieldDescription,
|
FieldDescription,
|
||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
FieldLegend,
|
FieldLegend,
|
||||||
FieldSet,
|
FieldSet,
|
||||||
FieldTitle,
|
FieldTitle,
|
||||||
} from "@/examples/radix/ui/field"
|
} from "@/styles/radix-nova/ui/field"
|
||||||
|
|
||||||
const options = [
|
const options = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { useState } from "react"
|
import { useState } from "react"
|
||||||
import { Field, FieldDescription, FieldTitle } from "@/examples/radix/ui/field"
|
|
||||||
import { Slider } from "@/examples/radix/ui/slider"
|
import {
|
||||||
|
Field,
|
||||||
|
FieldDescription,
|
||||||
|
FieldTitle,
|
||||||
|
} from "@/styles/radix-nova/ui/field"
|
||||||
|
import { Slider } from "@/styles/radix-nova/ui/slider"
|
||||||
|
|
||||||
export function FieldSlider() {
|
export function FieldSlider() {
|
||||||
const [value, setValue] = useState([200, 800])
|
const [value, setValue] = useState([200, 800])
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { FieldSeparator } from "@/examples/radix/ui/field"
|
import { FieldSeparator } from "@/styles/radix-nova/ui/field"
|
||||||
|
|
||||||
import { AppearanceSettings } from "./appearance-settings"
|
import { AppearanceSettings } from "./appearance-settings"
|
||||||
import { ButtonGroupDemo } from "./button-group-demo"
|
import { ButtonGroupDemo } from "./button-group-demo"
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
|
import { IconInfoCircle, IconStar } from "@tabler/icons-react"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
InputGroup,
|
InputGroup,
|
||||||
InputGroupAddon,
|
InputGroupAddon,
|
||||||
InputGroupButton,
|
InputGroupButton,
|
||||||
InputGroupInput,
|
InputGroupInput,
|
||||||
} from "@/examples/radix/ui/input-group"
|
} from "@/styles/radix-nova/ui/input-group"
|
||||||
import { Label } from "@/examples/radix/ui/label"
|
import { Label } from "@/styles/radix-nova/ui/label"
|
||||||
import {
|
import {
|
||||||
Popover,
|
Popover,
|
||||||
PopoverContent,
|
PopoverContent,
|
||||||
PopoverTrigger,
|
PopoverTrigger,
|
||||||
} from "@/examples/radix/ui/popover"
|
} from "@/styles/radix-nova/ui/popover"
|
||||||
import { IconInfoCircle, IconStar } from "@tabler/icons-react"
|
|
||||||
|
|
||||||
export function InputGroupButtonExample() {
|
export function InputGroupButtonExample() {
|
||||||
const [isFavorite, setIsFavorite] = React.useState(false)
|
const [isFavorite, setIsFavorite] = React.useState(false)
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
|
import { IconCheck, IconInfoCircle, IconPlus } from "@tabler/icons-react"
|
||||||
|
import { ArrowUpIcon, Search } from "lucide-react"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/examples/radix/ui/dropdown-menu"
|
} from "@/styles/radix-nova/ui/dropdown-menu"
|
||||||
import {
|
import {
|
||||||
InputGroup,
|
InputGroup,
|
||||||
InputGroupAddon,
|
InputGroupAddon,
|
||||||
@@ -11,15 +14,13 @@ import {
|
|||||||
InputGroupInput,
|
InputGroupInput,
|
||||||
InputGroupText,
|
InputGroupText,
|
||||||
InputGroupTextarea,
|
InputGroupTextarea,
|
||||||
} from "@/examples/radix/ui/input-group"
|
} from "@/styles/radix-nova/ui/input-group"
|
||||||
import { Separator } from "@/examples/radix/ui/separator"
|
import { Separator } from "@/styles/radix-nova/ui/separator"
|
||||||
import {
|
import {
|
||||||
Tooltip,
|
Tooltip,
|
||||||
TooltipContent,
|
TooltipContent,
|
||||||
TooltipTrigger,
|
TooltipTrigger,
|
||||||
} from "@/examples/radix/ui/tooltip"
|
} from "@/styles/radix-nova/ui/tooltip"
|
||||||
import { IconCheck, IconInfoCircle, IconPlus } from "@tabler/icons-react"
|
|
||||||
import { ArrowUpIcon, Search } from "lucide-react"
|
|
||||||
|
|
||||||
export function InputGroupDemo() {
|
export function InputGroupDemo() {
|
||||||
return (
|
return (
|
||||||
@@ -88,7 +89,7 @@ export function InputGroupDemo() {
|
|||||||
<InputGroupInput placeholder="@shadcn" />
|
<InputGroupInput placeholder="@shadcn" />
|
||||||
<InputGroupAddon align="inline-end">
|
<InputGroupAddon align="inline-end">
|
||||||
<div className="flex size-4 items-center justify-center rounded-full bg-primary text-foreground">
|
<div className="flex size-4 items-center justify-center rounded-full bg-primary text-foreground">
|
||||||
<IconCheck className="size-3 text-white" />
|
<IconCheck className="size-3 text-background" />
|
||||||
</div>
|
</div>
|
||||||
</InputGroupAddon>
|
</InputGroupAddon>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { Button } from "@/examples/radix/ui/button"
|
import { BadgeCheckIcon, ChevronRightIcon } from "lucide-react"
|
||||||
|
|
||||||
|
import { Button } from "@/styles/radix-nova/ui/button"
|
||||||
import {
|
import {
|
||||||
Item,
|
Item,
|
||||||
ItemActions,
|
ItemActions,
|
||||||
@@ -6,8 +8,7 @@ import {
|
|||||||
ItemDescription,
|
ItemDescription,
|
||||||
ItemMedia,
|
ItemMedia,
|
||||||
ItemTitle,
|
ItemTitle,
|
||||||
} from "@/examples/radix/ui/item"
|
} from "@/styles/radix-nova/ui/item"
|
||||||
import { BadgeCheckIcon, ChevronRightIcon } from "lucide-react"
|
|
||||||
|
|
||||||
export function ItemDemo() {
|
export function ItemDemo() {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,8 +1,24 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { useMemo, useState } from "react"
|
import { useMemo, useState } from "react"
|
||||||
import { Avatar, AvatarFallback, AvatarImage } from "@/examples/radix/ui/avatar"
|
import {
|
||||||
import { Badge } from "@/examples/radix/ui/badge"
|
IconApps,
|
||||||
|
IconArrowUp,
|
||||||
|
IconAt,
|
||||||
|
IconBook,
|
||||||
|
IconCircleDashedPlus,
|
||||||
|
IconPaperclip,
|
||||||
|
IconPlus,
|
||||||
|
IconWorld,
|
||||||
|
IconX,
|
||||||
|
} from "@tabler/icons-react"
|
||||||
|
|
||||||
|
import {
|
||||||
|
Avatar,
|
||||||
|
AvatarFallback,
|
||||||
|
AvatarImage,
|
||||||
|
} from "@/styles/radix-nova/ui/avatar"
|
||||||
|
import { Badge } from "@/styles/radix-nova/ui/badge"
|
||||||
import {
|
import {
|
||||||
Command,
|
Command,
|
||||||
CommandEmpty,
|
CommandEmpty,
|
||||||
@@ -10,7 +26,7 @@ import {
|
|||||||
CommandInput,
|
CommandInput,
|
||||||
CommandItem,
|
CommandItem,
|
||||||
CommandList,
|
CommandList,
|
||||||
} from "@/examples/radix/ui/command"
|
} from "@/styles/radix-nova/ui/command"
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuCheckboxItem,
|
DropdownMenuCheckboxItem,
|
||||||
@@ -23,36 +39,25 @@ import {
|
|||||||
DropdownMenuSubContent,
|
DropdownMenuSubContent,
|
||||||
DropdownMenuSubTrigger,
|
DropdownMenuSubTrigger,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/examples/radix/ui/dropdown-menu"
|
} from "@/styles/radix-nova/ui/dropdown-menu"
|
||||||
import { Field, FieldLabel } from "@/examples/radix/ui/field"
|
import { Field, FieldLabel } from "@/styles/radix-nova/ui/field"
|
||||||
import {
|
import {
|
||||||
InputGroup,
|
InputGroup,
|
||||||
InputGroupAddon,
|
InputGroupAddon,
|
||||||
InputGroupButton,
|
InputGroupButton,
|
||||||
InputGroupTextarea,
|
InputGroupTextarea,
|
||||||
} from "@/examples/radix/ui/input-group"
|
} from "@/styles/radix-nova/ui/input-group"
|
||||||
import {
|
import {
|
||||||
Popover,
|
Popover,
|
||||||
PopoverContent,
|
PopoverContent,
|
||||||
PopoverTrigger,
|
PopoverTrigger,
|
||||||
} from "@/examples/radix/ui/popover"
|
} from "@/styles/radix-nova/ui/popover"
|
||||||
import { Switch } from "@/examples/radix/ui/switch"
|
import { Switch } from "@/styles/radix-nova/ui/switch"
|
||||||
import {
|
import {
|
||||||
Tooltip,
|
Tooltip,
|
||||||
TooltipContent,
|
TooltipContent,
|
||||||
TooltipTrigger,
|
TooltipTrigger,
|
||||||
} from "@/examples/radix/ui/tooltip"
|
} from "@/styles/radix-nova/ui/tooltip"
|
||||||
import {
|
|
||||||
IconApps,
|
|
||||||
IconArrowUp,
|
|
||||||
IconAt,
|
|
||||||
IconBook,
|
|
||||||
IconCircleDashedPlus,
|
|
||||||
IconPaperclip,
|
|
||||||
IconPlus,
|
|
||||||
IconWorld,
|
|
||||||
IconX,
|
|
||||||
} from "@tabler/icons-react"
|
|
||||||
|
|
||||||
const SAMPLE_DATA = {
|
const SAMPLE_DATA = {
|
||||||
mentionable: [
|
mentionable: [
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Badge } from "@/examples/radix/ui/badge"
|
import { Badge } from "@/styles/radix-nova/ui/badge"
|
||||||
import { Spinner } from "@/examples/radix/ui/spinner"
|
import { Spinner } from "@/styles/radix-nova/ui/spinner"
|
||||||
|
|
||||||
export function SpinnerBadge() {
|
export function SpinnerBadge() {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Button } from "@/examples/radix/ui/button"
|
import { Button } from "@/styles/radix-nova/ui/button"
|
||||||
import {
|
import {
|
||||||
Empty,
|
Empty,
|
||||||
EmptyContent,
|
EmptyContent,
|
||||||
@@ -6,8 +6,8 @@ import {
|
|||||||
EmptyHeader,
|
EmptyHeader,
|
||||||
EmptyMedia,
|
EmptyMedia,
|
||||||
EmptyTitle,
|
EmptyTitle,
|
||||||
} from "@/examples/radix/ui/empty"
|
} from "@/styles/radix-nova/ui/empty"
|
||||||
import { Spinner } from "@/examples/radix/ui/spinner"
|
import { Spinner } from "@/styles/radix-nova/ui/spinner"
|
||||||
|
|
||||||
export function SpinnerEmpty() {
|
export function SpinnerEmpty() {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ export default function BlocksLayout({
|
|||||||
<a href="#blocks">Browse Blocks</a>
|
<a href="#blocks">Browse Blocks</a>
|
||||||
</Button>
|
</Button>
|
||||||
<Button asChild variant="ghost" size="sm">
|
<Button asChild variant="ghost" size="sm">
|
||||||
<Link href="/docs/blocks">Add a block</Link>
|
<Link href="/docs/components">View Components</Link>
|
||||||
</Button>
|
</Button>
|
||||||
</PageActions>
|
</PageActions>
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import { Button } from "@/examples/radix/ui/button"
|
|
||||||
import { mdxComponents } from "@/mdx-components"
|
import { mdxComponents } from "@/mdx-components"
|
||||||
import { IconRss } from "@tabler/icons-react"
|
import { IconRss } from "@tabler/icons-react"
|
||||||
|
|
||||||
import { getChangelogPages, type ChangelogPageData } from "@/lib/changelog"
|
import { getChangelogPages, type ChangelogPageData } from "@/lib/changelog"
|
||||||
import { absoluteUrl } from "@/lib/utils"
|
import { absoluteUrl } from "@/lib/utils"
|
||||||
import { OpenInV0Cta } from "@/components/open-in-v0-cta"
|
import { OpenInV0Cta } from "@/components/open-in-v0-cta"
|
||||||
|
import { Button } from "@/styles/radix-nova/ui/button"
|
||||||
|
|
||||||
export const revalidate = false
|
export const revalidate = false
|
||||||
export const dynamic = "force-static"
|
export const dynamic = "force-static"
|
||||||
@@ -79,7 +79,7 @@ export default function ChangelogPage() {
|
|||||||
})}
|
})}
|
||||||
{olderPages.length > 0 && (
|
{olderPages.length > 0 && (
|
||||||
<div id="more-updates" className="mb-24 scroll-mt-24">
|
<div id="more-updates" className="mb-24 scroll-mt-24">
|
||||||
<h2 className="font-heading mb-6 text-xl font-semibold tracking-tight">
|
<h2 className="mb-6 font-heading text-xl font-semibold tracking-tight">
|
||||||
More Updates
|
More Updates
|
||||||
</h2>
|
</h2>
|
||||||
<div className="grid auto-rows-fr gap-3 sm:grid-cols-2">
|
<div className="grid auto-rows-fr gap-3 sm:grid-cols-2">
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import { Button } from "@/examples/base/ui-rtl/button"
|
import { IconMinus, IconPlus } from "@tabler/icons-react"
|
||||||
import { ButtonGroup } from "@/examples/base/ui-rtl/button-group"
|
|
||||||
|
import { useLanguageContext } from "@/components/language-selector"
|
||||||
|
import { Button } from "@/styles/base-nova/ui-rtl/button"
|
||||||
|
import { ButtonGroup } from "@/styles/base-nova/ui-rtl/button-group"
|
||||||
import {
|
import {
|
||||||
Field,
|
Field,
|
||||||
FieldContent,
|
FieldContent,
|
||||||
@@ -13,13 +16,13 @@ import {
|
|||||||
FieldSeparator,
|
FieldSeparator,
|
||||||
FieldSet,
|
FieldSet,
|
||||||
FieldTitle,
|
FieldTitle,
|
||||||
} from "@/examples/base/ui-rtl/field"
|
} from "@/styles/base-nova/ui-rtl/field"
|
||||||
import { Input } from "@/examples/base/ui-rtl/input"
|
import { Input } from "@/styles/base-nova/ui-rtl/input"
|
||||||
import { RadioGroup, RadioGroupItem } from "@/examples/base/ui-rtl/radio-group"
|
import {
|
||||||
import { Switch } from "@/examples/base/ui-rtl/switch"
|
RadioGroup,
|
||||||
import { IconMinus, IconPlus } from "@tabler/icons-react"
|
RadioGroupItem,
|
||||||
|
} from "@/styles/base-nova/ui-rtl/radio-group"
|
||||||
import { useLanguageContext } from "@/components/language-selector"
|
import { Switch } from "@/styles/base-nova/ui-rtl/switch"
|
||||||
|
|
||||||
const translations = {
|
const translations = {
|
||||||
ar: {
|
ar: {
|
||||||
|
|||||||
@@ -1,22 +1,6 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import { Button } from "@/examples/base/ui-rtl/button"
|
|
||||||
import { ButtonGroup } from "@/examples/base/ui-rtl/button-group"
|
|
||||||
import {
|
|
||||||
DropdownMenu,
|
|
||||||
DropdownMenuContent,
|
|
||||||
DropdownMenuGroup,
|
|
||||||
DropdownMenuItem,
|
|
||||||
DropdownMenuPortal,
|
|
||||||
DropdownMenuRadioGroup,
|
|
||||||
DropdownMenuRadioItem,
|
|
||||||
DropdownMenuSeparator,
|
|
||||||
DropdownMenuSub,
|
|
||||||
DropdownMenuSubContent,
|
|
||||||
DropdownMenuSubTrigger,
|
|
||||||
DropdownMenuTrigger,
|
|
||||||
} from "@/examples/base/ui-rtl/dropdown-menu"
|
|
||||||
import {
|
import {
|
||||||
ArchiveIcon,
|
ArchiveIcon,
|
||||||
ArrowLeftIcon,
|
ArrowLeftIcon,
|
||||||
@@ -30,6 +14,22 @@ import {
|
|||||||
} from "lucide-react"
|
} from "lucide-react"
|
||||||
|
|
||||||
import { useLanguageContext } from "@/components/language-selector"
|
import { useLanguageContext } from "@/components/language-selector"
|
||||||
|
import { Button } from "@/styles/base-nova/ui-rtl/button"
|
||||||
|
import { ButtonGroup } from "@/styles/base-nova/ui-rtl/button-group"
|
||||||
|
import {
|
||||||
|
DropdownMenu,
|
||||||
|
DropdownMenuContent,
|
||||||
|
DropdownMenuGroup,
|
||||||
|
DropdownMenuItem,
|
||||||
|
DropdownMenuPortal,
|
||||||
|
DropdownMenuRadioGroup,
|
||||||
|
DropdownMenuRadioItem,
|
||||||
|
DropdownMenuSeparator,
|
||||||
|
DropdownMenuSub,
|
||||||
|
DropdownMenuSubContent,
|
||||||
|
DropdownMenuSubTrigger,
|
||||||
|
DropdownMenuTrigger,
|
||||||
|
} from "@/styles/base-nova/ui-rtl/dropdown-menu"
|
||||||
|
|
||||||
const translations = {
|
const translations = {
|
||||||
ar: {
|
ar: {
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import { Button } from "@/examples/base/ui-rtl/button"
|
import { AudioLinesIcon, PlusIcon } from "lucide-react"
|
||||||
import { ButtonGroup } from "@/examples/base/ui-rtl/button-group"
|
|
||||||
|
import { useLanguageContext } from "@/components/language-selector"
|
||||||
|
import { Button } from "@/styles/base-nova/ui-rtl/button"
|
||||||
|
import { ButtonGroup } from "@/styles/base-nova/ui-rtl/button-group"
|
||||||
import {
|
import {
|
||||||
InputGroup,
|
InputGroup,
|
||||||
InputGroupAddon,
|
InputGroupAddon,
|
||||||
InputGroupButton,
|
InputGroupButton,
|
||||||
InputGroupInput,
|
InputGroupInput,
|
||||||
} from "@/examples/base/ui-rtl/input-group"
|
} from "@/styles/base-nova/ui-rtl/input-group"
|
||||||
import {
|
import {
|
||||||
Tooltip,
|
Tooltip,
|
||||||
TooltipContent,
|
TooltipContent,
|
||||||
TooltipTrigger,
|
TooltipTrigger,
|
||||||
} from "@/examples/base/ui-rtl/tooltip"
|
} from "@/styles/base-nova/ui-rtl/tooltip"
|
||||||
import { AudioLinesIcon, PlusIcon } from "lucide-react"
|
|
||||||
|
|
||||||
import { useLanguageContext } from "@/components/language-selector"
|
|
||||||
|
|
||||||
const translations = {
|
const translations = {
|
||||||
ar: {
|
ar: {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { Button } from "@/examples/base/ui-rtl/button"
|
|
||||||
import { ButtonGroup } from "@/examples/base/ui-rtl/button-group"
|
|
||||||
import { ArrowLeftIcon, ArrowRightIcon } from "lucide-react"
|
import { ArrowLeftIcon, ArrowRightIcon } from "lucide-react"
|
||||||
|
|
||||||
import { useLanguageContext } from "@/components/language-selector"
|
import { useLanguageContext } from "@/components/language-selector"
|
||||||
|
import { Button } from "@/styles/base-nova/ui-rtl/button"
|
||||||
|
import { ButtonGroup } from "@/styles/base-nova/ui-rtl/button-group"
|
||||||
|
|
||||||
const translations = {
|
const translations = {
|
||||||
ar: {
|
ar: {
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { Button } from "@/examples/base/ui-rtl/button"
|
import { BotIcon, ChevronDownIcon } from "lucide-react"
|
||||||
import { ButtonGroup } from "@/examples/base/ui-rtl/button-group"
|
|
||||||
|
import { useLanguageContext } from "@/components/language-selector"
|
||||||
|
import { Button } from "@/styles/base-nova/ui-rtl/button"
|
||||||
|
import { ButtonGroup } from "@/styles/base-nova/ui-rtl/button-group"
|
||||||
import {
|
import {
|
||||||
Popover,
|
Popover,
|
||||||
PopoverContent,
|
PopoverContent,
|
||||||
PopoverTrigger,
|
PopoverTrigger,
|
||||||
} from "@/examples/base/ui-rtl/popover"
|
} from "@/styles/base-nova/ui-rtl/popover"
|
||||||
import { Separator } from "@/examples/base/ui-rtl/separator"
|
import { Separator } from "@/styles/base-nova/ui-rtl/separator"
|
||||||
import { Textarea } from "@/examples/base/ui-rtl/textarea"
|
import { Textarea } from "@/styles/base-nova/ui-rtl/textarea"
|
||||||
import { BotIcon, ChevronDownIcon } from "lucide-react"
|
|
||||||
|
|
||||||
import { useLanguageContext } from "@/components/language-selector"
|
|
||||||
|
|
||||||
const translations = {
|
const translations = {
|
||||||
ar: {
|
ar: {
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
|
import { PlusIcon } from "lucide-react"
|
||||||
|
|
||||||
|
import { useLanguageContext } from "@/components/language-selector"
|
||||||
import {
|
import {
|
||||||
Avatar,
|
Avatar,
|
||||||
AvatarFallback,
|
AvatarFallback,
|
||||||
AvatarGroup,
|
AvatarGroup,
|
||||||
AvatarImage,
|
AvatarImage,
|
||||||
} from "@/examples/base/ui-rtl/avatar"
|
} from "@/styles/base-nova/ui-rtl/avatar"
|
||||||
import { Button } from "@/examples/base/ui-rtl/button"
|
import { Button } from "@/styles/base-nova/ui-rtl/button"
|
||||||
import {
|
import {
|
||||||
Empty,
|
Empty,
|
||||||
EmptyContent,
|
EmptyContent,
|
||||||
@@ -14,10 +17,7 @@ import {
|
|||||||
EmptyHeader,
|
EmptyHeader,
|
||||||
EmptyMedia,
|
EmptyMedia,
|
||||||
EmptyTitle,
|
EmptyTitle,
|
||||||
} from "@/examples/base/ui-rtl/empty"
|
} from "@/styles/base-nova/ui-rtl/empty"
|
||||||
import { PlusIcon } from "lucide-react"
|
|
||||||
|
|
||||||
import { useLanguageContext } from "@/components/language-selector"
|
|
||||||
|
|
||||||
const translations = {
|
const translations = {
|
||||||
ar: {
|
ar: {
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { Checkbox } from "@/examples/base/ui-rtl/checkbox"
|
|
||||||
import { Field, FieldLabel } from "@/examples/base/ui-rtl/field"
|
|
||||||
|
|
||||||
import { useLanguageContext } from "@/components/language-selector"
|
import { useLanguageContext } from "@/components/language-selector"
|
||||||
|
import { Checkbox } from "@/styles/base-nova/ui-rtl/checkbox"
|
||||||
|
import { Field, FieldLabel } from "@/styles/base-nova/ui-rtl/field"
|
||||||
|
|
||||||
const translations = {
|
const translations = {
|
||||||
ar: {
|
ar: {
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { Button } from "@/examples/base/ui-rtl/button"
|
import { useLanguageContext } from "@/components/language-selector"
|
||||||
import { Checkbox } from "@/examples/base/ui-rtl/checkbox"
|
import { Button } from "@/styles/base-nova/ui-rtl/button"
|
||||||
|
import { Checkbox } from "@/styles/base-nova/ui-rtl/checkbox"
|
||||||
import {
|
import {
|
||||||
Field,
|
Field,
|
||||||
FieldDescription,
|
FieldDescription,
|
||||||
@@ -10,8 +11,8 @@ import {
|
|||||||
FieldLegend,
|
FieldLegend,
|
||||||
FieldSeparator,
|
FieldSeparator,
|
||||||
FieldSet,
|
FieldSet,
|
||||||
} from "@/examples/base/ui-rtl/field"
|
} from "@/styles/base-nova/ui-rtl/field"
|
||||||
import { Input } from "@/examples/base/ui-rtl/input"
|
import { Input } from "@/styles/base-nova/ui-rtl/input"
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
@@ -19,10 +20,8 @@ import {
|
|||||||
SelectItem,
|
SelectItem,
|
||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
SelectValue,
|
SelectValue,
|
||||||
} from "@/examples/base/ui-rtl/select"
|
} from "@/styles/base-nova/ui-rtl/select"
|
||||||
import { Textarea } from "@/examples/base/ui-rtl/textarea"
|
import { Textarea } from "@/styles/base-nova/ui-rtl/textarea"
|
||||||
|
|
||||||
import { useLanguageContext } from "@/components/language-selector"
|
|
||||||
|
|
||||||
const translations = {
|
const translations = {
|
||||||
ar: {
|
ar: {
|
||||||
@@ -140,7 +139,7 @@ export function FieldDemo() {
|
|||||||
<div className="grid grid-cols-2 gap-4">
|
<div className="grid grid-cols-2 gap-4">
|
||||||
<Field>
|
<Field>
|
||||||
<FieldLabel htmlFor="rtl-exp-month">{t.month}</FieldLabel>
|
<FieldLabel htmlFor="rtl-exp-month">{t.month}</FieldLabel>
|
||||||
<Select defaultValue="" items={months}>
|
<Select defaultValue="">
|
||||||
<SelectTrigger id="rtl-exp-month">
|
<SelectTrigger id="rtl-exp-month">
|
||||||
<SelectValue placeholder="MM" />
|
<SelectValue placeholder="MM" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
@@ -157,7 +156,7 @@ export function FieldDemo() {
|
|||||||
</Field>
|
</Field>
|
||||||
<Field>
|
<Field>
|
||||||
<FieldLabel htmlFor="rtl-exp-year">{t.year}</FieldLabel>
|
<FieldLabel htmlFor="rtl-exp-year">{t.year}</FieldLabel>
|
||||||
<Select defaultValue="" items={years}>
|
<Select defaultValue="">
|
||||||
<SelectTrigger id="rtl-exp-year">
|
<SelectTrigger id="rtl-exp-year">
|
||||||
<SelectValue placeholder="YYYY" />
|
<SelectValue placeholder="YYYY" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { Card, CardContent } from "@/examples/base/ui-rtl/card"
|
import { useLanguageContext } from "@/components/language-selector"
|
||||||
import { Checkbox } from "@/examples/base/ui-rtl/checkbox"
|
import { Card, CardContent } from "@/styles/base-nova/ui-rtl/card"
|
||||||
|
import { Checkbox } from "@/styles/base-nova/ui-rtl/checkbox"
|
||||||
import {
|
import {
|
||||||
Field,
|
Field,
|
||||||
FieldDescription,
|
FieldDescription,
|
||||||
@@ -10,9 +11,7 @@ import {
|
|||||||
FieldLegend,
|
FieldLegend,
|
||||||
FieldSet,
|
FieldSet,
|
||||||
FieldTitle,
|
FieldTitle,
|
||||||
} from "@/examples/base/ui-rtl/field"
|
} from "@/styles/base-nova/ui-rtl/field"
|
||||||
|
|
||||||
import { useLanguageContext } from "@/components/language-selector"
|
|
||||||
|
|
||||||
const translations = {
|
const translations = {
|
||||||
ar: {
|
ar: {
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { useState } from "react"
|
import { useState } from "react"
|
||||||
|
|
||||||
|
import { useLanguageContext } from "@/components/language-selector"
|
||||||
import {
|
import {
|
||||||
Field,
|
Field,
|
||||||
FieldDescription,
|
FieldDescription,
|
||||||
FieldTitle,
|
FieldTitle,
|
||||||
} from "@/examples/base/ui-rtl/field"
|
} from "@/styles/base-nova/ui-rtl/field"
|
||||||
import { Slider } from "@/examples/base/ui-rtl/slider"
|
import { Slider } from "@/styles/base-nova/ui-rtl/slider"
|
||||||
|
|
||||||
import { useLanguageContext } from "@/components/language-selector"
|
|
||||||
|
|
||||||
const translations = {
|
const translations = {
|
||||||
ar: {
|
ar: {
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { DirectionProvider } from "@/examples/base/ui-rtl/direction"
|
|
||||||
import { FieldSeparator } from "@/examples/base/ui-rtl/field"
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
LanguageProvider,
|
LanguageProvider,
|
||||||
LanguageSelector,
|
LanguageSelector,
|
||||||
useLanguageContext,
|
useLanguageContext,
|
||||||
} from "@/components/language-selector"
|
} from "@/components/language-selector"
|
||||||
|
import { DirectionProvider } from "@/styles/base-nova/ui-rtl/direction"
|
||||||
|
import { FieldSeparator } from "@/styles/base-nova/ui-rtl/field"
|
||||||
|
|
||||||
import { AppearanceSettings } from "./appearance-settings"
|
import { AppearanceSettings } from "./appearance-settings"
|
||||||
import { ButtonGroupDemo } from "./button-group-demo"
|
import { ButtonGroupDemo } from "./button-group-demo"
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
|
import { IconInfoCircle, IconStar } from "@tabler/icons-react"
|
||||||
|
|
||||||
|
import { useLanguageContext } from "@/components/language-selector"
|
||||||
import {
|
import {
|
||||||
InputGroup,
|
InputGroup,
|
||||||
InputGroupAddon,
|
InputGroupAddon,
|
||||||
InputGroupButton,
|
InputGroupButton,
|
||||||
InputGroupInput,
|
InputGroupInput,
|
||||||
} from "@/examples/base/ui-rtl/input-group"
|
} from "@/styles/base-nova/ui-rtl/input-group"
|
||||||
import { Label } from "@/examples/base/ui-rtl/label"
|
import { Label } from "@/styles/base-nova/ui-rtl/label"
|
||||||
import {
|
import {
|
||||||
Popover,
|
Popover,
|
||||||
PopoverContent,
|
PopoverContent,
|
||||||
PopoverTrigger,
|
PopoverTrigger,
|
||||||
} from "@/examples/base/ui-rtl/popover"
|
} from "@/styles/base-nova/ui-rtl/popover"
|
||||||
import { IconInfoCircle, IconStar } from "@tabler/icons-react"
|
|
||||||
|
|
||||||
import { useLanguageContext } from "@/components/language-selector"
|
|
||||||
|
|
||||||
const translations = {
|
const translations = {
|
||||||
ar: {
|
ar: {
|
||||||
|
|||||||
@@ -1,25 +1,5 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import {
|
|
||||||
DropdownMenu,
|
|
||||||
DropdownMenuContent,
|
|
||||||
DropdownMenuItem,
|
|
||||||
DropdownMenuTrigger,
|
|
||||||
} from "@/examples/base/ui-rtl/dropdown-menu"
|
|
||||||
import {
|
|
||||||
InputGroup,
|
|
||||||
InputGroupAddon,
|
|
||||||
InputGroupButton,
|
|
||||||
InputGroupInput,
|
|
||||||
InputGroupText,
|
|
||||||
InputGroupTextarea,
|
|
||||||
} from "@/examples/base/ui-rtl/input-group"
|
|
||||||
import { Separator } from "@/examples/base/ui-rtl/separator"
|
|
||||||
import {
|
|
||||||
Tooltip,
|
|
||||||
TooltipContent,
|
|
||||||
TooltipTrigger,
|
|
||||||
} from "@/examples/base/ui-rtl/tooltip"
|
|
||||||
import {
|
import {
|
||||||
IconCheck,
|
IconCheck,
|
||||||
IconChevronDown,
|
IconChevronDown,
|
||||||
@@ -29,6 +9,26 @@ import {
|
|||||||
import { ArrowUpIcon, Search } from "lucide-react"
|
import { ArrowUpIcon, Search } from "lucide-react"
|
||||||
|
|
||||||
import { useLanguageContext } from "@/components/language-selector"
|
import { useLanguageContext } from "@/components/language-selector"
|
||||||
|
import {
|
||||||
|
DropdownMenu,
|
||||||
|
DropdownMenuContent,
|
||||||
|
DropdownMenuItem,
|
||||||
|
DropdownMenuTrigger,
|
||||||
|
} from "@/styles/base-nova/ui-rtl/dropdown-menu"
|
||||||
|
import {
|
||||||
|
InputGroup,
|
||||||
|
InputGroupAddon,
|
||||||
|
InputGroupButton,
|
||||||
|
InputGroupInput,
|
||||||
|
InputGroupText,
|
||||||
|
InputGroupTextarea,
|
||||||
|
} from "@/styles/base-nova/ui-rtl/input-group"
|
||||||
|
import { Separator } from "@/styles/base-nova/ui-rtl/separator"
|
||||||
|
import {
|
||||||
|
Tooltip,
|
||||||
|
TooltipContent,
|
||||||
|
TooltipTrigger,
|
||||||
|
} from "@/styles/base-nova/ui-rtl/tooltip"
|
||||||
|
|
||||||
const translations = {
|
const translations = {
|
||||||
ar: {
|
ar: {
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { Button } from "@/examples/base/ui-rtl/button"
|
import { BadgeCheckIcon, ChevronRightIcon } from "lucide-react"
|
||||||
|
|
||||||
|
import { useLanguageContext } from "@/components/language-selector"
|
||||||
|
import { Button } from "@/styles/base-nova/ui-rtl/button"
|
||||||
import {
|
import {
|
||||||
Item,
|
Item,
|
||||||
ItemActions,
|
ItemActions,
|
||||||
@@ -8,10 +11,7 @@ import {
|
|||||||
ItemDescription,
|
ItemDescription,
|
||||||
ItemMedia,
|
ItemMedia,
|
||||||
ItemTitle,
|
ItemTitle,
|
||||||
} from "@/examples/base/ui-rtl/item"
|
} from "@/styles/base-nova/ui-rtl/item"
|
||||||
import { BadgeCheckIcon, ChevronRightIcon } from "lucide-react"
|
|
||||||
|
|
||||||
import { useLanguageContext } from "@/components/language-selector"
|
|
||||||
|
|
||||||
const translations = {
|
const translations = {
|
||||||
ar: {
|
ar: {
|
||||||
|
|||||||
@@ -1,47 +1,6 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { useMemo, useState } from "react"
|
import { useMemo, useState } from "react"
|
||||||
import {
|
|
||||||
Avatar,
|
|
||||||
AvatarFallback,
|
|
||||||
AvatarImage,
|
|
||||||
} from "@/examples/base/ui-rtl/avatar"
|
|
||||||
import { Badge } from "@/examples/base/ui-rtl/badge"
|
|
||||||
import {
|
|
||||||
Command,
|
|
||||||
CommandEmpty,
|
|
||||||
CommandGroup,
|
|
||||||
CommandInput,
|
|
||||||
CommandItem,
|
|
||||||
CommandList,
|
|
||||||
} from "@/examples/base/ui-rtl/command"
|
|
||||||
import {
|
|
||||||
DropdownMenu,
|
|
||||||
DropdownMenuCheckboxItem,
|
|
||||||
DropdownMenuContent,
|
|
||||||
DropdownMenuGroup,
|
|
||||||
DropdownMenuItem,
|
|
||||||
DropdownMenuLabel,
|
|
||||||
DropdownMenuSeparator,
|
|
||||||
DropdownMenuSub,
|
|
||||||
DropdownMenuSubContent,
|
|
||||||
DropdownMenuSubTrigger,
|
|
||||||
DropdownMenuTrigger,
|
|
||||||
} from "@/examples/base/ui-rtl/dropdown-menu"
|
|
||||||
import { Field, FieldLabel } from "@/examples/base/ui-rtl/field"
|
|
||||||
import {
|
|
||||||
InputGroup,
|
|
||||||
InputGroupAddon,
|
|
||||||
InputGroupButton,
|
|
||||||
InputGroupTextarea,
|
|
||||||
} from "@/examples/base/ui-rtl/input-group"
|
|
||||||
import { Popover, PopoverContent } from "@/examples/base/ui-rtl/popover"
|
|
||||||
import { Switch } from "@/examples/base/ui-rtl/switch"
|
|
||||||
import {
|
|
||||||
Tooltip,
|
|
||||||
TooltipContent,
|
|
||||||
TooltipTrigger,
|
|
||||||
} from "@/examples/base/ui-rtl/tooltip"
|
|
||||||
import {
|
import {
|
||||||
IconApps,
|
IconApps,
|
||||||
IconArrowUp,
|
IconArrowUp,
|
||||||
@@ -55,6 +14,47 @@ import {
|
|||||||
} from "@tabler/icons-react"
|
} from "@tabler/icons-react"
|
||||||
|
|
||||||
import { useLanguageContext } from "@/components/language-selector"
|
import { useLanguageContext } from "@/components/language-selector"
|
||||||
|
import {
|
||||||
|
Avatar,
|
||||||
|
AvatarFallback,
|
||||||
|
AvatarImage,
|
||||||
|
} from "@/styles/base-nova/ui-rtl/avatar"
|
||||||
|
import { Badge } from "@/styles/base-nova/ui-rtl/badge"
|
||||||
|
import {
|
||||||
|
Command,
|
||||||
|
CommandEmpty,
|
||||||
|
CommandGroup,
|
||||||
|
CommandInput,
|
||||||
|
CommandItem,
|
||||||
|
CommandList,
|
||||||
|
} from "@/styles/base-nova/ui-rtl/command"
|
||||||
|
import {
|
||||||
|
DropdownMenu,
|
||||||
|
DropdownMenuCheckboxItem,
|
||||||
|
DropdownMenuContent,
|
||||||
|
DropdownMenuGroup,
|
||||||
|
DropdownMenuItem,
|
||||||
|
DropdownMenuLabel,
|
||||||
|
DropdownMenuSeparator,
|
||||||
|
DropdownMenuSub,
|
||||||
|
DropdownMenuSubContent,
|
||||||
|
DropdownMenuSubTrigger,
|
||||||
|
DropdownMenuTrigger,
|
||||||
|
} from "@/styles/base-nova/ui-rtl/dropdown-menu"
|
||||||
|
import { Field, FieldLabel } from "@/styles/base-nova/ui-rtl/field"
|
||||||
|
import {
|
||||||
|
InputGroup,
|
||||||
|
InputGroupAddon,
|
||||||
|
InputGroupButton,
|
||||||
|
InputGroupTextarea,
|
||||||
|
} from "@/styles/base-nova/ui-rtl/input-group"
|
||||||
|
import { Popover, PopoverContent } from "@/styles/base-nova/ui-rtl/popover"
|
||||||
|
import { Switch } from "@/styles/base-nova/ui-rtl/switch"
|
||||||
|
import {
|
||||||
|
Tooltip,
|
||||||
|
TooltipContent,
|
||||||
|
TooltipTrigger,
|
||||||
|
} from "@/styles/base-nova/ui-rtl/tooltip"
|
||||||
|
|
||||||
const translations = {
|
const translations = {
|
||||||
ar: {
|
ar: {
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { Badge } from "@/examples/base/ui-rtl/badge"
|
|
||||||
import { Spinner } from "@/examples/base/ui-rtl/spinner"
|
|
||||||
|
|
||||||
import { useLanguageContext } from "@/components/language-selector"
|
import { useLanguageContext } from "@/components/language-selector"
|
||||||
|
import { Badge } from "@/styles/base-nova/ui-rtl/badge"
|
||||||
|
import { Spinner } from "@/styles/base-nova/ui-rtl/spinner"
|
||||||
|
|
||||||
const translations = {
|
const translations = {
|
||||||
ar: {
|
ar: {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { Button } from "@/examples/base/ui-rtl/button"
|
import { useLanguageContext } from "@/components/language-selector"
|
||||||
|
import { Button } from "@/styles/base-nova/ui-rtl/button"
|
||||||
import {
|
import {
|
||||||
Empty,
|
Empty,
|
||||||
EmptyContent,
|
EmptyContent,
|
||||||
@@ -8,10 +9,8 @@ import {
|
|||||||
EmptyHeader,
|
EmptyHeader,
|
||||||
EmptyMedia,
|
EmptyMedia,
|
||||||
EmptyTitle,
|
EmptyTitle,
|
||||||
} from "@/examples/base/ui-rtl/empty"
|
} from "@/styles/base-nova/ui-rtl/empty"
|
||||||
import { Spinner } from "@/examples/base/ui-rtl/spinner"
|
import { Spinner } from "@/styles/base-nova/ui-rtl/spinner"
|
||||||
|
|
||||||
import { useLanguageContext } from "@/components/language-selector"
|
|
||||||
|
|
||||||
const translations = {
|
const translations = {
|
||||||
ar: {
|
ar: {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import Script from "next/script"
|
import Script from "next/script"
|
||||||
|
import { type RegistryItem } from "shadcn/schema"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Command,
|
Command,
|
||||||
CommandDialog,
|
CommandDialog,
|
||||||
@@ -9,9 +11,7 @@ import {
|
|||||||
CommandInput,
|
CommandInput,
|
||||||
CommandItem,
|
CommandItem,
|
||||||
CommandList,
|
CommandList,
|
||||||
} from "@/examples/base/ui/command"
|
} from "@/styles/base-nova/ui/command"
|
||||||
import { type RegistryItem } from "shadcn/schema"
|
|
||||||
|
|
||||||
import { useActionMenu } from "@/app/(create)/hooks/use-action-menu"
|
import { useActionMenu } from "@/app/(create)/hooks/use-action-menu"
|
||||||
|
|
||||||
export const CMD_K_FORWARD_TYPE = "cmd-k-forward"
|
export const CMD_K_FORWARD_TYPE = "cmd-k-forward"
|
||||||
|
|||||||
136
apps/v4/app/(create)/components/chart-color-picker.tsx
Normal file
136
apps/v4/app/(create)/components/chart-color-picker.tsx
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import * as React from "react"
|
||||||
|
|
||||||
|
import { useMounted } from "@/hooks/use-mounted"
|
||||||
|
import {
|
||||||
|
BASE_COLORS,
|
||||||
|
getThemesForBaseColor,
|
||||||
|
type ChartColorName,
|
||||||
|
} from "@/registry/config"
|
||||||
|
import { LockButton } from "@/app/(create)/components/lock-button"
|
||||||
|
import {
|
||||||
|
Picker,
|
||||||
|
PickerContent,
|
||||||
|
PickerGroup,
|
||||||
|
PickerRadioGroup,
|
||||||
|
PickerRadioItem,
|
||||||
|
PickerSeparator,
|
||||||
|
PickerTrigger,
|
||||||
|
} from "@/app/(create)/components/picker"
|
||||||
|
import { useDesignSystemSearchParams } from "@/app/(create)/lib/search-params"
|
||||||
|
|
||||||
|
export function ChartColorPicker({
|
||||||
|
isMobile,
|
||||||
|
anchorRef,
|
||||||
|
}: {
|
||||||
|
isMobile: boolean
|
||||||
|
anchorRef: React.RefObject<HTMLDivElement | null>
|
||||||
|
}) {
|
||||||
|
const mounted = useMounted()
|
||||||
|
const [params, setParams] = useDesignSystemSearchParams()
|
||||||
|
|
||||||
|
const availableChartColors = React.useMemo(
|
||||||
|
() => getThemesForBaseColor(params.baseColor),
|
||||||
|
[params.baseColor]
|
||||||
|
)
|
||||||
|
|
||||||
|
const currentChartColor = React.useMemo(
|
||||||
|
() =>
|
||||||
|
availableChartColors.find((theme) => theme.name === params.chartColor),
|
||||||
|
[availableChartColors, params.chartColor]
|
||||||
|
)
|
||||||
|
|
||||||
|
const currentChartColorIsBaseColor = React.useMemo(
|
||||||
|
() => BASE_COLORS.find((baseColor) => baseColor.name === params.chartColor),
|
||||||
|
[params.chartColor]
|
||||||
|
)
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (!currentChartColor && availableChartColors.length > 0) {
|
||||||
|
setParams({ chartColor: availableChartColors[0].name })
|
||||||
|
}
|
||||||
|
}, [currentChartColor, availableChartColors, setParams])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="group/picker relative">
|
||||||
|
<Picker>
|
||||||
|
<PickerTrigger>
|
||||||
|
<div className="flex flex-col justify-start text-left">
|
||||||
|
<div className="text-xs text-muted-foreground">Chart Color</div>
|
||||||
|
<div className="text-sm font-medium text-foreground">
|
||||||
|
{currentChartColor?.title}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{mounted && (
|
||||||
|
<div
|
||||||
|
style={
|
||||||
|
{
|
||||||
|
"--color":
|
||||||
|
currentChartColor?.cssVars?.dark?.[
|
||||||
|
currentChartColorIsBaseColor
|
||||||
|
? "muted-foreground"
|
||||||
|
: "primary"
|
||||||
|
],
|
||||||
|
} as React.CSSProperties
|
||||||
|
}
|
||||||
|
className="pointer-events-none absolute top-1/2 right-4 size-4 -translate-y-1/2 rounded-full bg-(--color) select-none md:right-2.5"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</PickerTrigger>
|
||||||
|
<PickerContent
|
||||||
|
anchor={isMobile ? anchorRef : undefined}
|
||||||
|
side={isMobile ? "top" : "right"}
|
||||||
|
align={isMobile ? "center" : "start"}
|
||||||
|
className="max-h-92"
|
||||||
|
>
|
||||||
|
<PickerRadioGroup
|
||||||
|
value={currentChartColor?.name}
|
||||||
|
onValueChange={(value) => {
|
||||||
|
setParams({ chartColor: value as ChartColorName })
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<PickerGroup>
|
||||||
|
{availableChartColors
|
||||||
|
.filter((theme) =>
|
||||||
|
BASE_COLORS.find((baseColor) => baseColor.name === theme.name)
|
||||||
|
)
|
||||||
|
.map((theme) => (
|
||||||
|
<PickerRadioItem
|
||||||
|
key={theme.name}
|
||||||
|
value={theme.name}
|
||||||
|
closeOnClick={isMobile}
|
||||||
|
>
|
||||||
|
{theme.title}
|
||||||
|
</PickerRadioItem>
|
||||||
|
))}
|
||||||
|
</PickerGroup>
|
||||||
|
<PickerSeparator />
|
||||||
|
<PickerGroup>
|
||||||
|
{availableChartColors
|
||||||
|
.filter(
|
||||||
|
(theme) =>
|
||||||
|
!BASE_COLORS.find(
|
||||||
|
(baseColor) => baseColor.name === theme.name
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.map((theme) => (
|
||||||
|
<PickerRadioItem
|
||||||
|
key={theme.name}
|
||||||
|
value={theme.name}
|
||||||
|
closeOnClick={isMobile}
|
||||||
|
>
|
||||||
|
{theme.title}
|
||||||
|
</PickerRadioItem>
|
||||||
|
))}
|
||||||
|
</PickerGroup>
|
||||||
|
</PickerRadioGroup>
|
||||||
|
</PickerContent>
|
||||||
|
</Picker>
|
||||||
|
<LockButton
|
||||||
|
param="chartColor"
|
||||||
|
className="absolute top-1/2 right-8 -translate-y-1/2"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import { Button } from "@/examples/base/ui/button"
|
|
||||||
|
|
||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
import { copyToClipboardWithMeta } from "@/components/copy-button"
|
import { copyToClipboardWithMeta } from "@/components/copy-button"
|
||||||
|
import { Button } from "@/styles/base-nova/ui/button"
|
||||||
import { usePresetCode } from "@/app/(create)/hooks/use-design-system"
|
import { usePresetCode } from "@/app/(create)/hooks/use-design-system"
|
||||||
|
|
||||||
export function CopyPreset({ className }: React.ComponentProps<typeof Button>) {
|
export function CopyPreset({ className }: React.ComponentProps<typeof Button>) {
|
||||||
|
|||||||
@@ -1,36 +1,34 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
|
import { type RegistryItem } from "shadcn/schema"
|
||||||
|
|
||||||
|
import { useIsMobile } from "@/hooks/use-mobile"
|
||||||
|
import { getThemesForBaseColor, STYLES } from "@/registry/config"
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
CardContent,
|
CardContent,
|
||||||
CardFooter,
|
CardFooter,
|
||||||
CardHeader,
|
CardHeader,
|
||||||
} from "@/examples/base/ui/card"
|
} from "@/styles/base-nova/ui/card"
|
||||||
import { FieldGroup } from "@/examples/base/ui/field"
|
import { FieldGroup, FieldSeparator } from "@/styles/base-nova/ui/field"
|
||||||
import { Separator } from "@/examples/base/ui/separator"
|
|
||||||
import { CardTitle } from "@/examples/radix/ui/card"
|
|
||||||
import { type RegistryItem } from "shadcn/schema"
|
|
||||||
|
|
||||||
import { useIsMobile } from "@/hooks/use-mobile"
|
|
||||||
import { getThemesForBaseColor, STYLES } from "@/registry/config"
|
|
||||||
import { MenuAccentPicker } from "@/app/(create)/components/accent-picker"
|
import { MenuAccentPicker } from "@/app/(create)/components/accent-picker"
|
||||||
import { ActionMenu } from "@/app/(create)/components/action-menu"
|
import { ActionMenu } from "@/app/(create)/components/action-menu"
|
||||||
import { BaseColorPicker } from "@/app/(create)/components/base-color-picker"
|
import { BaseColorPicker } from "@/app/(create)/components/base-color-picker"
|
||||||
import { BasePicker } from "@/app/(create)/components/base-picker"
|
import { BasePicker } from "@/app/(create)/components/base-picker"
|
||||||
|
import { ChartColorPicker } from "@/app/(create)/components/chart-color-picker"
|
||||||
import { CopyPreset } from "@/app/(create)/components/copy-preset"
|
import { CopyPreset } from "@/app/(create)/components/copy-preset"
|
||||||
import { FontPicker } from "@/app/(create)/components/font-picker"
|
import { FontPicker } from "@/app/(create)/components/font-picker"
|
||||||
import { IconLibraryPicker } from "@/app/(create)/components/icon-library-picker"
|
import { IconLibraryPicker } from "@/app/(create)/components/icon-library-picker"
|
||||||
import { MainMenu } from "@/app/(create)/components/main-menu"
|
import { MainMenu } from "@/app/(create)/components/main-menu"
|
||||||
import { MenuColorPicker } from "@/app/(create)/components/menu-picker"
|
import { MenuColorPicker } from "@/app/(create)/components/menu-picker"
|
||||||
import { ProjectForm } from "@/app/(create)/components/project-form"
|
|
||||||
import { RadiusPicker } from "@/app/(create)/components/radius-picker"
|
import { RadiusPicker } from "@/app/(create)/components/radius-picker"
|
||||||
import { RandomButton } from "@/app/(create)/components/random-button"
|
import { RandomButton } from "@/app/(create)/components/random-button"
|
||||||
import { ResetDialog } from "@/app/(create)/components/reset-button"
|
import { ResetDialog } from "@/app/(create)/components/reset-button"
|
||||||
import { StylePicker } from "@/app/(create)/components/style-picker"
|
import { StylePicker } from "@/app/(create)/components/style-picker"
|
||||||
import { ThemePicker } from "@/app/(create)/components/theme-picker"
|
import { ThemePicker } from "@/app/(create)/components/theme-picker"
|
||||||
import { V0Button } from "@/app/(create)/components/v0-button"
|
import { V0Button } from "@/app/(create)/components/v0-button"
|
||||||
import { FONTS } from "@/app/(create)/lib/fonts"
|
import { FONT_HEADING_OPTIONS, FONTS } from "@/app/(create)/lib/fonts"
|
||||||
import { useDesignSystemSearchParams } from "@/app/(create)/lib/search-params"
|
import { useDesignSystemSearchParams } from "@/app/(create)/lib/search-params"
|
||||||
|
|
||||||
export function Customizer({
|
export function Customizer({
|
||||||
@@ -57,22 +55,40 @@ export function Customizer({
|
|||||||
<MainMenu />
|
<MainMenu />
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="no-scrollbar min-h-0 flex-1 overflow-x-auto overflow-y-hidden md:overflow-y-auto">
|
<CardContent className="no-scrollbar min-h-0 flex-1 overflow-x-auto overflow-y-hidden md:overflow-y-auto">
|
||||||
<FieldGroup className="flex-row gap-2.5 py-px md:flex-col md:gap-3.25">
|
<FieldGroup className="flex-row gap-2.5 py-px **:data-[slot=field-separator]:-mx-4 **:data-[slot=field-separator]:w-auto md:flex-col md:gap-3.25">
|
||||||
<BasePicker isMobile={isMobile} anchorRef={anchorRef} />
|
{isMobile && <BasePicker isMobile={isMobile} anchorRef={anchorRef} />}
|
||||||
<StylePicker
|
<StylePicker
|
||||||
styles={STYLES}
|
styles={STYLES}
|
||||||
isMobile={isMobile}
|
isMobile={isMobile}
|
||||||
anchorRef={anchorRef}
|
anchorRef={anchorRef}
|
||||||
/>
|
/>
|
||||||
|
<FieldSeparator className="hidden md:block" />
|
||||||
<BaseColorPicker isMobile={isMobile} anchorRef={anchorRef} />
|
<BaseColorPicker isMobile={isMobile} anchorRef={anchorRef} />
|
||||||
<ThemePicker
|
<ThemePicker
|
||||||
themes={availableThemes}
|
themes={availableThemes}
|
||||||
isMobile={isMobile}
|
isMobile={isMobile}
|
||||||
anchorRef={anchorRef}
|
anchorRef={anchorRef}
|
||||||
/>
|
/>
|
||||||
|
<ChartColorPicker isMobile={isMobile} anchorRef={anchorRef} />
|
||||||
|
<FieldSeparator className="hidden md:block" />
|
||||||
|
<FontPicker
|
||||||
|
label="Heading"
|
||||||
|
param="fontHeading"
|
||||||
|
fonts={FONT_HEADING_OPTIONS}
|
||||||
|
isMobile={isMobile}
|
||||||
|
anchorRef={anchorRef}
|
||||||
|
/>
|
||||||
|
<FontPicker
|
||||||
|
label="Font"
|
||||||
|
param="font"
|
||||||
|
fonts={FONTS}
|
||||||
|
isMobile={isMobile}
|
||||||
|
anchorRef={anchorRef}
|
||||||
|
/>
|
||||||
|
<FieldSeparator className="hidden md:block" />
|
||||||
<IconLibraryPicker isMobile={isMobile} anchorRef={anchorRef} />
|
<IconLibraryPicker isMobile={isMobile} anchorRef={anchorRef} />
|
||||||
<FontPicker fonts={FONTS} isMobile={isMobile} anchorRef={anchorRef} />
|
|
||||||
<RadiusPicker isMobile={isMobile} anchorRef={anchorRef} />
|
<RadiusPicker isMobile={isMobile} anchorRef={anchorRef} />
|
||||||
|
<FieldSeparator className="hidden md:block" />
|
||||||
<MenuColorPicker isMobile={isMobile} anchorRef={anchorRef} />
|
<MenuColorPicker isMobile={isMobile} anchorRef={anchorRef} />
|
||||||
<MenuAccentPicker isMobile={isMobile} anchorRef={anchorRef} />
|
<MenuAccentPicker isMobile={isMobile} anchorRef={anchorRef} />
|
||||||
</FieldGroup>
|
</FieldGroup>
|
||||||
|
|||||||
@@ -64,18 +64,37 @@ export function DesignSystemProvider({
|
|||||||
history: "replace", // …or push updates into the iframe history.
|
history: "replace", // …or push updates into the iframe history.
|
||||||
})
|
})
|
||||||
const [isReady, setIsReady] = React.useState(false)
|
const [isReady, setIsReady] = React.useState(false)
|
||||||
const { style, theme, font, baseColor, menuAccent, menuColor, radius } =
|
const {
|
||||||
searchParams
|
style,
|
||||||
|
theme,
|
||||||
|
font,
|
||||||
|
fontHeading,
|
||||||
|
baseColor,
|
||||||
|
chartColor,
|
||||||
|
menuAccent,
|
||||||
|
menuColor,
|
||||||
|
radius,
|
||||||
|
} = searchParams
|
||||||
const effectiveRadius = style === "lyra" ? "none" : radius
|
const effectiveRadius = style === "lyra" ? "none" : radius
|
||||||
const selectedFont = React.useMemo(
|
const selectedFont = React.useMemo(
|
||||||
() => FONTS.find((fontOption) => fontOption.value === font),
|
() => FONTS.find((fontOption) => fontOption.value === font),
|
||||||
[font]
|
[font]
|
||||||
)
|
)
|
||||||
|
const selectedHeadingFont = React.useMemo(() => {
|
||||||
|
if (fontHeading === "inherit" || fontHeading === font) {
|
||||||
|
return selectedFont
|
||||||
|
}
|
||||||
|
|
||||||
|
return FONTS.find((fontOption) => fontOption.value === fontHeading)
|
||||||
|
}, [font, fontHeading, selectedFont])
|
||||||
const initialFontSansRef = React.useRef<string | null>(null)
|
const initialFontSansRef = React.useRef<string | null>(null)
|
||||||
|
const initialFontHeadingRef = React.useRef<string | null>(null)
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
initialFontSansRef.current =
|
initialFontSansRef.current =
|
||||||
document.documentElement.style.getPropertyValue("--font-sans")
|
document.documentElement.style.getPropertyValue("--font-sans")
|
||||||
|
initialFontHeadingRef.current =
|
||||||
|
document.documentElement.style.getPropertyValue("--font-heading")
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
removeManagedBodyClasses(document.body)
|
removeManagedBodyClasses(document.body)
|
||||||
@@ -86,10 +105,18 @@ export function DesignSystemProvider({
|
|||||||
"--font-sans",
|
"--font-sans",
|
||||||
initialFontSansRef.current
|
initialFontSansRef.current
|
||||||
)
|
)
|
||||||
return
|
} else {
|
||||||
|
document.documentElement.style.removeProperty("--font-sans")
|
||||||
}
|
}
|
||||||
|
|
||||||
document.documentElement.style.removeProperty("--font-sans")
|
if (initialFontHeadingRef.current) {
|
||||||
|
document.documentElement.style.setProperty(
|
||||||
|
"--font-heading",
|
||||||
|
initialFontHeadingRef.current
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
document.documentElement.style.removeProperty("--font-heading")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
@@ -124,12 +151,29 @@ export function DesignSystemProvider({
|
|||||||
// Always set --font-sans for the preview so the selected font is visible.
|
// Always set --font-sans for the preview so the selected font is visible.
|
||||||
// The font type (sans/serif/mono) is metadata for the CLI updater.
|
// The font type (sans/serif/mono) is metadata for the CLI updater.
|
||||||
if (selectedFont) {
|
if (selectedFont) {
|
||||||
const fontFamily = selectedFont.font.style.fontFamily
|
document.documentElement.style.setProperty(
|
||||||
document.documentElement.style.setProperty("--font-sans", fontFamily)
|
"--font-sans",
|
||||||
|
selectedFont.font.style.fontFamily
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedHeadingFont) {
|
||||||
|
document.documentElement.style.setProperty(
|
||||||
|
"--font-heading",
|
||||||
|
selectedHeadingFont.font.style.fontFamily
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsReady(true)
|
setIsReady(true)
|
||||||
}, [style, theme, font, baseColor, selectedFont])
|
}, [
|
||||||
|
style,
|
||||||
|
theme,
|
||||||
|
font,
|
||||||
|
fontHeading,
|
||||||
|
baseColor,
|
||||||
|
selectedFont,
|
||||||
|
selectedHeadingFont,
|
||||||
|
])
|
||||||
|
|
||||||
const registryTheme = React.useMemo(() => {
|
const registryTheme = React.useMemo(() => {
|
||||||
if (!baseColor || !theme || !menuAccent || !effectiveRadius) {
|
if (!baseColor || !theme || !menuAccent || !effectiveRadius) {
|
||||||
@@ -140,12 +184,13 @@ export function DesignSystemProvider({
|
|||||||
...DEFAULT_CONFIG,
|
...DEFAULT_CONFIG,
|
||||||
baseColor,
|
baseColor,
|
||||||
theme,
|
theme,
|
||||||
|
chartColor,
|
||||||
menuAccent,
|
menuAccent,
|
||||||
radius: effectiveRadius,
|
radius: effectiveRadius,
|
||||||
}
|
}
|
||||||
|
|
||||||
return buildRegistryTheme(config)
|
return buildRegistryTheme(config)
|
||||||
}, [baseColor, theme, menuAccent, effectiveRadius])
|
}, [baseColor, theme, chartColor, menuAccent, effectiveRadius])
|
||||||
|
|
||||||
// Use useLayoutEffect for synchronous CSS var updates.
|
// Use useLayoutEffect for synchronous CSS var updates.
|
||||||
React.useLayoutEffect(() => {
|
React.useLayoutEffect(() => {
|
||||||
|
|||||||
@@ -2,13 +2,6 @@
|
|||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
|
|
||||||
import {
|
|
||||||
Item,
|
|
||||||
ItemContent,
|
|
||||||
ItemDescription,
|
|
||||||
ItemTitle,
|
|
||||||
} from "@/registry/bases/radix/ui/item"
|
|
||||||
import { type FontValue } from "@/registry/config"
|
|
||||||
import { LockButton } from "@/app/(create)/components/lock-button"
|
import { LockButton } from "@/app/(create)/components/lock-button"
|
||||||
import {
|
import {
|
||||||
Picker,
|
Picker,
|
||||||
@@ -20,28 +13,68 @@ import {
|
|||||||
PickerSeparator,
|
PickerSeparator,
|
||||||
PickerTrigger,
|
PickerTrigger,
|
||||||
} from "@/app/(create)/components/picker"
|
} from "@/app/(create)/components/picker"
|
||||||
import { type Font } from "@/app/(create)/lib/fonts"
|
import { FONTS } from "@/app/(create)/lib/fonts"
|
||||||
import { useDesignSystemSearchParams } from "@/app/(create)/lib/search-params"
|
import {
|
||||||
|
useDesignSystemSearchParams,
|
||||||
|
type DesignSystemSearchParams,
|
||||||
|
} from "@/app/(create)/lib/search-params"
|
||||||
|
|
||||||
|
type FontPickerOption = {
|
||||||
|
name: string
|
||||||
|
value: string
|
||||||
|
type: string
|
||||||
|
font: {
|
||||||
|
style: {
|
||||||
|
fontFamily: string
|
||||||
|
}
|
||||||
|
} | null
|
||||||
|
}
|
||||||
|
|
||||||
export function FontPicker({
|
export function FontPicker({
|
||||||
|
label,
|
||||||
|
param,
|
||||||
fonts,
|
fonts,
|
||||||
isMobile,
|
isMobile,
|
||||||
anchorRef,
|
anchorRef,
|
||||||
}: {
|
}: {
|
||||||
fonts: readonly Font[]
|
label: string
|
||||||
|
param: "font" | "fontHeading"
|
||||||
|
fonts: readonly FontPickerOption[]
|
||||||
isMobile: boolean
|
isMobile: boolean
|
||||||
anchorRef: React.RefObject<HTMLDivElement | null>
|
anchorRef: React.RefObject<HTMLDivElement | null>
|
||||||
}) {
|
}) {
|
||||||
const [params, setParams] = useDesignSystemSearchParams()
|
const [params, setParams] = useDesignSystemSearchParams()
|
||||||
|
const currentValue = param === "font" ? params.font : params.fontHeading
|
||||||
|
const handleFontChange = React.useCallback(
|
||||||
|
(value: string) => {
|
||||||
|
setParams({
|
||||||
|
[param]: value,
|
||||||
|
} as Partial<DesignSystemSearchParams>)
|
||||||
|
},
|
||||||
|
[param, setParams]
|
||||||
|
)
|
||||||
|
|
||||||
const currentFont = React.useMemo(
|
const currentFont = React.useMemo(
|
||||||
() => fonts.find((font) => font.value === params.font),
|
() => fonts.find((font) => font.value === currentValue),
|
||||||
[fonts, params.font]
|
[fonts, currentValue]
|
||||||
)
|
)
|
||||||
|
const currentBodyFont = React.useMemo(
|
||||||
|
() => FONTS.find((font) => font.value === params.font),
|
||||||
|
[params.font]
|
||||||
|
)
|
||||||
|
const inheritsBodyFont = param === "fontHeading" && currentValue === "inherit"
|
||||||
|
const displayFontName = inheritsBodyFont
|
||||||
|
? currentBodyFont?.name
|
||||||
|
: currentFont?.name
|
||||||
|
const inheritFontLabel = currentBodyFont ? currentBodyFont.name : "Body font"
|
||||||
const groupedFonts = React.useMemo(() => {
|
const groupedFonts = React.useMemo(() => {
|
||||||
const groups = new Map<Font["type"], Font[]>()
|
const pickerFonts =
|
||||||
|
param === "fontHeading"
|
||||||
|
? fonts.filter((font) => font.value !== "inherit")
|
||||||
|
: fonts
|
||||||
|
const groups = new Map<string, FontPickerOption[]>()
|
||||||
|
|
||||||
for (const font of fonts) {
|
for (const font of pickerFonts) {
|
||||||
const existing = groups.get(font.type)
|
const existing = groups.get(font.type)
|
||||||
if (existing) {
|
if (existing) {
|
||||||
existing.push(font)
|
existing.push(font)
|
||||||
@@ -56,21 +89,25 @@ export function FontPicker({
|
|||||||
label: `${type.charAt(0).toUpperCase()}${type.slice(1)}`,
|
label: `${type.charAt(0).toUpperCase()}${type.slice(1)}`,
|
||||||
items,
|
items,
|
||||||
}))
|
}))
|
||||||
}, [fonts])
|
}, [fonts, param])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="group/picker relative">
|
<div className="group/picker relative">
|
||||||
<Picker>
|
<Picker>
|
||||||
<PickerTrigger>
|
<PickerTrigger>
|
||||||
<div className="flex flex-col justify-start text-left">
|
<div className="flex flex-col justify-start text-left">
|
||||||
<div className="text-xs text-muted-foreground">Font</div>
|
<div className="text-xs text-muted-foreground">{label}</div>
|
||||||
<div className="text-sm font-medium text-foreground">
|
<div className="text-sm font-medium text-foreground">
|
||||||
{currentFont?.name}
|
{displayFontName}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className="pointer-events-none absolute top-1/2 right-4 flex size-4 -translate-y-1/2 items-center justify-center text-base text-foreground select-none md:right-2.5"
|
className="pointer-events-none absolute top-1/2 right-4 flex size-4 -translate-y-1/2 items-center justify-center text-base text-foreground select-none md:right-2.5"
|
||||||
style={{ fontFamily: currentFont?.font.style.fontFamily }}
|
style={{
|
||||||
|
fontFamily:
|
||||||
|
currentFont?.font?.style.fontFamily ??
|
||||||
|
currentBodyFont?.font.style.fontFamily,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Aa
|
Aa
|
||||||
</div>
|
</div>
|
||||||
@@ -82,11 +119,19 @@ export function FontPicker({
|
|||||||
className="max-h-96"
|
className="max-h-96"
|
||||||
>
|
>
|
||||||
<PickerRadioGroup
|
<PickerRadioGroup
|
||||||
value={currentFont?.value}
|
value={currentValue}
|
||||||
onValueChange={(value) => {
|
onValueChange={handleFontChange}
|
||||||
setParams({ font: value as FontValue })
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
|
{param === "fontHeading" ? (
|
||||||
|
<>
|
||||||
|
<PickerGroup>
|
||||||
|
<PickerRadioItem value="inherit" closeOnClick={isMobile}>
|
||||||
|
{inheritFontLabel}
|
||||||
|
</PickerRadioItem>
|
||||||
|
</PickerGroup>
|
||||||
|
<PickerSeparator />
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
{groupedFonts.map((group) => (
|
{groupedFonts.map((group) => (
|
||||||
<PickerGroup key={group.type}>
|
<PickerGroup key={group.type}>
|
||||||
<PickerLabel>{group.label}</PickerLabel>
|
<PickerLabel>{group.label}</PickerLabel>
|
||||||
@@ -105,7 +150,7 @@ export function FontPicker({
|
|||||||
</PickerContent>
|
</PickerContent>
|
||||||
</Picker>
|
</Picker>
|
||||||
<LockButton
|
<LockButton
|
||||||
param="font"
|
param={param}
|
||||||
className="absolute top-1/2 right-8 -translate-y-1/2"
|
className="absolute top-1/2 right-8 -translate-y-1/2"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import Script from "next/script"
|
import Script from "next/script"
|
||||||
import { Button } from "@/examples/base/ui/button"
|
|
||||||
import { Redo02Icon, Undo02Icon } from "@hugeicons/core-free-icons"
|
import { Redo02Icon, Undo02Icon } from "@hugeicons/core-free-icons"
|
||||||
import { HugeiconsIcon } from "@hugeicons/react"
|
import { HugeiconsIcon } from "@hugeicons/react"
|
||||||
|
|
||||||
|
import { Button } from "@/styles/base-nova/ui/button"
|
||||||
import { useHistory } from "@/app/(create)/hooks/use-history"
|
import { useHistory } from "@/app/(create)/hooks/use-history"
|
||||||
|
|
||||||
export const UNDO_FORWARD_TYPE = "undo-forward"
|
export const UNDO_FORWARD_TYPE = "undo-forward"
|
||||||
|
|||||||
@@ -2,11 +2,16 @@
|
|||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
|
import { ChevronRightIcon } from "lucide-react"
|
||||||
|
import { type RegistryItem } from "shadcn/schema"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
import { type Base } from "@/registry/bases"
|
||||||
import {
|
import {
|
||||||
Collapsible,
|
Collapsible,
|
||||||
CollapsibleContent,
|
CollapsibleContent,
|
||||||
CollapsibleTrigger,
|
CollapsibleTrigger,
|
||||||
} from "@/examples/base/ui/collapsible"
|
} from "@/styles/base-nova/ui/collapsible"
|
||||||
import {
|
import {
|
||||||
Sidebar,
|
Sidebar,
|
||||||
SidebarContent,
|
SidebarContent,
|
||||||
@@ -15,12 +20,7 @@ import {
|
|||||||
SidebarMenu,
|
SidebarMenu,
|
||||||
SidebarMenuButton,
|
SidebarMenuButton,
|
||||||
SidebarMenuItem,
|
SidebarMenuItem,
|
||||||
} from "@/examples/base/ui/sidebar"
|
} from "@/styles/base-nova/ui/sidebar"
|
||||||
import { ChevronRightIcon } from "lucide-react"
|
|
||||||
import { type RegistryItem } from "shadcn/schema"
|
|
||||||
|
|
||||||
import { cn } from "@/lib/utils"
|
|
||||||
import { type Base } from "@/registry/bases"
|
|
||||||
import { useDesignSystemSearchParams } from "@/app/(create)/lib/search-params"
|
import { useDesignSystemSearchParams } from "@/app/(create)/lib/search-params"
|
||||||
import { groupItemsByType } from "@/app/(create)/lib/utils"
|
import { groupItemsByType } from "@/app/(create)/lib/utils"
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import { type Button } from "@/examples/base/ui/button"
|
|
||||||
import { Menu09Icon } from "@hugeicons/core-free-icons"
|
import { Menu09Icon } from "@hugeicons/core-free-icons"
|
||||||
import { HugeiconsIcon } from "@hugeicons/react"
|
import { HugeiconsIcon } from "@hugeicons/react"
|
||||||
|
|
||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
|
import { type Button } from "@/styles/base-nova/ui/button"
|
||||||
import {
|
import {
|
||||||
Picker,
|
Picker,
|
||||||
PickerContent,
|
PickerContent,
|
||||||
@@ -73,7 +73,7 @@ export function MainMenu({ className }: React.ComponentProps<typeof Button>) {
|
|||||||
</PickerItem>
|
</PickerItem>
|
||||||
<PickerSeparator />
|
<PickerSeparator />
|
||||||
<PickerItem onClick={() => setShowResetDialog(true)}>
|
<PickerItem onClick={() => setShowResetDialog(true)}>
|
||||||
Reset
|
Reset <PickerShortcut>⇧R</PickerShortcut>
|
||||||
</PickerItem>
|
</PickerItem>
|
||||||
</PickerGroup>
|
</PickerGroup>
|
||||||
</PickerContent>
|
</PickerContent>
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ export function MenuColorPicker({
|
|||||||
<PickerTrigger>
|
<PickerTrigger>
|
||||||
<div className="flex flex-col justify-start text-left">
|
<div className="flex flex-col justify-start text-left">
|
||||||
<div className="text-xs text-muted-foreground">Menu</div>
|
<div className="text-xs text-muted-foreground">Menu</div>
|
||||||
<div className="text-sm font-medium text-foreground">
|
<div className="line-clamp-1 max-w-[80%] truncate text-sm font-medium text-foreground">
|
||||||
{currentMenu?.label}
|
{currentMenu?.label}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import Script from "next/script"
|
import Script from "next/script"
|
||||||
import { Button } from "@/examples/base/ui/button"
|
|
||||||
|
|
||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
|
import { Button } from "@/styles/base-nova/ui/button"
|
||||||
import { useThemeToggle } from "@/app/(create)/hooks/use-theme-toggle"
|
import { useThemeToggle } from "@/app/(create)/hooks/use-theme-toggle"
|
||||||
|
|
||||||
export const DARK_MODE_FORWARD_TYPE = "dark-mode-forward"
|
export const DARK_MODE_FORWARD_TYPE = "dark-mode-forward"
|
||||||
|
|||||||
@@ -31,8 +31,10 @@ export function PresetPicker({
|
|||||||
preset.style === params.style &&
|
preset.style === params.style &&
|
||||||
preset.baseColor === params.baseColor &&
|
preset.baseColor === params.baseColor &&
|
||||||
preset.theme === params.theme &&
|
preset.theme === params.theme &&
|
||||||
|
preset.chartColor === params.chartColor &&
|
||||||
preset.iconLibrary === params.iconLibrary &&
|
preset.iconLibrary === params.iconLibrary &&
|
||||||
preset.font === params.font &&
|
preset.font === params.font &&
|
||||||
|
preset.fontHeading === params.fontHeading &&
|
||||||
preset.menuAccent === params.menuAccent &&
|
preset.menuAccent === params.menuAccent &&
|
||||||
preset.menuColor === params.menuColor &&
|
preset.menuColor === params.menuColor &&
|
||||||
preset.radius === params.radius
|
preset.radius === params.radius
|
||||||
@@ -43,8 +45,10 @@ export function PresetPicker({
|
|||||||
params.style,
|
params.style,
|
||||||
params.baseColor,
|
params.baseColor,
|
||||||
params.theme,
|
params.theme,
|
||||||
|
params.chartColor,
|
||||||
params.iconLibrary,
|
params.iconLibrary,
|
||||||
params.font,
|
params.font,
|
||||||
|
params.fontHeading,
|
||||||
params.menuAccent,
|
params.menuAccent,
|
||||||
params.menuColor,
|
params.menuColor,
|
||||||
params.radius,
|
params.radius,
|
||||||
@@ -67,8 +71,10 @@ export function PresetPicker({
|
|||||||
style: preset.style,
|
style: preset.style,
|
||||||
baseColor: preset.baseColor,
|
baseColor: preset.baseColor,
|
||||||
theme: preset.theme,
|
theme: preset.theme,
|
||||||
|
chartColor: preset.chartColor,
|
||||||
iconLibrary: preset.iconLibrary,
|
iconLibrary: preset.iconLibrary,
|
||||||
font: preset.font,
|
font: preset.font,
|
||||||
|
fontHeading: preset.fontHeading,
|
||||||
menuAccent: preset.menuAccent,
|
menuAccent: preset.menuAccent,
|
||||||
menuColor: preset.menuColor,
|
menuColor: preset.menuColor,
|
||||||
radius: preset.radius,
|
radius: preset.radius,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
import { DARK_MODE_FORWARD_TYPE } from "@/app/(create)/components/mode-switcher"
|
import { DARK_MODE_FORWARD_TYPE } from "@/app/(create)/components/mode-switcher"
|
||||||
import { RANDOMIZE_FORWARD_TYPE } from "@/app/(create)/components/random-button"
|
import { RANDOMIZE_FORWARD_TYPE } from "@/app/(create)/components/random-button"
|
||||||
import { sendToIframe } from "@/app/(create)/hooks/use-iframe-sync"
|
import { sendToIframe } from "@/app/(create)/hooks/use-iframe-sync"
|
||||||
|
import { RESET_FORWARD_TYPE } from "@/app/(create)/hooks/use-reset"
|
||||||
import {
|
import {
|
||||||
serializeDesignSystemSearchParams,
|
serializeDesignSystemSearchParams,
|
||||||
useDesignSystemSearchParams,
|
useDesignSystemSearchParams,
|
||||||
@@ -70,6 +71,15 @@ function handleMessage(event: MessageEvent) {
|
|||||||
cancelable: true,
|
cancelable: true,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
} else if (type === RESET_FORWARD_TYPE) {
|
||||||
|
document.dispatchEvent(
|
||||||
|
new KeyboardEvent("keydown", {
|
||||||
|
key: "R",
|
||||||
|
shiftKey: true,
|
||||||
|
bubbles: true,
|
||||||
|
cancelable: true,
|
||||||
|
})
|
||||||
|
)
|
||||||
} else if (type === DARK_MODE_FORWARD_TYPE) {
|
} else if (type === DARK_MODE_FORWARD_TYPE) {
|
||||||
document.dispatchEvent(
|
document.dispatchEvent(
|
||||||
new KeyboardEvent("keydown", {
|
new KeyboardEvent("keydown", {
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import { Button } from "@/examples/base/ui/button"
|
import { Copy01Icon, Globe02Icon, Tick02Icon } from "@hugeicons/core-free-icons"
|
||||||
|
import { HugeiconsIcon } from "@hugeicons/react"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
import { useConfig } from "@/hooks/use-config"
|
||||||
|
import { copyToClipboardWithMeta } from "@/components/copy-button"
|
||||||
|
import { BASES, type BaseName } from "@/registry/config"
|
||||||
|
import { Button } from "@/styles/base-nova/ui/button"
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
@@ -10,7 +17,7 @@ import {
|
|||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
DialogTrigger,
|
DialogTrigger,
|
||||||
} from "@/examples/base/ui/dialog"
|
} from "@/styles/base-nova/ui/dialog"
|
||||||
import {
|
import {
|
||||||
Field,
|
Field,
|
||||||
FieldContent,
|
FieldContent,
|
||||||
@@ -20,21 +27,15 @@ import {
|
|||||||
FieldSeparator,
|
FieldSeparator,
|
||||||
FieldSet,
|
FieldSet,
|
||||||
FieldTitle,
|
FieldTitle,
|
||||||
} from "@/examples/base/ui/field"
|
} from "@/styles/base-nova/ui/field"
|
||||||
import { RadioGroup, RadioGroupItem } from "@/examples/base/ui/radio-group"
|
import { RadioGroup, RadioGroupItem } from "@/styles/base-nova/ui/radio-group"
|
||||||
import { Switch } from "@/examples/base/ui/switch"
|
import { Switch } from "@/styles/base-nova/ui/switch"
|
||||||
import {
|
import {
|
||||||
Tabs,
|
Tabs,
|
||||||
TabsContent,
|
TabsContent,
|
||||||
TabsList,
|
TabsList,
|
||||||
TabsTrigger,
|
TabsTrigger,
|
||||||
} from "@/examples/base/ui/tabs"
|
} from "@/styles/base-nova/ui/tabs"
|
||||||
import { Copy01Icon, Globe02Icon, Tick02Icon } from "@hugeicons/core-free-icons"
|
|
||||||
import { HugeiconsIcon } from "@hugeicons/react"
|
|
||||||
|
|
||||||
import { cn } from "@/lib/utils"
|
|
||||||
import { useConfig } from "@/hooks/use-config"
|
|
||||||
import { copyToClipboardWithMeta } from "@/components/copy-button"
|
|
||||||
import { usePresetCode } from "@/app/(create)/hooks/use-design-system"
|
import { usePresetCode } from "@/app/(create)/hooks/use-design-system"
|
||||||
import {
|
import {
|
||||||
useDesignSystemSearchParams,
|
useDesignSystemSearchParams,
|
||||||
@@ -86,7 +87,7 @@ export function ProjectForm({
|
|||||||
const rtlFlag = params.rtl ? " --rtl" : ""
|
const rtlFlag = params.rtl ? " --rtl" : ""
|
||||||
const flags = `${presetFlag}${baseFlag}${templateFlag}${monorepoFlag}${rtlFlag}`
|
const flags = `${presetFlag}${baseFlag}${templateFlag}${monorepoFlag}${rtlFlag}`
|
||||||
|
|
||||||
return IS_LOCAL_DEV && !process.env.NEXT_PUBLIC_RC
|
return IS_LOCAL_DEV
|
||||||
? {
|
? {
|
||||||
pnpm: `shadcn init${flags}`,
|
pnpm: `shadcn init${flags}`,
|
||||||
npm: `shadcn init${flags}`,
|
npm: `shadcn init${flags}`,
|
||||||
@@ -129,69 +130,76 @@ export function ProjectForm({
|
|||||||
<DialogTrigger render={<Button className={cn(className)} />}>
|
<DialogTrigger render={<Button className={cn(className)} />}>
|
||||||
Create Project
|
Create Project
|
||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
<DialogContent className="min-w-0 sm:max-w-sm">
|
<DialogContent className="dark no-scrollbar max-h-[calc(100svh-2rem)] overflow-y-auto rounded-2xl p-6 shadow-xl **:data-[slot=field-separator]:h-2 sm:max-w-sm">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>Create Project</DialogTitle>
|
<DialogTitle>Create Project</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>
|
||||||
Pick a template and configure your project. Available for all major
|
Pick a template and configure your project.
|
||||||
React frameworks.
|
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<FieldGroup>
|
<div>
|
||||||
<Field>
|
<FieldGroup>
|
||||||
<FieldLabel className="sr-only">Template</FieldLabel>
|
<FieldSeparator className="-mx-6" />
|
||||||
<TemplateGrid template={params.template} setParams={setParams} />
|
<Field className="-mt-2 gap-3">
|
||||||
</Field>
|
<FieldLabel>Template</FieldLabel>
|
||||||
<FieldSeparator />
|
<TemplateGrid template={params.template} setParams={setParams} />
|
||||||
<FieldSet>
|
</Field>
|
||||||
<FieldLegend variant="label" className="sr-only">
|
<FieldSeparator className="-mx-6" />
|
||||||
Options
|
<Field className="-mt-2">
|
||||||
</FieldLegend>
|
<FieldLabel>Base</FieldLabel>
|
||||||
<Field
|
<BaseGrid base={params.base} setParams={setParams} />
|
||||||
orientation="horizontal"
|
</Field>
|
||||||
data-disabled={hasMonorepo ? undefined : "true"}
|
<FieldSeparator className="-mx-6" />
|
||||||
>
|
<FieldSet>
|
||||||
<FieldLabel htmlFor="monorepo">
|
<FieldLegend variant="label" className="sr-only">
|
||||||
<span
|
Options
|
||||||
className="size-4 text-foreground [&_svg]:size-4 [&_svg]:fill-current"
|
</FieldLegend>
|
||||||
dangerouslySetInnerHTML={{
|
<Field
|
||||||
__html: TURBOREPO_LOGO,
|
orientation="horizontal"
|
||||||
|
data-disabled={hasMonorepo ? undefined : "true"}
|
||||||
|
>
|
||||||
|
<FieldLabel htmlFor="monorepo">
|
||||||
|
<span
|
||||||
|
className="size-4 text-neutral-100 [&_svg]:size-4 [&_svg]:fill-current"
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html: TURBOREPO_LOGO,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
Create a monorepo
|
||||||
|
</FieldLabel>
|
||||||
|
<Switch
|
||||||
|
id="monorepo"
|
||||||
|
checked={params.template?.endsWith("-monorepo") ?? false}
|
||||||
|
disabled={!hasMonorepo}
|
||||||
|
onCheckedChange={(checked) => {
|
||||||
|
const framework = getFramework(params.template ?? "next")
|
||||||
|
setParams({
|
||||||
|
template: getTemplateValue(
|
||||||
|
framework,
|
||||||
|
checked === true
|
||||||
|
) as typeof params.template,
|
||||||
|
})
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
Create a monorepo
|
</Field>
|
||||||
</FieldLabel>
|
<FieldSeparator className="-mx-6" />
|
||||||
<Switch
|
<Field orientation="horizontal">
|
||||||
id="monorepo"
|
<FieldLabel htmlFor="rtl">
|
||||||
checked={params.template?.endsWith("-monorepo") ?? false}
|
<HugeiconsIcon icon={Globe02Icon} className="size-4" />
|
||||||
disabled={!hasMonorepo}
|
Enable RTL support
|
||||||
onCheckedChange={(checked) => {
|
</FieldLabel>
|
||||||
const framework = getFramework(params.template ?? "next")
|
<Switch
|
||||||
setParams({
|
id="rtl"
|
||||||
template: getTemplateValue(
|
checked={params.rtl}
|
||||||
framework,
|
onCheckedChange={(checked) =>
|
||||||
checked === true
|
setParams({ rtl: checked === true })
|
||||||
) as typeof params.template,
|
}
|
||||||
})
|
/>
|
||||||
}}
|
</Field>
|
||||||
/>
|
</FieldSet>
|
||||||
</Field>
|
</FieldGroup>
|
||||||
<FieldSeparator />
|
</div>
|
||||||
<Field orientation="horizontal">
|
<DialogFooter className="-mx-6 -mb-6 min-w-0">
|
||||||
<FieldLabel htmlFor="rtl">
|
|
||||||
<HugeiconsIcon icon={Globe02Icon} className="size-4" />
|
|
||||||
Enable RTL support
|
|
||||||
</FieldLabel>
|
|
||||||
<Switch
|
|
||||||
id="rtl"
|
|
||||||
checked={params.rtl}
|
|
||||||
onCheckedChange={(checked) =>
|
|
||||||
setParams({ rtl: checked === true })
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</Field>
|
|
||||||
</FieldSet>
|
|
||||||
</FieldGroup>
|
|
||||||
<DialogFooter className="min-w-0">
|
|
||||||
<div className="flex w-full min-w-0 flex-col gap-3">
|
<div className="flex w-full min-w-0 flex-col gap-3">
|
||||||
<Tabs
|
<Tabs
|
||||||
value={packageManager}
|
value={packageManager}
|
||||||
@@ -201,16 +209,16 @@ export function ProjectForm({
|
|||||||
packageManager: value as PackageManager,
|
packageManager: value as PackageManager,
|
||||||
}))
|
}))
|
||||||
}}
|
}}
|
||||||
className="min-w-0 gap-0 overflow-hidden rounded-lg border bg-surface"
|
className="min-w-0 gap-0 overflow-hidden rounded-xl border-0 ring-1 ring-border"
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-2 px-1 py-1">
|
<div className="flex items-center gap-2 py-1 pr-1.5 pl-1">
|
||||||
<TabsList className="font-mono">
|
<TabsList className="bg-transparent font-mono">
|
||||||
{PACKAGE_MANAGERS.map((manager) => {
|
{PACKAGE_MANAGERS.map((manager) => {
|
||||||
return (
|
return (
|
||||||
<TabsTrigger
|
<TabsTrigger
|
||||||
key={manager}
|
key={manager}
|
||||||
value={manager}
|
value={manager}
|
||||||
className="data-[state=active]:shadow-none"
|
className="py-0 leading-none data-[state=active]:shadow-none"
|
||||||
>
|
>
|
||||||
{manager}
|
{manager}
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
@@ -234,7 +242,7 @@ export function ProjectForm({
|
|||||||
{Object.entries(commands).map(([key, cmd]) => {
|
{Object.entries(commands).map(([key, cmd]) => {
|
||||||
return (
|
return (
|
||||||
<TabsContent key={key} value={key}>
|
<TabsContent key={key} value={key}>
|
||||||
<div className="relative overflow-hidden border-t border-border/50 bg-surface px-3 py-3 text-surface-foreground">
|
<div className="relative overflow-hidden border-t bg-popover p-3">
|
||||||
<div className="no-scrollbar overflow-x-auto">
|
<div className="no-scrollbar overflow-x-auto">
|
||||||
<code className="font-mono text-sm whitespace-nowrap">
|
<code className="font-mono text-sm whitespace-nowrap">
|
||||||
{cmd}
|
{cmd}
|
||||||
@@ -281,23 +289,26 @@ const TemplateGrid = React.memo(function TemplateGrid({
|
|||||||
<RadioGroup
|
<RadioGroup
|
||||||
value={framework}
|
value={framework}
|
||||||
onValueChange={handleTemplateChange}
|
onValueChange={handleTemplateChange}
|
||||||
className="grid grid-cols-3 gap-2"
|
className="grid grid-cols-2 gap-2"
|
||||||
>
|
>
|
||||||
{TEMPLATES.map((item) => (
|
{TEMPLATES.map((item) => (
|
||||||
<FieldLabel
|
<FieldLabel
|
||||||
key={item.value}
|
key={item.value}
|
||||||
htmlFor={`template-${item.value}`}
|
htmlFor={`template-${item.value}`}
|
||||||
className="py-1"
|
className="block w-full"
|
||||||
>
|
>
|
||||||
<Field className="gap-0" orientation="horizontal">
|
<Field
|
||||||
<FieldContent className="flex flex-col items-center justify-center gap-2">
|
orientation="horizontal"
|
||||||
|
className="w-full rounded-md transition-colors duration-150 hover:bg-neutral-700/45"
|
||||||
|
>
|
||||||
|
<FieldContent className="flex flex-row items-center gap-2 px-2.5 py-1.5">
|
||||||
<div
|
<div
|
||||||
className="size-6 text-foreground [&_svg]:size-6 *:[svg]:text-foreground!"
|
className="size-4 text-neutral-100 [&_svg]:size-4 *:[svg]:text-neutral-100!"
|
||||||
dangerouslySetInnerHTML={{
|
dangerouslySetInnerHTML={{
|
||||||
__html: item.logo,
|
__html: item.logo,
|
||||||
}}
|
}}
|
||||||
></div>
|
></div>
|
||||||
<FieldTitle className="text-xs">{item.title}</FieldTitle>
|
<FieldTitle>{item.title}</FieldTitle>
|
||||||
</FieldContent>
|
</FieldContent>
|
||||||
<RadioGroupItem
|
<RadioGroupItem
|
||||||
value={item.value}
|
value={item.value}
|
||||||
@@ -310,3 +321,55 @@ const TemplateGrid = React.memo(function TemplateGrid({
|
|||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const BaseGrid = React.memo(function BaseGrid({
|
||||||
|
base,
|
||||||
|
setParams,
|
||||||
|
}: {
|
||||||
|
base: DesignSystemSearchParams["base"]
|
||||||
|
setParams: ReturnType<typeof useDesignSystemSearchParams>[1]
|
||||||
|
}) {
|
||||||
|
const handleBaseChange = React.useCallback(
|
||||||
|
(value: string) => {
|
||||||
|
setParams({ base: value as BaseName })
|
||||||
|
},
|
||||||
|
[setParams]
|
||||||
|
)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<RadioGroup
|
||||||
|
value={base}
|
||||||
|
onValueChange={handleBaseChange}
|
||||||
|
aria-label="Base"
|
||||||
|
className="grid grid-cols-2 gap-2"
|
||||||
|
>
|
||||||
|
{BASES.map((item) => (
|
||||||
|
<FieldLabel
|
||||||
|
key={item.name}
|
||||||
|
htmlFor={`base-${item.name}`}
|
||||||
|
className="block w-full"
|
||||||
|
>
|
||||||
|
<Field
|
||||||
|
orientation="horizontal"
|
||||||
|
className="w-full rounded-md transition-colors duration-150 hover:bg-neutral-700/45"
|
||||||
|
>
|
||||||
|
<FieldContent className="flex flex-row items-center gap-2 px-2.5 py-1.5">
|
||||||
|
<div
|
||||||
|
className="size-4 text-neutral-100 [&_svg]:size-4 *:[svg]:text-neutral-100!"
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html: item.meta?.logo ?? "",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<FieldTitle>{item.title}</FieldTitle>
|
||||||
|
</FieldContent>
|
||||||
|
<RadioGroupItem
|
||||||
|
value={item.name}
|
||||||
|
id={`base-${item.name}`}
|
||||||
|
className="sr-only absolute"
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
</FieldLabel>
|
||||||
|
))}
|
||||||
|
</RadioGroup>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import Script from "next/script"
|
import Script from "next/script"
|
||||||
import { Button } from "@/examples/base/ui/button"
|
|
||||||
import { DiceFaces05Icon } from "@hugeicons/core-free-icons"
|
import { DiceFaces05Icon } from "@hugeicons/core-free-icons"
|
||||||
import { HugeiconsIcon } from "@hugeicons/react"
|
import { HugeiconsIcon } from "@hugeicons/react"
|
||||||
|
|
||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
|
import { Button } from "@/styles/base-nova/ui/button"
|
||||||
import { useRandom } from "@/app/(create)/hooks/use-random"
|
import { useRandom } from "@/app/(create)/hooks/use-random"
|
||||||
|
import { RESET_FORWARD_TYPE } from "@/app/(create)/hooks/use-reset"
|
||||||
|
|
||||||
export const RANDOMIZE_FORWARD_TYPE = "randomize-forward"
|
export const RANDOMIZE_FORWARD_TYPE = "randomize-forward"
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ export function RandomizeScript() {
|
|||||||
dangerouslySetInnerHTML={{
|
dangerouslySetInnerHTML={{
|
||||||
__html: `
|
__html: `
|
||||||
(function() {
|
(function() {
|
||||||
// Forward R key
|
// Forward r key (shuffle) and Shift+R (reset).
|
||||||
document.addEventListener('keydown', function(e) {
|
document.addEventListener('keydown', function(e) {
|
||||||
if ((e.key === 'r' || e.key === 'R') && !e.metaKey && !e.ctrlKey) {
|
if ((e.key === 'r' || e.key === 'R') && !e.metaKey && !e.ctrlKey) {
|
||||||
if (
|
if (
|
||||||
@@ -53,8 +54,11 @@ export function RandomizeScript() {
|
|||||||
}
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (window.parent && window.parent !== window) {
|
if (window.parent && window.parent !== window) {
|
||||||
|
var type = e.shiftKey
|
||||||
|
? '${RESET_FORWARD_TYPE}'
|
||||||
|
: '${RANDOMIZE_FORWARD_TYPE}';
|
||||||
window.parent.postMessage({
|
window.parent.postMessage({
|
||||||
type: '${RANDOMIZE_FORWARD_TYPE}',
|
type: type,
|
||||||
key: e.key
|
key: e.key
|
||||||
}, '*');
|
}, '*');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ import {
|
|||||||
AlertDialogFooter,
|
AlertDialogFooter,
|
||||||
AlertDialogHeader,
|
AlertDialogHeader,
|
||||||
AlertDialogTitle,
|
AlertDialogTitle,
|
||||||
} from "@/examples/base/ui/alert-dialog"
|
} from "@/styles/base-nova/ui/alert-dialog"
|
||||||
|
|
||||||
import { useReset } from "@/app/(create)/hooks/use-reset"
|
import { useReset } from "@/app/(create)/hooks/use-reset"
|
||||||
|
|
||||||
export function ResetDialog() {
|
export function ResetDialog() {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import { Button } from "@/examples/base/ui/button"
|
|
||||||
import { Share03Icon, Tick02Icon } from "@hugeicons/core-free-icons"
|
import { Share03Icon, Tick02Icon } from "@hugeicons/core-free-icons"
|
||||||
import { HugeiconsIcon } from "@hugeicons/react"
|
import { HugeiconsIcon } from "@hugeicons/react"
|
||||||
|
|
||||||
import { copyToClipboardWithMeta } from "@/components/copy-button"
|
import { copyToClipboardWithMeta } from "@/components/copy-button"
|
||||||
|
import { Button } from "@/styles/base-nova/ui/button"
|
||||||
import { usePresetCode } from "@/app/(create)/hooks/use-design-system"
|
import { usePresetCode } from "@/app/(create)/hooks/use-design-system"
|
||||||
import { useDesignSystemSearchParams } from "@/app/(create)/lib/search-params"
|
import { useDesignSystemSearchParams } from "@/app/(create)/lib/search-params"
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import { Button } from "@/examples/base/ui/button"
|
|
||||||
import { Skeleton } from "@/examples/base/ui/skeleton"
|
|
||||||
|
|
||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
import { useIsMobile } from "@/hooks/use-mobile"
|
import { useIsMobile } from "@/hooks/use-mobile"
|
||||||
import { useMounted } from "@/hooks/use-mounted"
|
import { useMounted } from "@/hooks/use-mounted"
|
||||||
import { Icons } from "@/components/icons"
|
import { Icons } from "@/components/icons"
|
||||||
|
import { Button } from "@/styles/base-nova/ui/button"
|
||||||
|
import { Skeleton } from "@/styles/base-nova/ui/skeleton"
|
||||||
import { useDesignSystemSearchParams } from "@/app/(create)/lib/search-params"
|
import { useDesignSystemSearchParams } from "@/app/(create)/lib/search-params"
|
||||||
|
|
||||||
export function V0Button({ className }: { className?: string }) {
|
export function V0Button({ className }: { className?: string }) {
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import { Button } from "@/examples/base/ui/button"
|
|
||||||
|
import { Icons } from "@/components/icons"
|
||||||
|
import { Button } from "@/styles/base-nova/ui/button"
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogClose,
|
DialogClose,
|
||||||
@@ -10,9 +12,7 @@ import {
|
|||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/examples/base/ui/dialog"
|
} from "@/styles/base-nova/ui/dialog"
|
||||||
|
|
||||||
import { Icons } from "@/components/icons"
|
|
||||||
|
|
||||||
const STORAGE_KEY = "shadcn-create-welcome-dialog"
|
const STORAGE_KEY = "shadcn-create-welcome-dialog"
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export default async function CreatePage() {
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
data-slot="layout"
|
data-slot="layout"
|
||||||
className="group/layout relative z-10 flex h-svh flex-col overflow-hidden section-soft [--customizer-width:--spacing(56)] [--gap:--spacing(4)] md:[--gap:--spacing(6)]"
|
className="group/layout relative z-10 flex h-svh flex-col overflow-hidden section-soft [--customizer-width:--spacing(48)] [--gap:--spacing(4)] md:[--gap:--spacing(6)] 2xl:[--customizer-width:--spacing(56)]"
|
||||||
>
|
>
|
||||||
<SiteHeader />
|
<SiteHeader />
|
||||||
<main
|
<main
|
||||||
|
|||||||
@@ -1,40 +1,11 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import * as React from "react"
|
import { getPresetCode } from "@/app/(create)/lib/preset-code"
|
||||||
import { encodePreset, isPresetCode } from "shadcn/preset"
|
|
||||||
|
|
||||||
import { useDesignSystemSearchParams } from "@/app/(create)/lib/search-params"
|
import { useDesignSystemSearchParams } from "@/app/(create)/lib/search-params"
|
||||||
|
|
||||||
// Returns the current preset code derived from search params.
|
// Returns the canonical preset code derived from the current search params.
|
||||||
export function usePresetCode() {
|
export function usePresetCode() {
|
||||||
const [params] = useDesignSystemSearchParams()
|
const [params] = useDesignSystemSearchParams()
|
||||||
|
|
||||||
return React.useMemo(() => {
|
return getPresetCode(params)
|
||||||
// If preset is already in the URL, return it.
|
|
||||||
if (params.preset && isPresetCode(params.preset)) {
|
|
||||||
return params.preset
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise encode current params (e.g. on initial load before first interaction).
|
|
||||||
return encodePreset({
|
|
||||||
style: params.style ?? undefined,
|
|
||||||
baseColor: params.baseColor ?? undefined,
|
|
||||||
theme: params.theme ?? undefined,
|
|
||||||
iconLibrary: params.iconLibrary ?? undefined,
|
|
||||||
font: params.font ?? undefined,
|
|
||||||
radius: params.radius ?? undefined,
|
|
||||||
menuAccent: params.menuAccent ?? undefined,
|
|
||||||
menuColor: params.menuColor ?? undefined,
|
|
||||||
} as Parameters<typeof encodePreset>[0])
|
|
||||||
}, [
|
|
||||||
params.preset,
|
|
||||||
params.style,
|
|
||||||
params.baseColor,
|
|
||||||
params.theme,
|
|
||||||
params.iconLibrary,
|
|
||||||
params.font,
|
|
||||||
params.radius,
|
|
||||||
params.menuAccent,
|
|
||||||
params.menuColor,
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ export type LockableParam =
|
|||||||
| "style"
|
| "style"
|
||||||
| "baseColor"
|
| "baseColor"
|
||||||
| "theme"
|
| "theme"
|
||||||
|
| "chartColor"
|
||||||
| "iconLibrary"
|
| "iconLibrary"
|
||||||
| "font"
|
| "font"
|
||||||
|
| "fontHeading"
|
||||||
| "menuAccent"
|
| "menuAccent"
|
||||||
| "menuColor"
|
| "menuColor"
|
||||||
| "radius"
|
| "radius"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
MENU_COLORS,
|
MENU_COLORS,
|
||||||
RADII,
|
RADII,
|
||||||
STYLES,
|
STYLES,
|
||||||
|
type FontHeadingValue,
|
||||||
} from "@/registry/config"
|
} from "@/registry/config"
|
||||||
import { useLocks } from "@/app/(create)/hooks/use-locks"
|
import { useLocks } from "@/app/(create)/hooks/use-locks"
|
||||||
import { FONTS } from "@/app/(create)/lib/fonts"
|
import { FONTS } from "@/app/(create)/lib/fonts"
|
||||||
@@ -62,9 +63,41 @@ export function useRandom() {
|
|||||||
const selectedTheme = locks.has("theme")
|
const selectedTheme = locks.has("theme")
|
||||||
? paramsRef.current.theme
|
? paramsRef.current.theme
|
||||||
: randomItem(availableThemes).name
|
: randomItem(availableThemes).name
|
||||||
|
context.theme = selectedTheme
|
||||||
|
|
||||||
|
const availableChartColors = applyBias(
|
||||||
|
getThemesForBaseColor(baseColor),
|
||||||
|
context,
|
||||||
|
RANDOMIZE_BIASES.chartColors
|
||||||
|
)
|
||||||
|
const selectedChartColor = locks.has("chartColor")
|
||||||
|
? paramsRef.current.chartColor
|
||||||
|
: randomItem(availableChartColors).name
|
||||||
|
context.chartColor = selectedChartColor
|
||||||
const selectedFont = locks.has("font")
|
const selectedFont = locks.has("font")
|
||||||
? paramsRef.current.font
|
? paramsRef.current.font
|
||||||
: randomItem(availableFonts).value
|
: randomItem(availableFonts).value
|
||||||
|
context.font = selectedFont
|
||||||
|
|
||||||
|
// Pick heading font: ~70% inherit, ~30% distinct with cross-category contrast.
|
||||||
|
let selectedFontHeading: FontHeadingValue
|
||||||
|
if (locks.has("fontHeading")) {
|
||||||
|
selectedFontHeading = paramsRef.current.fontHeading
|
||||||
|
} else if (Math.random() < 0.7) {
|
||||||
|
selectedFontHeading = "inherit"
|
||||||
|
} else {
|
||||||
|
const bodyType = availableFonts.find(
|
||||||
|
(f) => f.value === selectedFont
|
||||||
|
)?.type
|
||||||
|
const contrastFonts = availableFonts.filter(
|
||||||
|
(f) => f.type !== bodyType && f.value !== selectedFont
|
||||||
|
)
|
||||||
|
selectedFontHeading = (
|
||||||
|
contrastFonts.length > 0
|
||||||
|
? randomItem(contrastFonts)
|
||||||
|
: randomItem(availableFonts)
|
||||||
|
).value as FontHeadingValue
|
||||||
|
}
|
||||||
const selectedRadius = locks.has("radius")
|
const selectedRadius = locks.has("radius")
|
||||||
? paramsRef.current.radius
|
? paramsRef.current.radius
|
||||||
: randomItem(availableRadii).name
|
: randomItem(availableRadii).name
|
||||||
@@ -91,16 +124,16 @@ export function useRandom() {
|
|||||||
: paramsRef.current.menuAccent
|
: paramsRef.current.menuAccent
|
||||||
: randomItem(MENU_ACCENTS).value
|
: randomItem(MENU_ACCENTS).value
|
||||||
|
|
||||||
context.theme = selectedTheme
|
|
||||||
context.font = selectedFont
|
|
||||||
context.radius = selectedRadius
|
context.radius = selectedRadius
|
||||||
|
|
||||||
const nextParams = {
|
const nextParams = {
|
||||||
style: selectedStyle,
|
style: selectedStyle,
|
||||||
baseColor,
|
baseColor,
|
||||||
theme: selectedTheme,
|
theme: selectedTheme,
|
||||||
|
chartColor: selectedChartColor,
|
||||||
iconLibrary: selectedIconLibrary,
|
iconLibrary: selectedIconLibrary,
|
||||||
font: selectedFont,
|
font: selectedFont,
|
||||||
|
fontHeading: selectedFontHeading,
|
||||||
menuAccent: selectedMenuAccent,
|
menuAccent: selectedMenuAccent,
|
||||||
menuColor: selectedMenuColor,
|
menuColor: selectedMenuColor,
|
||||||
radius: selectedRadius,
|
radius: selectedRadius,
|
||||||
@@ -123,7 +156,7 @@ export function useRandom() {
|
|||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const down = (e: KeyboardEvent) => {
|
const down = (e: KeyboardEvent) => {
|
||||||
if ((e.key === "r" || e.key === "R") && !e.metaKey && !e.ctrlKey) {
|
if (e.key === "r" && !e.shiftKey && !e.metaKey && !e.ctrlKey) {
|
||||||
if (
|
if (
|
||||||
(e.target instanceof HTMLElement && e.target.isContentEditable) ||
|
(e.target instanceof HTMLElement && e.target.isContentEditable) ||
|
||||||
e.target instanceof HTMLInputElement ||
|
e.target instanceof HTMLInputElement ||
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { DEFAULT_CONFIG } from "@/registry/config"
|
|||||||
import { useDesignSystemSearchParams } from "@/app/(create)/lib/search-params"
|
import { useDesignSystemSearchParams } from "@/app/(create)/lib/search-params"
|
||||||
|
|
||||||
const RESET_DIALOG_KEY = "create:reset-dialog-open"
|
const RESET_DIALOG_KEY = "create:reset-dialog-open"
|
||||||
|
export const RESET_FORWARD_TYPE = "reset-forward"
|
||||||
|
|
||||||
export function useReset() {
|
export function useReset() {
|
||||||
const [params, setParams] = useDesignSystemSearchParams()
|
const [params, setParams] = useDesignSystemSearchParams()
|
||||||
@@ -24,15 +25,17 @@ export function useReset() {
|
|||||||
style: DEFAULT_CONFIG.style,
|
style: DEFAULT_CONFIG.style,
|
||||||
baseColor: DEFAULT_CONFIG.baseColor,
|
baseColor: DEFAULT_CONFIG.baseColor,
|
||||||
theme: DEFAULT_CONFIG.theme,
|
theme: DEFAULT_CONFIG.theme,
|
||||||
|
chartColor: DEFAULT_CONFIG.chartColor,
|
||||||
iconLibrary: DEFAULT_CONFIG.iconLibrary,
|
iconLibrary: DEFAULT_CONFIG.iconLibrary,
|
||||||
font: DEFAULT_CONFIG.font,
|
font: DEFAULT_CONFIG.font,
|
||||||
|
fontHeading: DEFAULT_CONFIG.fontHeading,
|
||||||
menuAccent: DEFAULT_CONFIG.menuAccent,
|
menuAccent: DEFAULT_CONFIG.menuAccent,
|
||||||
menuColor: DEFAULT_CONFIG.menuColor,
|
menuColor: DEFAULT_CONFIG.menuColor,
|
||||||
radius: DEFAULT_CONFIG.radius,
|
radius: DEFAULT_CONFIG.radius,
|
||||||
template: DEFAULT_CONFIG.template,
|
template: DEFAULT_CONFIG.template,
|
||||||
item: "preview",
|
item: params.item,
|
||||||
})
|
})
|
||||||
}, [setParams, params.base])
|
}, [setParams, params.base, params.item])
|
||||||
|
|
||||||
const handleShowResetDialogChange = React.useCallback(
|
const handleShowResetDialogChange = React.useCallback(
|
||||||
(open: boolean) => {
|
(open: boolean) => {
|
||||||
@@ -46,6 +49,46 @@ export function useReset() {
|
|||||||
void setShowResetDialogData(false, { revalidate: false })
|
void setShowResetDialogData(false, { revalidate: false })
|
||||||
}, [reset, setShowResetDialogData])
|
}, [reset, setShowResetDialogData])
|
||||||
|
|
||||||
|
const showResetDialogRef = React.useRef(showResetDialog)
|
||||||
|
React.useEffect(() => {
|
||||||
|
showResetDialogRef.current = showResetDialog
|
||||||
|
}, [showResetDialog])
|
||||||
|
|
||||||
|
const confirmResetRef = React.useRef(confirmReset)
|
||||||
|
React.useEffect(() => {
|
||||||
|
confirmResetRef.current = confirmReset
|
||||||
|
}, [confirmReset])
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
const down = (e: KeyboardEvent) => {
|
||||||
|
if (e.key === "R" && e.shiftKey && !e.metaKey && !e.ctrlKey) {
|
||||||
|
if (
|
||||||
|
(e.target instanceof HTMLElement && e.target.isContentEditable) ||
|
||||||
|
e.target instanceof HTMLInputElement ||
|
||||||
|
e.target instanceof HTMLTextAreaElement ||
|
||||||
|
e.target instanceof HTMLSelectElement
|
||||||
|
) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
e.preventDefault()
|
||||||
|
|
||||||
|
// If the dialog is already open, confirm the reset.
|
||||||
|
if (showResetDialogRef.current) {
|
||||||
|
confirmResetRef.current()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
handleShowResetDialogChange(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("keydown", down)
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener("keydown", down)
|
||||||
|
}
|
||||||
|
}, [handleShowResetDialogChange])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
reset,
|
reset,
|
||||||
showResetDialog,
|
showResetDialog,
|
||||||
|
|||||||
@@ -3,13 +3,17 @@ import dedent from "dedent"
|
|||||||
import { UI_COMPONENTS } from "@/lib/components"
|
import { UI_COMPONENTS } from "@/lib/components"
|
||||||
import {
|
import {
|
||||||
buildRegistryBase,
|
buildRegistryBase,
|
||||||
fonts,
|
getBodyFont,
|
||||||
|
getHeadingFont,
|
||||||
|
getInheritedHeadingFontValue,
|
||||||
type DesignSystemConfig,
|
type DesignSystemConfig,
|
||||||
} from "@/registry/config"
|
} from "@/registry/config"
|
||||||
|
|
||||||
// Builds step-by-step markdown instructions for manually setting up a project.
|
// Builds step-by-step markdown instructions for manually setting up a project.
|
||||||
export function buildInstructions(config: DesignSystemConfig) {
|
export function buildInstructions(config: DesignSystemConfig) {
|
||||||
const registryBase = buildRegistryBase(config)
|
const registryBase = buildRegistryBase(config)
|
||||||
|
const normalizedFontHeading =
|
||||||
|
config.fontHeading === config.font ? "inherit" : config.fontHeading
|
||||||
|
|
||||||
const dependencies = [
|
const dependencies = [
|
||||||
...(registryBase.dependencies ?? []),
|
...(registryBase.dependencies ?? []),
|
||||||
@@ -25,13 +29,23 @@ export function buildInstructions(config: DesignSystemConfig) {
|
|||||||
.map(([key, value]) => ` --${key}: ${value};`)
|
.map(([key, value]) => ` --${key}: ${value};`)
|
||||||
.join("\n")
|
.join("\n")
|
||||||
|
|
||||||
const font = fonts.find((f) => f.name === `font-${config.font}`)
|
const font = getBodyFont(config.font)
|
||||||
|
const headingFont =
|
||||||
|
normalizedFontHeading === "inherit"
|
||||||
|
? undefined
|
||||||
|
: getHeadingFont(normalizedFontHeading)
|
||||||
|
|
||||||
const sections = [
|
const sections = [
|
||||||
buildDependenciesSection(dependencies),
|
buildDependenciesSection(dependencies),
|
||||||
buildUtilsSection(),
|
buildUtilsSection(),
|
||||||
buildCssSection(lightVars, darkVars),
|
buildCssSection(
|
||||||
buildFontSection(font),
|
lightVars,
|
||||||
|
darkVars,
|
||||||
|
normalizedFontHeading === "inherit"
|
||||||
|
? getInheritedHeadingFontValue(config.font)
|
||||||
|
: "var(--font-heading)"
|
||||||
|
),
|
||||||
|
buildFontSection(font, headingFont),
|
||||||
buildComponentsJsonSection(config),
|
buildComponentsJsonSection(config),
|
||||||
buildAvailableComponentsSection(config),
|
buildAvailableComponentsSection(config),
|
||||||
config.rtl ? buildRtlSection(config) : null,
|
config.rtl ? buildRtlSection(config) : null,
|
||||||
@@ -67,7 +81,11 @@ function buildUtilsSection() {
|
|||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildCssSection(lightVars: string, darkVars: string) {
|
function buildCssSection(
|
||||||
|
lightVars: string,
|
||||||
|
darkVars: string,
|
||||||
|
fontHeadingValue: string
|
||||||
|
) {
|
||||||
return dedent`
|
return dedent`
|
||||||
## Step 3: Set up CSS
|
## Step 3: Set up CSS
|
||||||
|
|
||||||
@@ -80,6 +98,7 @@ function buildCssSection(lightVars: string, darkVars: string) {
|
|||||||
|
|
||||||
@theme inline {
|
@theme inline {
|
||||||
--font-sans: var(--font-sans);
|
--font-sans: var(--font-sans);
|
||||||
|
--font-heading: ${fontHeadingValue};
|
||||||
--font-mono: var(--font-mono);
|
--font-mono: var(--font-mono);
|
||||||
--color-background: var(--background);
|
--color-background: var(--background);
|
||||||
--color-foreground: var(--foreground);
|
--color-foreground: var(--foreground);
|
||||||
@@ -142,40 +161,74 @@ function buildCssSection(lightVars: string, darkVars: string) {
|
|||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildFontSection(font: (typeof fonts)[number] | undefined) {
|
function buildFontSection(
|
||||||
|
font: ReturnType<typeof getBodyFont>,
|
||||||
|
headingFont: ReturnType<typeof getHeadingFont>
|
||||||
|
) {
|
||||||
if (!font) {
|
if (!font) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const googleFontsUrl = `https://fonts.google.com/specimen/${font.font.import.replace(/_/g, "+")}`
|
const googleFontsUrl = `https://fonts.google.com/specimen/${font.font.import.replace(/_/g, "+")}`
|
||||||
|
const headingGoogleFontsUrl = headingFont
|
||||||
|
? `https://fonts.google.com/specimen/${headingFont.font.import.replace(/_/g, "+")}`
|
||||||
|
: null
|
||||||
|
const nextImports = headingFont
|
||||||
|
? `${font.font.import}, ${headingFont.font.import}`
|
||||||
|
: font.font.import
|
||||||
|
const nextDeclarations = [
|
||||||
|
`const fontSans = ${font.font.import}({`,
|
||||||
|
` subsets: ["latin"],`,
|
||||||
|
` variable: "${font.font.variable}",`,
|
||||||
|
`})`,
|
||||||
|
headingFont ? `const fontHeading = ${headingFont.font.import}({` : null,
|
||||||
|
headingFont ? ` subsets: ["latin"],` : null,
|
||||||
|
headingFont ? ` variable: "${headingFont.font.variable}",` : null,
|
||||||
|
headingFont ? `})` : null,
|
||||||
|
]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join("\n")
|
||||||
|
const nextHtmlClassName = headingFont
|
||||||
|
? 'className={fontSans.variable + " " + fontHeading.variable}'
|
||||||
|
: `className={fontSans.variable}`
|
||||||
|
const otherFrameworkCss = [
|
||||||
|
":root {",
|
||||||
|
` ${font.font.variable}: ${font.font.family};`,
|
||||||
|
...(headingFont
|
||||||
|
? [` ${headingFont.font.variable}: ${headingFont.font.family};`]
|
||||||
|
: []),
|
||||||
|
"}",
|
||||||
|
].join("\n")
|
||||||
|
const headingSection = headingFont
|
||||||
|
? dedent`
|
||||||
|
|
||||||
|
This config also uses **${headingFont.title.replace(" (Heading)", "")}** for headings (\`${headingFont.font.variable}\`).
|
||||||
|
`
|
||||||
|
: ""
|
||||||
|
|
||||||
return dedent`
|
return dedent`
|
||||||
## Step 4: Set up the font
|
## Step 4: Set up the font
|
||||||
|
|
||||||
This config uses **${font.title}** (\`${font.font.variable}\`).
|
This config uses **${font.title}** (\`${font.font.variable}\`).
|
||||||
|
${headingSection}
|
||||||
|
|
||||||
### Next.js
|
### Next.js
|
||||||
|
|
||||||
\`\`\`tsx
|
\`\`\`tsx
|
||||||
import { ${font.font.import} } from "next/font/google"
|
import { ${nextImports} } from "next/font/google"
|
||||||
|
|
||||||
const fontSans = ${font.font.import}({
|
${nextDeclarations}
|
||||||
subsets: ["latin"],
|
|
||||||
variable: "${font.font.variable}",
|
|
||||||
})
|
|
||||||
|
|
||||||
// Add fontSans.variable to your <html> className.
|
// Add the font variable classes to your <html> className.
|
||||||
// <html className={fontSans.variable}>
|
// <html ${nextHtmlClassName}>
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
### Other frameworks
|
### Other frameworks
|
||||||
|
|
||||||
Add the font from [Google Fonts](${googleFontsUrl}) and set the \`${font.font.variable}\` CSS variable to the font family:
|
Add the font${headingFont ? "s" : ""} from [Google Fonts](${googleFontsUrl})${headingGoogleFontsUrl ? ` and [Google Fonts](${headingGoogleFontsUrl})` : ""} and set the CSS variable${headingFont ? "s" : ""} to the font famil${headingFont ? "ies" : "y"}:
|
||||||
|
|
||||||
\`\`\`css
|
\`\`\`css
|
||||||
:root {
|
${otherFrameworkCss}
|
||||||
${font.font.variable}: ${font.font.family};
|
|
||||||
}
|
|
||||||
\`\`\`
|
\`\`\`
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|||||||
21
apps/v4/app/(create)/init/parse-config.test.ts
Normal file
21
apps/v4/app/(create)/init/parse-config.test.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { describe, expect, it } from "vitest"
|
||||||
|
|
||||||
|
import { parseDesignSystemConfig } from "./parse-config"
|
||||||
|
|
||||||
|
describe("parseDesignSystemConfig", () => {
|
||||||
|
it("honors explicit fontHeading and chartColor overrides when a preset is present", () => {
|
||||||
|
const result = parseDesignSystemConfig(
|
||||||
|
new URLSearchParams(
|
||||||
|
"preset=a0&fontHeading=playfair-display&chartColor=emerald"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(result.success).toBe(true)
|
||||||
|
if (!result.success) {
|
||||||
|
throw new Error(result.error)
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(result.data.fontHeading).toBe("playfair-display")
|
||||||
|
expect(result.data.chartColor).toBe("emerald")
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
designSystemConfigSchema,
|
designSystemConfigSchema,
|
||||||
type DesignSystemConfig,
|
type DesignSystemConfig,
|
||||||
} from "@/registry/config"
|
} from "@/registry/config"
|
||||||
|
import { resolvePresetOverrides } from "@/app/(create)/lib/preset-query"
|
||||||
|
|
||||||
// Parses design system config from URL search params.
|
// Parses design system config from URL search params.
|
||||||
export function parseDesignSystemConfig(searchParams: URLSearchParams) {
|
export function parseDesignSystemConfig(searchParams: URLSearchParams) {
|
||||||
@@ -15,8 +16,10 @@ export function parseDesignSystemConfig(searchParams: URLSearchParams) {
|
|||||||
if (!decoded) {
|
if (!decoded) {
|
||||||
return { success: false as const, error: "Invalid preset code" }
|
return { success: false as const, error: "Invalid preset code" }
|
||||||
}
|
}
|
||||||
|
const presetOverrides = resolvePresetOverrides(searchParams, decoded)
|
||||||
configInput = {
|
configInput = {
|
||||||
...decoded,
|
...decoded,
|
||||||
|
...presetOverrides,
|
||||||
base: searchParams.get("base") ?? "radix",
|
base: searchParams.get("base") ?? "radix",
|
||||||
template: searchParams.get("template") ?? undefined,
|
template: searchParams.get("template") ?? undefined,
|
||||||
rtl: searchParams.get("rtl") === "true",
|
rtl: searchParams.get("rtl") === "true",
|
||||||
@@ -28,7 +31,9 @@ export function parseDesignSystemConfig(searchParams: URLSearchParams) {
|
|||||||
iconLibrary: searchParams.get("iconLibrary"),
|
iconLibrary: searchParams.get("iconLibrary"),
|
||||||
baseColor: searchParams.get("baseColor"),
|
baseColor: searchParams.get("baseColor"),
|
||||||
theme: searchParams.get("theme"),
|
theme: searchParams.get("theme"),
|
||||||
|
chartColor: searchParams.get("chartColor") ?? undefined,
|
||||||
font: searchParams.get("font"),
|
font: searchParams.get("font"),
|
||||||
|
fontHeading: searchParams.get("fontHeading") ?? undefined,
|
||||||
menuAccent: searchParams.get("menuAccent"),
|
menuAccent: searchParams.get("menuAccent"),
|
||||||
menuColor: searchParams.get("menuColor"),
|
menuColor: searchParams.get("menuColor"),
|
||||||
radius: searchParams.get("radius"),
|
radius: searchParams.get("radius"),
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { NextResponse, type NextRequest } from "next/server"
|
import { NextResponse, type NextRequest } from "next/server"
|
||||||
import { track } from "@vercel/analytics/server"
|
import { track } from "@vercel/analytics/server"
|
||||||
import { encodePreset, isPresetCode } from "shadcn/preset"
|
import { isPresetCode } from "shadcn/preset"
|
||||||
import { registryItemSchema } from "shadcn/schema"
|
import { registryItemSchema } from "shadcn/schema"
|
||||||
|
|
||||||
import { buildRegistryBase } from "@/registry/config"
|
import { buildRegistryBase } from "@/registry/config"
|
||||||
import { parseDesignSystemConfig } from "@/app/(create)/init/parse-config"
|
import { parseDesignSystemConfig } from "@/app/(create)/init/parse-config"
|
||||||
|
import { getPresetCode } from "@/app/(create)/lib/preset-code"
|
||||||
|
|
||||||
export async function GET(request: NextRequest) {
|
export async function GET(request: NextRequest) {
|
||||||
try {
|
try {
|
||||||
@@ -15,21 +16,11 @@ export async function GET(request: NextRequest) {
|
|||||||
return NextResponse.json({ error: result.error }, { status: 400 })
|
return NextResponse.json({ error: result.error }, { status: 400 })
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use the preset code from the URL if provided, otherwise encode one.
|
const rawPreset = searchParams.get("preset")
|
||||||
const presetParam = searchParams.get("preset")
|
|
||||||
const presetCode =
|
const presetCode =
|
||||||
presetParam && isPresetCode(presetParam)
|
rawPreset && isPresetCode(rawPreset)
|
||||||
? presetParam
|
? rawPreset
|
||||||
: encodePreset({
|
: getPresetCode(result.data)
|
||||||
style: result.data.style,
|
|
||||||
baseColor: result.data.baseColor,
|
|
||||||
theme: result.data.theme,
|
|
||||||
iconLibrary: result.data.iconLibrary,
|
|
||||||
font: result.data.font,
|
|
||||||
radius: result.data.radius,
|
|
||||||
menuAccent: result.data.menuAccent,
|
|
||||||
menuColor: result.data.menuColor,
|
|
||||||
} as Parameters<typeof encodePreset>[0])
|
|
||||||
|
|
||||||
const registryBase = buildRegistryBase(result.data)
|
const registryBase = buildRegistryBase(result.data)
|
||||||
const parseResult = registryItemSchema.safeParse(registryBase)
|
const parseResult = registryItemSchema.safeParse(registryBase)
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { after, NextResponse, type NextRequest } from "next/server"
|
import { after, NextResponse, type NextRequest } from "next/server"
|
||||||
import { track } from "@vercel/analytics/server"
|
import { track } from "@vercel/analytics/server"
|
||||||
|
import { isPresetCode } from "shadcn/preset"
|
||||||
|
|
||||||
import { parseDesignSystemConfig } from "@/app/(create)/init/parse-config"
|
import { parseDesignSystemConfig } from "@/app/(create)/init/parse-config"
|
||||||
|
import { getPresetCode } from "@/app/(create)/lib/preset-code"
|
||||||
import { buildV0Payload } from "@/app/(create)/lib/v0"
|
import { buildV0Payload } from "@/app/(create)/lib/v0"
|
||||||
|
|
||||||
export async function GET(request: NextRequest) {
|
export async function GET(request: NextRequest) {
|
||||||
@@ -13,11 +15,17 @@ export async function GET(request: NextRequest) {
|
|||||||
return NextResponse.json({ error: result.error }, { status: 400 })
|
return NextResponse.json({ error: result.error }, { status: 400 })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const rawPreset = searchParams.get("preset")
|
||||||
|
const presetCode =
|
||||||
|
rawPreset && isPresetCode(rawPreset)
|
||||||
|
? rawPreset
|
||||||
|
: getPresetCode(result.data)
|
||||||
|
|
||||||
// Defer analytics to after response is sent.
|
// Defer analytics to after response is sent.
|
||||||
after(() => {
|
after(() => {
|
||||||
track("create_open_in_v0", {
|
track("create_open_in_v0", {
|
||||||
...result.data,
|
...result.data,
|
||||||
preset: searchParams.get("preset") ?? "",
|
preset: presetCode,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -3,21 +3,37 @@ import {
|
|||||||
Figtree,
|
Figtree,
|
||||||
Geist,
|
Geist,
|
||||||
Geist_Mono,
|
Geist_Mono,
|
||||||
|
IBM_Plex_Sans,
|
||||||
|
Instrument_Sans,
|
||||||
Inter,
|
Inter,
|
||||||
JetBrains_Mono,
|
JetBrains_Mono,
|
||||||
Lora,
|
Lora,
|
||||||
|
Manrope,
|
||||||
Merriweather,
|
Merriweather,
|
||||||
|
Montserrat,
|
||||||
Noto_Sans,
|
Noto_Sans,
|
||||||
Noto_Serif,
|
Noto_Serif,
|
||||||
Nunito_Sans,
|
Nunito_Sans,
|
||||||
Outfit,
|
Outfit,
|
||||||
|
Oxanium,
|
||||||
Playfair_Display,
|
Playfair_Display,
|
||||||
Public_Sans,
|
Public_Sans,
|
||||||
Raleway,
|
Raleway,
|
||||||
Roboto,
|
Roboto,
|
||||||
Roboto_Slab,
|
Roboto_Slab,
|
||||||
|
Source_Sans_3,
|
||||||
|
Space_Grotesk,
|
||||||
} from "next/font/google"
|
} from "next/font/google"
|
||||||
|
|
||||||
|
import { FONT_DEFINITIONS, type FontName } from "@/lib/font-definitions"
|
||||||
|
|
||||||
|
type PreviewFont = ReturnType<typeof Inter>
|
||||||
|
|
||||||
|
const geistSans = Geist({
|
||||||
|
subsets: ["latin"],
|
||||||
|
variable: "--font-geist-sans",
|
||||||
|
})
|
||||||
|
|
||||||
const inter = Inter({
|
const inter = Inter({
|
||||||
subsets: ["latin"],
|
subsets: ["latin"],
|
||||||
variable: "--font-inter",
|
variable: "--font-inter",
|
||||||
@@ -38,21 +54,6 @@ const figtree = Figtree({
|
|||||||
variable: "--font-figtree",
|
variable: "--font-figtree",
|
||||||
})
|
})
|
||||||
|
|
||||||
const jetbrainsMono = JetBrains_Mono({
|
|
||||||
subsets: ["latin"],
|
|
||||||
variable: "--font-jetbrains-mono",
|
|
||||||
})
|
|
||||||
|
|
||||||
const geistSans = Geist({
|
|
||||||
subsets: ["latin"],
|
|
||||||
variable: "--font-geist-sans",
|
|
||||||
})
|
|
||||||
|
|
||||||
const geistMono = Geist_Mono({
|
|
||||||
subsets: ["latin"],
|
|
||||||
variable: "--font-geist-mono",
|
|
||||||
})
|
|
||||||
|
|
||||||
const roboto = Roboto({
|
const roboto = Roboto({
|
||||||
subsets: ["latin"],
|
subsets: ["latin"],
|
||||||
variable: "--font-roboto",
|
variable: "--font-roboto",
|
||||||
@@ -78,6 +79,51 @@ const outfit = Outfit({
|
|||||||
variable: "--font-outfit",
|
variable: "--font-outfit",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const oxanium = Oxanium({
|
||||||
|
subsets: ["latin"],
|
||||||
|
variable: "--font-oxanium",
|
||||||
|
})
|
||||||
|
|
||||||
|
const manrope = Manrope({
|
||||||
|
subsets: ["latin"],
|
||||||
|
variable: "--font-manrope",
|
||||||
|
})
|
||||||
|
|
||||||
|
const spaceGrotesk = Space_Grotesk({
|
||||||
|
subsets: ["latin"],
|
||||||
|
variable: "--font-space-grotesk",
|
||||||
|
})
|
||||||
|
|
||||||
|
const montserrat = Montserrat({
|
||||||
|
subsets: ["latin"],
|
||||||
|
variable: "--font-montserrat",
|
||||||
|
})
|
||||||
|
|
||||||
|
const ibmPlexSans = IBM_Plex_Sans({
|
||||||
|
subsets: ["latin"],
|
||||||
|
variable: "--font-ibm-plex-sans",
|
||||||
|
})
|
||||||
|
|
||||||
|
const sourceSans3 = Source_Sans_3({
|
||||||
|
subsets: ["latin"],
|
||||||
|
variable: "--font-source-sans-3",
|
||||||
|
})
|
||||||
|
|
||||||
|
const instrumentSans = Instrument_Sans({
|
||||||
|
subsets: ["latin"],
|
||||||
|
variable: "--font-instrument-sans",
|
||||||
|
})
|
||||||
|
|
||||||
|
const jetbrainsMono = JetBrains_Mono({
|
||||||
|
subsets: ["latin"],
|
||||||
|
variable: "--font-jetbrains-mono",
|
||||||
|
})
|
||||||
|
|
||||||
|
const geistMono = Geist_Mono({
|
||||||
|
subsets: ["latin"],
|
||||||
|
variable: "--font-geist-mono",
|
||||||
|
})
|
||||||
|
|
||||||
const notoSerif = Noto_Serif({
|
const notoSerif = Noto_Serif({
|
||||||
subsets: ["latin"],
|
subsets: ["latin"],
|
||||||
variable: "--font-noto-serif",
|
variable: "--font-noto-serif",
|
||||||
@@ -103,109 +149,85 @@ const playfairDisplay = Playfair_Display({
|
|||||||
variable: "--font-playfair-display",
|
variable: "--font-playfair-display",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const PREVIEW_FONTS = {
|
||||||
|
geist: geistSans,
|
||||||
|
inter,
|
||||||
|
"noto-sans": notoSans,
|
||||||
|
"nunito-sans": nunitoSans,
|
||||||
|
figtree,
|
||||||
|
roboto,
|
||||||
|
raleway,
|
||||||
|
"dm-sans": dmSans,
|
||||||
|
"public-sans": publicSans,
|
||||||
|
outfit,
|
||||||
|
oxanium,
|
||||||
|
manrope,
|
||||||
|
"space-grotesk": spaceGrotesk,
|
||||||
|
montserrat,
|
||||||
|
"ibm-plex-sans": ibmPlexSans,
|
||||||
|
"source-sans-3": sourceSans3,
|
||||||
|
"instrument-sans": instrumentSans,
|
||||||
|
"jetbrains-mono": jetbrainsMono,
|
||||||
|
"geist-mono": geistMono,
|
||||||
|
"noto-serif": notoSerif,
|
||||||
|
"roboto-slab": robotoSlab,
|
||||||
|
merriweather,
|
||||||
|
lora,
|
||||||
|
"playfair-display": playfairDisplay,
|
||||||
|
} satisfies Record<FontName, PreviewFont>
|
||||||
|
|
||||||
|
function createFontOption(name: FontName) {
|
||||||
|
const definition = FONT_DEFINITIONS.find((font) => font.name === name)
|
||||||
|
|
||||||
|
if (!definition) {
|
||||||
|
throw new Error(`Unknown font definition: ${name}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: definition.title,
|
||||||
|
value: definition.name,
|
||||||
|
font: PREVIEW_FONTS[name],
|
||||||
|
type: definition.type,
|
||||||
|
} as const
|
||||||
|
}
|
||||||
|
|
||||||
export const FONTS = [
|
export const FONTS = [
|
||||||
{
|
createFontOption("geist"),
|
||||||
name: "Geist",
|
createFontOption("inter"),
|
||||||
value: "geist",
|
createFontOption("noto-sans"),
|
||||||
font: geistSans,
|
createFontOption("nunito-sans"),
|
||||||
type: "sans",
|
createFontOption("figtree"),
|
||||||
},
|
createFontOption("roboto"),
|
||||||
{
|
createFontOption("raleway"),
|
||||||
name: "Inter",
|
createFontOption("dm-sans"),
|
||||||
value: "inter",
|
createFontOption("public-sans"),
|
||||||
font: inter,
|
createFontOption("outfit"),
|
||||||
type: "sans",
|
createFontOption("oxanium"),
|
||||||
},
|
createFontOption("manrope"),
|
||||||
{
|
createFontOption("space-grotesk"),
|
||||||
name: "Noto Sans",
|
createFontOption("montserrat"),
|
||||||
value: "noto-sans",
|
createFontOption("ibm-plex-sans"),
|
||||||
font: notoSans,
|
createFontOption("source-sans-3"),
|
||||||
type: "sans",
|
createFontOption("instrument-sans"),
|
||||||
},
|
createFontOption("geist-mono"),
|
||||||
{
|
createFontOption("jetbrains-mono"),
|
||||||
name: "Nunito Sans",
|
createFontOption("noto-serif"),
|
||||||
value: "nunito-sans",
|
createFontOption("roboto-slab"),
|
||||||
font: nunitoSans,
|
createFontOption("merriweather"),
|
||||||
type: "sans",
|
createFontOption("lora"),
|
||||||
},
|
createFontOption("playfair-display"),
|
||||||
{
|
|
||||||
name: "Figtree",
|
|
||||||
value: "figtree",
|
|
||||||
font: figtree,
|
|
||||||
type: "sans",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Roboto",
|
|
||||||
value: "roboto",
|
|
||||||
font: roboto,
|
|
||||||
type: "sans",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Raleway",
|
|
||||||
value: "raleway",
|
|
||||||
font: raleway,
|
|
||||||
type: "sans",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "DM Sans",
|
|
||||||
value: "dm-sans",
|
|
||||||
font: dmSans,
|
|
||||||
type: "sans",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Public Sans",
|
|
||||||
value: "public-sans",
|
|
||||||
font: publicSans,
|
|
||||||
type: "sans",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Outfit",
|
|
||||||
value: "outfit",
|
|
||||||
font: outfit,
|
|
||||||
type: "sans",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Geist Mono",
|
|
||||||
value: "geist-mono",
|
|
||||||
font: geistMono,
|
|
||||||
type: "mono",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "JetBrains Mono",
|
|
||||||
value: "jetbrains-mono",
|
|
||||||
font: jetbrainsMono,
|
|
||||||
type: "mono",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Noto Serif",
|
|
||||||
value: "noto-serif",
|
|
||||||
font: notoSerif,
|
|
||||||
type: "serif",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Roboto Slab",
|
|
||||||
value: "roboto-slab",
|
|
||||||
font: robotoSlab,
|
|
||||||
type: "serif",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Merriweather",
|
|
||||||
value: "merriweather",
|
|
||||||
font: merriweather,
|
|
||||||
type: "serif",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Lora",
|
|
||||||
value: "lora",
|
|
||||||
font: lora,
|
|
||||||
type: "serif",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Playfair Display",
|
|
||||||
value: "playfair-display",
|
|
||||||
font: playfairDisplay,
|
|
||||||
type: "serif",
|
|
||||||
},
|
|
||||||
] as const
|
] as const
|
||||||
|
|
||||||
export type Font = (typeof FONTS)[number]
|
export type Font = (typeof FONTS)[number]
|
||||||
|
|
||||||
|
export const FONT_HEADING_OPTIONS = [
|
||||||
|
{
|
||||||
|
name: "Inherit",
|
||||||
|
value: "inherit",
|
||||||
|
font: null,
|
||||||
|
type: "default",
|
||||||
|
},
|
||||||
|
...FONTS,
|
||||||
|
] as const
|
||||||
|
|
||||||
|
export type FontHeadingOption = (typeof FONT_HEADING_OPTIONS)[number]
|
||||||
|
|||||||
34
apps/v4/app/(create)/lib/preset-code.ts
Normal file
34
apps/v4/app/(create)/lib/preset-code.ts
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import { encodePreset, type PresetConfig } from "shadcn/preset"
|
||||||
|
|
||||||
|
import { type DesignSystemConfig } from "@/registry/config"
|
||||||
|
|
||||||
|
type PresetCodeConfig = Pick<
|
||||||
|
DesignSystemConfig,
|
||||||
|
| "style"
|
||||||
|
| "baseColor"
|
||||||
|
| "theme"
|
||||||
|
| "chartColor"
|
||||||
|
| "iconLibrary"
|
||||||
|
| "font"
|
||||||
|
| "fontHeading"
|
||||||
|
| "radius"
|
||||||
|
| "menuAccent"
|
||||||
|
| "menuColor"
|
||||||
|
>
|
||||||
|
|
||||||
|
export function getPresetCode(config: PresetCodeConfig) {
|
||||||
|
const presetConfig: Partial<PresetConfig> = {
|
||||||
|
style: config.style as PresetConfig["style"],
|
||||||
|
baseColor: config.baseColor as PresetConfig["baseColor"],
|
||||||
|
theme: config.theme as PresetConfig["theme"],
|
||||||
|
chartColor: config.chartColor as PresetConfig["chartColor"],
|
||||||
|
iconLibrary: config.iconLibrary as PresetConfig["iconLibrary"],
|
||||||
|
font: config.font as PresetConfig["font"],
|
||||||
|
fontHeading: config.fontHeading as PresetConfig["fontHeading"],
|
||||||
|
radius: config.radius as PresetConfig["radius"],
|
||||||
|
menuAccent: config.menuAccent as PresetConfig["menuAccent"],
|
||||||
|
menuColor: config.menuColor as PresetConfig["menuColor"],
|
||||||
|
}
|
||||||
|
|
||||||
|
return encodePreset(presetConfig)
|
||||||
|
}
|
||||||
34
apps/v4/app/(create)/lib/preset-query.test.ts
Normal file
34
apps/v4/app/(create)/lib/preset-query.test.ts
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import { describe, expect, it } from "vitest"
|
||||||
|
|
||||||
|
import { resolvePresetOverrides } from "./preset-query"
|
||||||
|
|
||||||
|
describe("resolvePresetOverrides", () => {
|
||||||
|
it("prefers explicit fontHeading and chartColor query params", () => {
|
||||||
|
const overrides = resolvePresetOverrides(
|
||||||
|
new URLSearchParams("fontHeading=playfair-display&chartColor=emerald"),
|
||||||
|
{
|
||||||
|
theme: "neutral",
|
||||||
|
chartColor: "blue",
|
||||||
|
fontHeading: "inherit",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(overrides).toEqual({
|
||||||
|
fontHeading: "playfair-display",
|
||||||
|
chartColor: "emerald",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it("falls back to decoded preset values when no overrides are present", () => {
|
||||||
|
const overrides = resolvePresetOverrides(new URLSearchParams(), {
|
||||||
|
theme: "neutral",
|
||||||
|
chartColor: "blue",
|
||||||
|
fontHeading: "inherit",
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(overrides).toEqual({
|
||||||
|
fontHeading: "inherit",
|
||||||
|
chartColor: "blue",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
30
apps/v4/app/(create)/lib/preset-query.ts
Normal file
30
apps/v4/app/(create)/lib/preset-query.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import { V1_CHART_COLOR_MAP, type PresetConfig } from "shadcn/preset"
|
||||||
|
|
||||||
|
import { type ChartColorName, type FontHeadingValue } from "@/registry/config"
|
||||||
|
|
||||||
|
type SearchParamsLike = Pick<URLSearchParams, "get" | "has">
|
||||||
|
|
||||||
|
export function resolvePresetOverrides(
|
||||||
|
searchParams: SearchParamsLike,
|
||||||
|
decoded: Pick<PresetConfig, "theme" | "chartColor" | "fontHeading">
|
||||||
|
) {
|
||||||
|
const hasFontHeadingOverride = searchParams.has("fontHeading")
|
||||||
|
const hasChartColorOverride = searchParams.has("chartColor")
|
||||||
|
|
||||||
|
const fontHeading = hasFontHeadingOverride
|
||||||
|
? ((searchParams.get("fontHeading") ??
|
||||||
|
decoded.fontHeading) as FontHeadingValue)
|
||||||
|
: decoded.fontHeading
|
||||||
|
|
||||||
|
const chartColor = hasChartColorOverride
|
||||||
|
? ((searchParams.get("chartColor") ??
|
||||||
|
decoded.chartColor ??
|
||||||
|
V1_CHART_COLOR_MAP[decoded.theme] ??
|
||||||
|
decoded.theme) as ChartColorName)
|
||||||
|
: (decoded.chartColor ?? V1_CHART_COLOR_MAP[decoded.theme] ?? decoded.theme)
|
||||||
|
|
||||||
|
return {
|
||||||
|
fontHeading,
|
||||||
|
chartColor,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import type {
|
|||||||
BaseColorName,
|
BaseColorName,
|
||||||
Radius,
|
Radius,
|
||||||
StyleName,
|
StyleName,
|
||||||
|
Theme,
|
||||||
ThemeName,
|
ThemeName,
|
||||||
} from "@/registry/config"
|
} from "@/registry/config"
|
||||||
|
|
||||||
@@ -12,6 +13,7 @@ export type RandomizeContext = {
|
|||||||
style?: StyleName
|
style?: StyleName
|
||||||
baseColor?: BaseColorName
|
baseColor?: BaseColorName
|
||||||
theme?: ThemeName
|
theme?: ThemeName
|
||||||
|
chartColor?: string
|
||||||
iconLibrary?: string
|
iconLibrary?: string
|
||||||
font?: string
|
font?: string
|
||||||
menuAccent?: string
|
menuAccent?: string
|
||||||
@@ -26,12 +28,30 @@ export type BiasFilter<T> = (
|
|||||||
|
|
||||||
export type RandomizeBiases = {
|
export type RandomizeBiases = {
|
||||||
baseColors?: BiasFilter<BaseColor>
|
baseColors?: BiasFilter<BaseColor>
|
||||||
|
chartColors?: BiasFilter<Theme>
|
||||||
fonts?: BiasFilter<(typeof FONTS)[number]>
|
fonts?: BiasFilter<(typeof FONTS)[number]>
|
||||||
radius?: BiasFilter<Radius>
|
radius?: BiasFilter<Radius>
|
||||||
// Add more bias filters as needed:
|
}
|
||||||
// styles?: BiasFilter<Style>
|
|
||||||
// themes?: BiasFilter<Theme>
|
// Theme → chart color pairings for randomization.
|
||||||
// etc.
|
const CHART_COLOR_PAIRINGS: Record<string, string[]> = {
|
||||||
|
red: ["teal", "sky"],
|
||||||
|
orange: ["teal", "blue"],
|
||||||
|
amber: ["cyan", "indigo"],
|
||||||
|
yellow: ["sky", "violet"],
|
||||||
|
lime: ["indigo", "pink"],
|
||||||
|
green: ["purple", "rose"],
|
||||||
|
emerald: ["purple", "red"],
|
||||||
|
teal: ["fuchsia", "red"],
|
||||||
|
cyan: ["rose", "amber"],
|
||||||
|
sky: ["red", "yellow"],
|
||||||
|
blue: ["orange", "yellow"],
|
||||||
|
indigo: ["amber", "yellow"],
|
||||||
|
violet: ["yellow", "lime"],
|
||||||
|
purple: ["green", "lime"],
|
||||||
|
fuchsia: ["lime", "teal"],
|
||||||
|
pink: ["green", "cyan"],
|
||||||
|
rose: ["emerald", "sky"],
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,21 +71,25 @@ export const RANDOMIZE_BIASES: RandomizeBiases = {
|
|||||||
return fonts
|
return fonts
|
||||||
},
|
},
|
||||||
radius: (radii, context) => {
|
radius: (radii, context) => {
|
||||||
// When style is lyra, always use "none" radius
|
// When style is lyra, always use "none" radius.
|
||||||
if (context.style === "lyra") {
|
if (context.style === "lyra") {
|
||||||
return radii.filter((radius) => radius.name === "none")
|
return radii.filter((radius) => radius.name === "none")
|
||||||
}
|
}
|
||||||
|
|
||||||
return radii
|
return radii
|
||||||
},
|
},
|
||||||
// Add more biases here as needed:
|
chartColors: (chartColors, context) => {
|
||||||
// Example: When baseColor is "blue", prefer certain themes
|
// When theme has a pairing, restrict chart colors to the paired values.
|
||||||
// themes: (themes, context) => {
|
const pairing = context.theme ? CHART_COLOR_PAIRINGS[context.theme] : null
|
||||||
// if (context.baseColor === "blue") {
|
if (pairing) {
|
||||||
// return themes.filter(theme => theme.name.includes("dark"))
|
const filtered = chartColors.filter((c) => pairing.includes(c.name))
|
||||||
// }
|
if (filtered.length > 0) {
|
||||||
// return themes
|
return filtered
|
||||||
// },
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return chartColors
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
|
import { useSearchParams } from "next/navigation"
|
||||||
import { useQueryStates } from "nuqs"
|
import { useQueryStates } from "nuqs"
|
||||||
import {
|
import {
|
||||||
createLoader,
|
createLoader,
|
||||||
@@ -10,12 +11,13 @@ import {
|
|||||||
type inferParserType,
|
type inferParserType,
|
||||||
type Options,
|
type Options,
|
||||||
} from "nuqs/server"
|
} from "nuqs/server"
|
||||||
import { decodePreset, encodePreset, isPresetCode } from "shadcn/preset"
|
import { decodePreset, isPresetCode } from "shadcn/preset"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BASE_COLORS,
|
BASE_COLORS,
|
||||||
BASES,
|
BASES,
|
||||||
DEFAULT_CONFIG,
|
DEFAULT_CONFIG,
|
||||||
|
getThemesForBaseColor,
|
||||||
iconLibraries,
|
iconLibraries,
|
||||||
MENU_ACCENTS,
|
MENU_ACCENTS,
|
||||||
MENU_COLORS,
|
MENU_COLORS,
|
||||||
@@ -24,6 +26,8 @@ import {
|
|||||||
THEMES,
|
THEMES,
|
||||||
type BaseColorName,
|
type BaseColorName,
|
||||||
type BaseName,
|
type BaseName,
|
||||||
|
type ChartColorName,
|
||||||
|
type FontHeadingValue,
|
||||||
type FontValue,
|
type FontValue,
|
||||||
type IconLibraryName,
|
type IconLibraryName,
|
||||||
type MenuAccentValue,
|
type MenuAccentValue,
|
||||||
@@ -33,9 +37,11 @@ import {
|
|||||||
type ThemeName,
|
type ThemeName,
|
||||||
} from "@/registry/config"
|
} from "@/registry/config"
|
||||||
import { FONTS } from "@/app/(create)/lib/fonts"
|
import { FONTS } from "@/app/(create)/lib/fonts"
|
||||||
|
import { getPresetCode } from "@/app/(create)/lib/preset-code"
|
||||||
|
import { resolvePresetOverrides } from "@/app/(create)/lib/preset-query"
|
||||||
|
|
||||||
const designSystemSearchParams = {
|
const designSystemSearchParams = {
|
||||||
preset: parseAsString.withDefault("a0"),
|
preset: parseAsString.withDefault("b0"),
|
||||||
base: parseAsStringLiteral<BaseName>(BASES.map((b) => b.name)).withDefault(
|
base: parseAsStringLiteral<BaseName>(BASES.map((b) => b.name)).withDefault(
|
||||||
DEFAULT_CONFIG.base
|
DEFAULT_CONFIG.base
|
||||||
),
|
),
|
||||||
@@ -49,9 +55,16 @@ const designSystemSearchParams = {
|
|||||||
theme: parseAsStringLiteral<ThemeName>(THEMES.map((t) => t.name)).withDefault(
|
theme: parseAsStringLiteral<ThemeName>(THEMES.map((t) => t.name)).withDefault(
|
||||||
DEFAULT_CONFIG.theme
|
DEFAULT_CONFIG.theme
|
||||||
),
|
),
|
||||||
|
chartColor: parseAsStringLiteral<ChartColorName>(
|
||||||
|
THEMES.map((t) => t.name)
|
||||||
|
).withDefault(DEFAULT_CONFIG.chartColor ?? "neutral"),
|
||||||
font: parseAsStringLiteral<FontValue>(FONTS.map((f) => f.value)).withDefault(
|
font: parseAsStringLiteral<FontValue>(FONTS.map((f) => f.value)).withDefault(
|
||||||
DEFAULT_CONFIG.font
|
DEFAULT_CONFIG.font
|
||||||
),
|
),
|
||||||
|
fontHeading: parseAsStringLiteral<FontHeadingValue>([
|
||||||
|
"inherit",
|
||||||
|
...FONTS.map((f) => f.value),
|
||||||
|
]).withDefault(DEFAULT_CONFIG.fontHeading),
|
||||||
baseColor: parseAsStringLiteral<BaseColorName>(
|
baseColor: parseAsStringLiteral<BaseColorName>(
|
||||||
BASE_COLORS.map((b) => b.name)
|
BASE_COLORS.map((b) => b.name)
|
||||||
).withDefault(DEFAULT_CONFIG.baseColor),
|
).withDefault(DEFAULT_CONFIG.baseColor),
|
||||||
@@ -87,13 +100,24 @@ const DESIGN_SYSTEM_KEYS = [
|
|||||||
"style",
|
"style",
|
||||||
"baseColor",
|
"baseColor",
|
||||||
"theme",
|
"theme",
|
||||||
|
"chartColor",
|
||||||
"iconLibrary",
|
"iconLibrary",
|
||||||
"font",
|
"font",
|
||||||
|
"fontHeading",
|
||||||
"radius",
|
"radius",
|
||||||
"menuAccent",
|
"menuAccent",
|
||||||
"menuColor",
|
"menuColor",
|
||||||
] as const
|
] as const
|
||||||
|
|
||||||
|
function normalizeFontHeading(
|
||||||
|
font: FontValue,
|
||||||
|
fontHeading: FontHeadingValue
|
||||||
|
): FontHeadingValue {
|
||||||
|
// Persist "same as body" as an explicit inherit sentinel so the body font
|
||||||
|
// can change later without freezing headings to a concrete previous value.
|
||||||
|
return fontHeading === font ? "inherit" : fontHeading
|
||||||
|
}
|
||||||
|
|
||||||
// Non-design-system keys that get passed through as-is.
|
// Non-design-system keys that get passed through as-is.
|
||||||
// `base` is not encoded in preset codes — it's an architectural choice, not visual.
|
// `base` is not encoded in preset codes — it's an architectural choice, not visual.
|
||||||
const NON_DESIGN_SYSTEM_KEYS = [
|
const NON_DESIGN_SYSTEM_KEYS = [
|
||||||
@@ -145,39 +169,83 @@ function normalizePartialDesignSystemParams(
|
|||||||
function normalizeDesignSystemParams(
|
function normalizeDesignSystemParams(
|
||||||
params: DesignSystemSearchParams
|
params: DesignSystemSearchParams
|
||||||
): DesignSystemSearchParams {
|
): DesignSystemSearchParams {
|
||||||
|
let result = {
|
||||||
|
...params,
|
||||||
|
fontHeading: normalizeFontHeading(params.font, params.fontHeading),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate theme and chartColor against baseColor.
|
||||||
|
if (result.baseColor) {
|
||||||
|
const available = getThemesForBaseColor(result.baseColor)
|
||||||
|
const themeValid = available.some((t) => t.name === result.theme)
|
||||||
|
const chartColorValid = available.some((t) => t.name === result.chartColor)
|
||||||
|
|
||||||
|
if (!themeValid || !chartColorValid) {
|
||||||
|
const fallback = (available[0]?.name ?? result.baseColor) as ThemeName
|
||||||
|
result = {
|
||||||
|
...result,
|
||||||
|
...(!themeValid && { theme: fallback }),
|
||||||
|
...(!chartColorValid && { chartColor: fallback as ChartColorName }),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
params.menuAccent === "bold" &&
|
result.menuAccent === "bold" &&
|
||||||
isTranslucentMenuColor(params.menuColor)
|
isTranslucentMenuColor(result.menuColor)
|
||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
...params,
|
...result,
|
||||||
menuAccent: "subtle",
|
menuAccent: "subtle",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return params
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// If preset param exists, decode it and overlay on raw params.
|
||||||
|
// V1 presets don't encode chartColor — fall back to the colored
|
||||||
|
// theme that base-color themes originally borrowed charts from.
|
||||||
|
type SearchParamsLike = Pick<URLSearchParams, "get" | "has">
|
||||||
|
|
||||||
|
function resolvePresetParams(
|
||||||
|
rawParams: DesignSystemSearchParams,
|
||||||
|
searchParams: SearchParamsLike
|
||||||
|
) {
|
||||||
|
if (rawParams.preset && isPresetCode(rawParams.preset)) {
|
||||||
|
const decoded = decodePreset(rawParams.preset)
|
||||||
|
if (decoded) {
|
||||||
|
const presetOverrides = resolvePresetOverrides(searchParams, decoded)
|
||||||
|
return normalizeDesignSystemParams({
|
||||||
|
...decoded,
|
||||||
|
...presetOverrides,
|
||||||
|
base: rawParams.base,
|
||||||
|
item: rawParams.item,
|
||||||
|
preset: rawParams.preset,
|
||||||
|
template: rawParams.template,
|
||||||
|
rtl: rawParams.rtl,
|
||||||
|
size: rawParams.size,
|
||||||
|
custom: rawParams.custom,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return normalizeDesignSystemParams(rawParams)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wraps nuqs useQueryStates with transparent preset encoding/decoding.
|
// Wraps nuqs useQueryStates with transparent preset encoding/decoding.
|
||||||
// - Reads: if ?preset=CODE is in the URL, decodes it and returns individual values.
|
// - Reads: if ?preset=CODE is in the URL, decodes it and returns individual values.
|
||||||
// - Writes: when design system params are set, encodes them into a preset code.
|
// - Writes: when design system params are set, encodes them into a preset code.
|
||||||
export function useDesignSystemSearchParams(options: Options = {}) {
|
export function useDesignSystemSearchParams(options: Options = {}) {
|
||||||
|
const searchParams = useSearchParams()
|
||||||
const [rawParams, rawSetParams] = useQueryStates(designSystemSearchParams, {
|
const [rawParams, rawSetParams] = useQueryStates(designSystemSearchParams, {
|
||||||
shallow: false,
|
shallow: false,
|
||||||
history: "push",
|
history: "push",
|
||||||
...options,
|
...options,
|
||||||
})
|
})
|
||||||
|
|
||||||
// If preset param exists, decode it and overlay on raw params.
|
|
||||||
const params = React.useMemo(
|
const params = React.useMemo(
|
||||||
() =>
|
() => resolvePresetParams(rawParams, searchParams),
|
||||||
rawParams.preset && isPresetCode(rawParams.preset)
|
[rawParams, searchParams]
|
||||||
? normalizeDesignSystemParams({
|
|
||||||
...rawParams,
|
|
||||||
...(decodePreset(rawParams.preset) ?? {}),
|
|
||||||
})
|
|
||||||
: normalizeDesignSystemParams(rawParams),
|
|
||||||
[rawParams]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Use ref so setParams callback stays stable across renders.
|
// Use ref so setParams callback stays stable across renders.
|
||||||
@@ -215,21 +283,10 @@ export function useDesignSystemSearchParams(options: Options = {}) {
|
|||||||
...paramsRef.current,
|
...paramsRef.current,
|
||||||
...resolvedUpdates,
|
...resolvedUpdates,
|
||||||
})
|
})
|
||||||
|
|
||||||
// Encode design system fields into a preset code.
|
// Encode design system fields into a preset code.
|
||||||
// Cast needed: merged values may include null from nuqs resets,
|
// Cast needed: merged values may include null from nuqs resets,
|
||||||
// but encodePreset handles missing values by falling back to defaults.
|
// but encodePreset handles missing values by falling back to defaults.
|
||||||
const code = encodePreset({
|
const code = getPresetCode(merged)
|
||||||
style: merged.style ?? undefined,
|
|
||||||
baseColor: merged.baseColor ?? undefined,
|
|
||||||
theme: merged.theme ?? undefined,
|
|
||||||
iconLibrary: merged.iconLibrary ?? undefined,
|
|
||||||
font: merged.font ?? undefined,
|
|
||||||
radius: merged.radius ?? undefined,
|
|
||||||
menuAccent: merged.menuAccent ?? undefined,
|
|
||||||
menuColor: merged.menuColor ?? undefined,
|
|
||||||
} as Parameters<typeof encodePreset>[0])
|
|
||||||
|
|
||||||
// Build update: set preset, clear individual DS params from URL.
|
// Build update: set preset, clear individual DS params from URL.
|
||||||
const rawUpdate: Record<string, unknown> = { preset: code }
|
const rawUpdate: Record<string, unknown> = { preset: code }
|
||||||
for (const key of DESIGN_SYSTEM_KEYS) {
|
for (const key of DESIGN_SYSTEM_KEYS) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export const TEMPLATES = [
|
|||||||
{
|
{
|
||||||
value: "vite",
|
value: "vite",
|
||||||
title: "Vite",
|
title: "Vite",
|
||||||
logo: '<svg xmlns="http://www.w3.org/2000/svg" width="410" height="404" fill="none" viewBox="0 0 410 404"><path fill="var(--foreground)" d="m399.641 59.525-183.998 329.02c-3.799 6.793-13.559 6.833-17.415.073L10.582 59.556C6.38 52.19 12.68 43.266 21.028 44.76l184.195 32.923c1.175.21 2.378.208 3.553-.006l180.343-32.87c8.32-1.517 14.649 7.337 10.522 14.719"/><path fill="var(--background)" d="M292.965 1.574 156.801 28.255a5 5 0 0 0-4.03 4.611l-8.376 141.464c-.197 3.332 2.863 5.918 6.115 5.168l37.91-8.749c3.547-.818 6.752 2.306 6.023 5.873l-11.263 55.153c-.758 3.712 2.727 6.886 6.352 5.785l23.415-7.114c3.63-1.102 7.118 2.081 6.35 5.796l-17.899 86.633c-1.12 5.419 6.088 8.374 9.094 3.728l2.008-3.103 110.954-221.428c1.858-3.707-1.346-7.935-5.418-7.15l-39.022 7.532c-3.667.707-6.787-2.708-5.752-6.296l25.469-88.291c1.036-3.594-2.095-7.012-5.766-6.293"/></svg>',
|
logo: '<svg xmlns="http://www.w3.org/2000/svg" width="410" height="404" fill="none" viewBox="0 0 410 404"><path fill="var(--foreground)" d="m399.641 59.525-183.998 329.02c-3.799 6.793-13.559 6.833-17.415.073L10.582 59.556C6.38 52.19 12.68 43.266 21.028 44.76l184.195 32.923c1.175.21 2.378.208 3.553-.006l180.343-32.87c8.32-1.517 14.649 7.337 10.522 14.719"/><path fill="var(--color-neutral-800)" d="M292.965 1.574 156.801 28.255a5 5 0 0 0-4.03 4.611l-8.376 141.464c-.197 3.332 2.863 5.918 6.115 5.168l37.91-8.749c3.547-.818 6.752 2.306 6.023 5.873l-11.263 55.153c-.758 3.712 2.727 6.886 6.352 5.785l23.415-7.114c3.63-1.102 7.118 2.081 6.35 5.796l-17.899 86.633c-1.12 5.419 6.088 8.374 9.094 3.728l2.008-3.103 110.954-221.428c1.858-3.707-1.346-7.935-5.418-7.15l-39.022 7.532c-3.667.707-6.787-2.708-5.752-6.296l25.469-88.291c1.036-3.594-2.095-7.012-5.766-6.293"/></svg>',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "start",
|
value: "start",
|
||||||
|
|||||||
115
apps/v4/app/(create)/lib/v0.test.ts
Normal file
115
apps/v4/app/(create)/lib/v0.test.ts
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"
|
||||||
|
|
||||||
|
import { DEFAULT_CONFIG } from "@/registry/config"
|
||||||
|
import { buildV0Payload } from "@/app/(create)/lib/v0"
|
||||||
|
|
||||||
|
vi.mock("shadcn/schema", async () => {
|
||||||
|
return await vi.importActual("shadcn/schema")
|
||||||
|
})
|
||||||
|
|
||||||
|
vi.mock("shadcn/utils", async () => {
|
||||||
|
const actual = (await vi.importActual("shadcn/utils")) as {
|
||||||
|
transformFont: unknown
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
transformFont: actual.transformFont,
|
||||||
|
transformIcons: async ({ sourceFile }: { sourceFile: unknown }) =>
|
||||||
|
sourceFile,
|
||||||
|
transformMenu: async ({ sourceFile }: { sourceFile: unknown }) =>
|
||||||
|
sourceFile,
|
||||||
|
transformRender: async ({ sourceFile }: { sourceFile: unknown }) =>
|
||||||
|
sourceFile,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
vi.mock("@/registry/bases/__index__", () => ({
|
||||||
|
Index: {
|
||||||
|
base: {
|
||||||
|
card: {
|
||||||
|
name: "card",
|
||||||
|
type: "registry:ui",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
radix: {
|
||||||
|
card: {
|
||||||
|
name: "card",
|
||||||
|
type: "registry:ui",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
|
||||||
|
describe("buildV0Payload", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
process.env.NEXT_PUBLIC_APP_URL = "http://example.test"
|
||||||
|
|
||||||
|
vi.stubGlobal(
|
||||||
|
"fetch",
|
||||||
|
vi.fn(async (input: string | URL | Request) => {
|
||||||
|
const url =
|
||||||
|
typeof input === "string"
|
||||||
|
? input
|
||||||
|
: input instanceof URL
|
||||||
|
? input.toString()
|
||||||
|
: input.url
|
||||||
|
const name = url.split("/").pop()?.replace(".json", "") ?? "component"
|
||||||
|
|
||||||
|
return new Response(
|
||||||
|
JSON.stringify({
|
||||||
|
name,
|
||||||
|
type: "registry:ui",
|
||||||
|
files: [
|
||||||
|
{
|
||||||
|
path: `registry/base-nova/ui/${name}.tsx`,
|
||||||
|
type: "registry:ui",
|
||||||
|
content: `import * as React from "react"\n\nexport function Component() {\n return <div className="cn-font-heading text-xl" />\n}\n`,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
status: 200,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
vi.unstubAllGlobals()
|
||||||
|
delete process.env.NEXT_PUBLIC_APP_URL
|
||||||
|
})
|
||||||
|
|
||||||
|
it("rewrites cn-font-heading to font-heading when heading inherits the body font", async () => {
|
||||||
|
const payload = await buildV0Payload({
|
||||||
|
...DEFAULT_CONFIG,
|
||||||
|
item: undefined,
|
||||||
|
fontHeading: "inherit",
|
||||||
|
})
|
||||||
|
|
||||||
|
const cardFile = payload.files?.find(
|
||||||
|
(file) => file.target === "components/ui/card.tsx"
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(cardFile?.content).toContain("font-heading")
|
||||||
|
expect(cardFile?.content).not.toContain("cn-font-heading")
|
||||||
|
})
|
||||||
|
|
||||||
|
it("rewrites cn-font-heading to font-heading when a distinct heading font is selected", async () => {
|
||||||
|
const payload = await buildV0Payload({
|
||||||
|
...DEFAULT_CONFIG,
|
||||||
|
item: undefined,
|
||||||
|
fontHeading: "playfair-display",
|
||||||
|
})
|
||||||
|
|
||||||
|
const cardFile = payload.files?.find(
|
||||||
|
(file) => file.target === "components/ui/card.tsx"
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(cardFile?.content).toContain("font-heading")
|
||||||
|
expect(cardFile?.content).not.toContain("cn-font-heading")
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -5,19 +5,28 @@ import {
|
|||||||
type configSchema,
|
type configSchema,
|
||||||
type RegistryItem,
|
type RegistryItem,
|
||||||
} from "shadcn/schema"
|
} from "shadcn/schema"
|
||||||
import { transformIcons, transformMenu, transformRender } from "shadcn/utils"
|
import {
|
||||||
import { Project, ScriptKind } from "ts-morph"
|
transformFont,
|
||||||
|
transformIcons,
|
||||||
|
transformMenu,
|
||||||
|
transformRender,
|
||||||
|
} from "shadcn/utils"
|
||||||
|
import { Project, ScriptKind, type SourceFile } from "ts-morph"
|
||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
buildRegistryBase,
|
buildRegistryBase,
|
||||||
fonts,
|
getBodyFont,
|
||||||
|
getHeadingFont,
|
||||||
|
getInheritedHeadingFontValue,
|
||||||
type DesignSystemConfig,
|
type DesignSystemConfig,
|
||||||
} from "@/registry/config"
|
} from "@/registry/config"
|
||||||
|
|
||||||
const { Index } = await import("@/registry/bases/__index__")
|
const { Index } = await import("@/registry/bases/__index__")
|
||||||
|
|
||||||
const THEME_INLINE = `--font-sans: var(--font-sans);
|
function buildThemeInline(fontHeadingValue: string) {
|
||||||
|
return `--font-sans: var(--font-sans);
|
||||||
|
--font-heading: ${fontHeadingValue};
|
||||||
--font-mono: var(--font-mono);
|
--font-mono: var(--font-mono);
|
||||||
--font-serif: var(--font-serif);
|
--font-serif: var(--font-serif);
|
||||||
--color-background: var(--background);
|
--color-background: var(--background);
|
||||||
@@ -59,6 +68,7 @@ const THEME_INLINE = `--font-sans: var(--font-sans);
|
|||||||
--radius-2xl: calc(var(--radius) * 1.8);
|
--radius-2xl: calc(var(--radius) * 1.8);
|
||||||
--radius-3xl: calc(var(--radius) * 2.2);
|
--radius-3xl: calc(var(--radius) * 2.2);
|
||||||
--radius-4xl: calc(var(--radius) * 2.6);`
|
--radius-4xl: calc(var(--radius) * 2.6);`
|
||||||
|
}
|
||||||
|
|
||||||
// Static file — parsed once at module level.
|
// Static file — parsed once at module level.
|
||||||
const themeProviderFile = registryItemFileSchema.parse({
|
const themeProviderFile = registryItemFileSchema.parse({
|
||||||
@@ -148,7 +158,20 @@ const ALIASES = {
|
|||||||
hooks: "@/hooks",
|
hooks: "@/hooks",
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
const transformers = [transformIcons, transformMenu, transformRender]
|
type V0Transformer = (opts: {
|
||||||
|
filename: string
|
||||||
|
raw: string
|
||||||
|
sourceFile: SourceFile
|
||||||
|
config: z.infer<typeof configSchema>
|
||||||
|
supportedFontMarkers?: string[]
|
||||||
|
}) => Promise<unknown>
|
||||||
|
|
||||||
|
const transformers: V0Transformer[] = [
|
||||||
|
transformIcons as V0Transformer,
|
||||||
|
transformMenu as V0Transformer,
|
||||||
|
transformRender as V0Transformer,
|
||||||
|
transformFont as V0Transformer,
|
||||||
|
]
|
||||||
|
|
||||||
function getStyle(designSystemConfig: DesignSystemConfig) {
|
function getStyle(designSystemConfig: DesignSystemConfig) {
|
||||||
return `${designSystemConfig.base}-${designSystemConfig.style}`
|
return `${designSystemConfig.base}-${designSystemConfig.style}`
|
||||||
@@ -156,10 +179,18 @@ function getStyle(designSystemConfig: DesignSystemConfig) {
|
|||||||
|
|
||||||
export async function buildV0Payload(designSystemConfig: DesignSystemConfig) {
|
export async function buildV0Payload(designSystemConfig: DesignSystemConfig) {
|
||||||
const registryBase = buildRegistryBase(designSystemConfig)
|
const registryBase = buildRegistryBase(designSystemConfig)
|
||||||
|
const normalizedFontHeading =
|
||||||
|
designSystemConfig.fontHeading === designSystemConfig.font
|
||||||
|
? "inherit"
|
||||||
|
: designSystemConfig.fontHeading
|
||||||
|
|
||||||
// Only buildComponentFiles is async — run sync builders directly.
|
// Only buildComponentFiles is async — run sync builders directly.
|
||||||
const globalsCss = buildGlobalsCss(registryBase)
|
const globalsCss = buildGlobalsCss(
|
||||||
const layoutFile = buildLayoutFile(designSystemConfig)
|
registryBase,
|
||||||
|
designSystemConfig.font,
|
||||||
|
normalizedFontHeading
|
||||||
|
)
|
||||||
|
const layoutFile = buildLayoutFile(designSystemConfig, normalizedFontHeading)
|
||||||
const componentFiles = await buildComponentFiles(designSystemConfig)
|
const componentFiles = await buildComponentFiles(designSystemConfig)
|
||||||
|
|
||||||
const dependencies = [...(registryBase.dependencies ?? []), "next-themes"]
|
const dependencies = [...(registryBase.dependencies ?? []), "next-themes"]
|
||||||
@@ -181,7 +212,11 @@ export async function buildV0Payload(designSystemConfig: DesignSystemConfig) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildGlobalsCss(registryBase: RegistryItem) {
|
function buildGlobalsCss(
|
||||||
|
registryBase: RegistryItem,
|
||||||
|
font: DesignSystemConfig["font"],
|
||||||
|
fontHeading: DesignSystemConfig["fontHeading"]
|
||||||
|
) {
|
||||||
const lightVars = Object.entries(registryBase.cssVars?.light ?? {})
|
const lightVars = Object.entries(registryBase.cssVars?.light ?? {})
|
||||||
.map(([key, value]) => ` --${key}: ${value};`)
|
.map(([key, value]) => ` --${key}: ${value};`)
|
||||||
.join("\n")
|
.join("\n")
|
||||||
@@ -194,11 +229,15 @@ function buildGlobalsCss(registryBase: RegistryItem) {
|
|||||||
@import "tw-animate-css";
|
@import "tw-animate-css";
|
||||||
@import "shadcn/tailwind.css";
|
@import "shadcn/tailwind.css";
|
||||||
|
|
||||||
@custom-variant dark (&:is(.dark *));
|
@custom-variant dark (&:is(.dark *));
|
||||||
|
|
||||||
@theme inline {
|
@theme inline {
|
||||||
${THEME_INLINE}
|
${buildThemeInline(
|
||||||
}
|
fontHeading === "inherit"
|
||||||
|
? getInheritedHeadingFontValue(font)
|
||||||
|
: "var(--font-heading)"
|
||||||
|
)}
|
||||||
|
}
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
${lightVars}
|
${lightVars}
|
||||||
@@ -332,18 +371,23 @@ function buildPackageJson(dependencies: string[]) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildLayoutFile(designSystemConfig: DesignSystemConfig) {
|
function buildLayoutFile(
|
||||||
const font = fonts.find(
|
designSystemConfig: DesignSystemConfig,
|
||||||
(font) => font.name === `font-${designSystemConfig.font}`
|
fontHeading: DesignSystemConfig["fontHeading"]
|
||||||
)
|
) {
|
||||||
|
const font = getBodyFont(designSystemConfig.font)
|
||||||
if (!font) {
|
if (!font) {
|
||||||
throw new Error(`Font "${designSystemConfig.font}" not found`)
|
throw new Error(`Font "${designSystemConfig.font}" not found`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const headingFont =
|
||||||
|
fontHeading === "inherit" ? undefined : getHeadingFont(fontHeading)
|
||||||
|
|
||||||
// Derive const name from the font's CSS variable (e.g. --font-sans → fontSans).
|
// Derive const name from the font's CSS variable (e.g. --font-sans → fontSans).
|
||||||
const constName = font.font.variable
|
const constName = font.font.variable
|
||||||
.replace(/^--/, "")
|
.replace(/^--/, "")
|
||||||
.replace(/-./g, (m) => m[1].toUpperCase())
|
.replace(/-./g, (m) => m[1].toUpperCase())
|
||||||
|
const headingConstName = "fontHeading"
|
||||||
|
|
||||||
// Add font-serif or font-mono class to body when needed. Sans is the default.
|
// Add font-serif or font-mono class to body when needed. Sans is the default.
|
||||||
const fontClass =
|
const fontClass =
|
||||||
@@ -354,14 +398,26 @@ function buildLayoutFile(designSystemConfig: DesignSystemConfig) {
|
|||||||
: ""
|
: ""
|
||||||
|
|
||||||
const bodyClassName = fontClass ? `antialiased ${fontClass}` : "antialiased"
|
const bodyClassName = fontClass ? `antialiased ${fontClass}` : "antialiased"
|
||||||
|
const imports = headingFont
|
||||||
|
? Array.from(new Set([font.font.import, headingFont.font.import])).join(
|
||||||
|
", "
|
||||||
|
)
|
||||||
|
: font.font.import
|
||||||
|
const headingDeclaration = headingFont
|
||||||
|
? `\nconst ${headingConstName} = ${headingFont.font.import}({subsets:['latin'],variable:'${headingFont.font.variable}'});\n`
|
||||||
|
: ""
|
||||||
|
const htmlClassName = headingFont
|
||||||
|
? `{${constName}.variable + " " + ${headingConstName}.variable}`
|
||||||
|
: `{${constName}.variable}`
|
||||||
|
|
||||||
const content = dedent`
|
const content = dedent`
|
||||||
import type { Metadata } from "next";
|
import type { Metadata } from "next";
|
||||||
import { ${font.font.import} } from "next/font/google";
|
import { ${imports} } from "next/font/google";
|
||||||
import "./globals.css";
|
import "./globals.css";
|
||||||
import { ThemeProvider } from "@/components/theme-provider";
|
import { ThemeProvider } from "@/components/theme-provider";
|
||||||
|
|
||||||
const ${constName} = ${font.font.import}({subsets:['latin'],variable:'${font.font.variable}'});
|
const ${constName} = ${font.font.import}({subsets:['latin'],variable:'${font.font.variable}'});
|
||||||
|
${headingDeclaration}
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "Create Next App",
|
title: "Create Next App",
|
||||||
@@ -374,7 +430,7 @@ function buildLayoutFile(designSystemConfig: DesignSystemConfig) {
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}>) {
|
}>) {
|
||||||
return (
|
return (
|
||||||
<html lang="en" suppressHydrationWarning className={${constName}.variable}>
|
<html lang="en" suppressHydrationWarning className=${htmlClassName}>
|
||||||
<body
|
<body
|
||||||
className="${bodyClassName}"
|
className="${bodyClassName}"
|
||||||
>
|
>
|
||||||
@@ -401,13 +457,14 @@ async function buildComponentFiles(designSystemConfig: DesignSystemConfig) {
|
|||||||
// Build config once for all components.
|
// Build config once for all components.
|
||||||
const config = buildTransformConfig(designSystemConfig)
|
const config = buildTransformConfig(designSystemConfig)
|
||||||
|
|
||||||
// Fetch UI components and the item component in parallel.
|
// Fetch UI components, the demo, and the item component in parallel.
|
||||||
const [registryItemFiles, itemComponentFile] = await Promise.all([
|
const [registryItemFiles, demoFile, itemComponentFile] = await Promise.all([
|
||||||
Promise.all(
|
Promise.all(
|
||||||
allItemsForBase.map((name) =>
|
allItemsForBase.map((name) =>
|
||||||
getRegistryItemFile(name, designSystemConfig, config)
|
getRegistryItemFile(name, designSystemConfig, config)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
getRegistryItemFile("demo", designSystemConfig, config),
|
||||||
designSystemConfig.item
|
designSystemConfig.item
|
||||||
? getRegistryItemFile(designSystemConfig.item, designSystemConfig, config)
|
? getRegistryItemFile(designSystemConfig.item, designSystemConfig, config)
|
||||||
: null,
|
: null,
|
||||||
@@ -415,29 +472,24 @@ async function buildComponentFiles(designSystemConfig: DesignSystemConfig) {
|
|||||||
|
|
||||||
const files = [...registryItemFiles.filter(Boolean)]
|
const files = [...registryItemFiles.filter(Boolean)]
|
||||||
|
|
||||||
|
// Include the demo component.
|
||||||
|
if (demoFile) {
|
||||||
|
files.push({
|
||||||
|
...demoFile,
|
||||||
|
target: "components/demo.tsx",
|
||||||
|
type: "registry:component",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const pageFile = {
|
const pageFile = {
|
||||||
path: "app/page.tsx",
|
path: "app/page.tsx",
|
||||||
type: "registry:page",
|
type: "registry:page",
|
||||||
target: "app/page.tsx",
|
target: "app/page.tsx",
|
||||||
content: dedent`
|
content: dedent`
|
||||||
import { Button } from "@/components/ui/button"
|
import { Demo } from "@/components/demo"
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
return (
|
return <Demo />
|
||||||
<div className="flex min-h-svh p-6">
|
|
||||||
<div className="flex max-w-md min-w-0 flex-col gap-4 text-sm leading-loose">
|
|
||||||
<div>
|
|
||||||
<h1 className="font-medium">Project ready!</h1>
|
|
||||||
<p>You may now add components and start building.</p>
|
|
||||||
<p>We've already added the button component for you.</p>
|
|
||||||
<Button className="mt-2">Button</Button>
|
|
||||||
</div>
|
|
||||||
<div className="font-mono text-xs text-muted-foreground">
|
|
||||||
(Press <kbd>d</kbd> to toggle dark mode)
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
@@ -557,6 +609,7 @@ async function transformFileContent(
|
|||||||
raw: content,
|
raw: content,
|
||||||
sourceFile,
|
sourceFile,
|
||||||
config,
|
config,
|
||||||
|
supportedFontMarkers: ["cn-font-heading"],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,10 @@
|
|||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import { Label, Pie, PieChart, Sector } from "recharts"
|
import { Label, Pie, PieChart, Sector } from "recharts"
|
||||||
import { type PieSectorDataItem } from "recharts/types/polar/Pie"
|
import type {
|
||||||
|
PieSectorDataItem,
|
||||||
|
PieSectorShapeProps,
|
||||||
|
} from "recharts/types/polar/Pie"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
@@ -77,6 +80,26 @@ export function ChartVisitors() {
|
|||||||
)
|
)
|
||||||
const months = React.useMemo(() => desktopData.map((item) => item.month), [])
|
const months = React.useMemo(() => desktopData.map((item) => item.month), [])
|
||||||
|
|
||||||
|
const renderPieShape = React.useCallback(
|
||||||
|
({ index, outerRadius = 0, ...props }: PieSectorShapeProps) => {
|
||||||
|
if (index === activeIndex) {
|
||||||
|
return (
|
||||||
|
<g>
|
||||||
|
<Sector {...props} outerRadius={outerRadius + 10} />
|
||||||
|
<Sector
|
||||||
|
{...props}
|
||||||
|
outerRadius={outerRadius + 25}
|
||||||
|
innerRadius={outerRadius + 12}
|
||||||
|
/>
|
||||||
|
</g>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return <Sector {...props} outerRadius={outerRadius} />
|
||||||
|
},
|
||||||
|
[activeIndex]
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card data-chart={id}>
|
<Card data-chart={id}>
|
||||||
<ChartStyle id={id} config={chartConfig} />
|
<ChartStyle id={id} config={chartConfig} />
|
||||||
@@ -136,20 +159,7 @@ export function ChartVisitors() {
|
|||||||
nameKey="month"
|
nameKey="month"
|
||||||
innerRadius={60}
|
innerRadius={60}
|
||||||
strokeWidth={5}
|
strokeWidth={5}
|
||||||
activeIndex={activeIndex}
|
shape={renderPieShape}
|
||||||
activeShape={({
|
|
||||||
outerRadius = 0,
|
|
||||||
...props
|
|
||||||
}: PieSectorDataItem) => (
|
|
||||||
<g>
|
|
||||||
<Sector {...props} outerRadius={outerRadius + 10} />
|
|
||||||
<Sector
|
|
||||||
{...props}
|
|
||||||
outerRadius={outerRadius + 25}
|
|
||||||
innerRadius={outerRadius + 12}
|
|
||||||
/>
|
|
||||||
</g>
|
|
||||||
)}
|
|
||||||
>
|
>
|
||||||
<Label
|
<Label
|
||||||
content={({ viewBox }) => {
|
content={({ viewBox }) => {
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ export function ChartBarMixed() {
|
|||||||
cursor={false}
|
cursor={false}
|
||||||
content={<ChartTooltipContent hideLabel />}
|
content={<ChartTooltipContent hideLabel />}
|
||||||
/>
|
/>
|
||||||
<Bar dataKey="visitors" layout="vertical" radius={5} />
|
<Bar dataKey="visitors" radius={5} />
|
||||||
</BarChart>
|
</BarChart>
|
||||||
</ChartContainer>
|
</ChartContainer>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
import { absoluteUrl } from "@/lib/utils"
|
import { absoluteUrl } from "@/lib/utils"
|
||||||
import { getStyle, legacyStyles, type Style } from "@/registry/_legacy-styles"
|
import { getStyle, legacyStyles, type Style } from "@/registry/_legacy-styles"
|
||||||
|
|
||||||
import "@/styles/legacy-themes.css"
|
import "@/app/legacy-themes.css"
|
||||||
|
|
||||||
import { ComponentPreview } from "./component-preview"
|
import { ComponentPreview } from "./component-preview"
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
--breakpoint-3xl: 1600px;
|
--breakpoint-3xl: 1600px;
|
||||||
--breakpoint-4xl: 2000px;
|
--breakpoint-4xl: 2000px;
|
||||||
--font-sans: var(--font-sans);
|
--font-sans: var(--font-sans);
|
||||||
|
--font-heading: var(--font-heading);
|
||||||
--font-mono: var(--font-mono);
|
--font-mono: var(--font-mono);
|
||||||
--radius-sm: calc(var(--radius) * 0.6);
|
--radius-sm: calc(var(--radius) * 0.6);
|
||||||
--radius-md: calc(var(--radius) * 0.8);
|
--radius-md: calc(var(--radius) * 0.8);
|
||||||
@@ -173,6 +174,9 @@
|
|||||||
font-synthesis-weight: none;
|
font-synthesis-weight: none;
|
||||||
text-rendering: optimizeLegibility;
|
text-rendering: optimizeLegibility;
|
||||||
}
|
}
|
||||||
|
.cn-font-heading {
|
||||||
|
@apply font-heading;
|
||||||
|
}
|
||||||
|
|
||||||
[data-slot="layout"] {
|
[data-slot="layout"] {
|
||||||
@apply overscroll-none;
|
@apply overscroll-none;
|
||||||
@@ -13,7 +13,7 @@ import { TooltipProvider as BaseTooltipProvider } from "@/registry/bases/base/ui
|
|||||||
import { Toaster } from "@/registry/bases/radix/ui/sonner"
|
import { Toaster } from "@/registry/bases/radix/ui/sonner"
|
||||||
import { TooltipProvider as RadixTooltipProvider } from "@/registry/bases/radix/ui/tooltip"
|
import { TooltipProvider as RadixTooltipProvider } from "@/registry/bases/radix/ui/tooltip"
|
||||||
|
|
||||||
import "@/styles/globals.css"
|
import "@/app/globals.css"
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: {
|
title: {
|
||||||
|
|||||||
@@ -2,11 +2,6 @@
|
|||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import {
|
|
||||||
Popover,
|
|
||||||
PopoverContent,
|
|
||||||
PopoverTrigger,
|
|
||||||
} from "@/examples/base/ui/popover"
|
|
||||||
import { IconAlertCircle } from "@tabler/icons-react"
|
import { IconAlertCircle } from "@tabler/icons-react"
|
||||||
|
|
||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
@@ -21,6 +16,11 @@ import { DirectionProvider as BaseDirectionProvider } from "@/registry/bases/bas
|
|||||||
import { DirectionProvider as RadixDirectionProvider } from "@/registry/bases/radix/ui/direction"
|
import { DirectionProvider as RadixDirectionProvider } from "@/registry/bases/radix/ui/direction"
|
||||||
import { Button } from "@/registry/new-york-v4/ui/button"
|
import { Button } from "@/registry/new-york-v4/ui/button"
|
||||||
import { Separator } from "@/registry/new-york-v4/ui/separator"
|
import { Separator } from "@/registry/new-york-v4/ui/separator"
|
||||||
|
import {
|
||||||
|
Popover,
|
||||||
|
PopoverContent,
|
||||||
|
PopoverTrigger,
|
||||||
|
} from "@/styles/base-nova/ui/popover"
|
||||||
|
|
||||||
export function ComponentPreviewTabs({
|
export function ComponentPreviewTabs({
|
||||||
className,
|
className,
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
@@ -8,9 +10,7 @@ import {
|
|||||||
SelectItem,
|
SelectItem,
|
||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
SelectValue,
|
SelectValue,
|
||||||
} from "@/examples/base/ui/select"
|
} from "@/styles/base-nova/ui/select"
|
||||||
|
|
||||||
import { cn } from "@/lib/utils"
|
|
||||||
|
|
||||||
export type Language = "en" | "ar" | "he"
|
export type Language = "en" | "ar" | "he"
|
||||||
|
|
||||||
|
|||||||
@@ -7,12 +7,6 @@ import { useTheme } from "next-themes"
|
|||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
import { useMetaColor } from "@/hooks/use-meta-color"
|
import { useMetaColor } from "@/hooks/use-meta-color"
|
||||||
import { Button } from "@/registry/new-york-v4/ui/button"
|
import { Button } from "@/registry/new-york-v4/ui/button"
|
||||||
import { Kbd } from "@/registry/new-york-v4/ui/kbd"
|
|
||||||
import {
|
|
||||||
Tooltip,
|
|
||||||
TooltipContent,
|
|
||||||
TooltipTrigger,
|
|
||||||
} from "@/registry/new-york-v4/ui/tooltip"
|
|
||||||
|
|
||||||
export const DARK_MODE_FORWARD_TYPE = "dark-mode-forward"
|
export const DARK_MODE_FORWARD_TYPE = "dark-mode-forward"
|
||||||
|
|
||||||
@@ -35,40 +29,33 @@ export function ModeSwitcher({
|
|||||||
}, [resolvedTheme, setTheme])
|
}, [resolvedTheme, setTheme])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip>
|
<Button
|
||||||
<TooltipTrigger asChild>
|
variant={variant}
|
||||||
<Button
|
size="icon"
|
||||||
variant={variant}
|
className={cn("group/toggle extend-touch-target size-8", className)}
|
||||||
size="icon"
|
onClick={toggleTheme}
|
||||||
className={cn("group/toggle extend-touch-target size-8", className)}
|
>
|
||||||
onClick={toggleTheme}
|
<svg
|
||||||
>
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
<svg
|
width="24"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
height="24"
|
||||||
width="24"
|
viewBox="0 0 24 24"
|
||||||
height="24"
|
fill="none"
|
||||||
viewBox="0 0 24 24"
|
stroke="currentColor"
|
||||||
fill="none"
|
strokeWidth="2"
|
||||||
stroke="currentColor"
|
strokeLinecap="round"
|
||||||
strokeWidth="2"
|
strokeLinejoin="round"
|
||||||
strokeLinecap="round"
|
className="size-4.5"
|
||||||
strokeLinejoin="round"
|
>
|
||||||
className="size-4.5"
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
>
|
<path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0" />
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
<path d="M12 3l0 18" />
|
||||||
<path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0" />
|
<path d="M12 9l4.65 -4.65" />
|
||||||
<path d="M12 3l0 18" />
|
<path d="M12 14.3l7.37 -7.37" />
|
||||||
<path d="M12 9l4.65 -4.65" />
|
<path d="M12 19.6l8.85 -8.85" />
|
||||||
<path d="M12 14.3l7.37 -7.37" />
|
</svg>
|
||||||
<path d="M12 19.6l8.85 -8.85" />
|
<span className="sr-only">Toggle theme</span>
|
||||||
</svg>
|
</Button>
|
||||||
<span className="sr-only">Toggle theme</span>
|
|
||||||
</Button>
|
|
||||||
</TooltipTrigger>
|
|
||||||
<TooltipContent className="flex items-center gap-2 pr-1">
|
|
||||||
Toggle Mode <Kbd>D</Kbd>
|
|
||||||
</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
import { Button } from "@/registry/new-york-v4/ui/button"
|
import { Button } from "@/styles/base-nova/ui/button"
|
||||||
|
|
||||||
export function OpenInV0Cta({ className }: React.ComponentProps<"div">) {
|
export function OpenInV0Cta({ className }: React.ComponentProps<"div">) {
|
||||||
return (
|
return (
|
||||||
@@ -19,7 +19,7 @@ export function OpenInV0Cta({ className }: React.ComponentProps<"div">) {
|
|||||||
Vercel provides tools and infrastructure to deploy apps and features at
|
Vercel provides tools and infrastructure to deploy apps and features at
|
||||||
scale.
|
scale.
|
||||||
</div>
|
</div>
|
||||||
<Button size="sm" className="mt-2 w-fit">
|
<Button variant="outline" size="sm" className="mt-2 w-fit">
|
||||||
Deploy Now
|
Deploy Now
|
||||||
</Button>
|
</Button>
|
||||||
<a
|
<a
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import { Button } from "@/examples/radix/ui/button"
|
|
||||||
import { PlusSignIcon } from "@hugeicons/core-free-icons"
|
import { PlusSignIcon } from "@hugeicons/core-free-icons"
|
||||||
import { HugeiconsIcon } from "@hugeicons/react"
|
import { HugeiconsIcon } from "@hugeicons/react"
|
||||||
|
|
||||||
@@ -14,6 +13,7 @@ import { MobileNav } from "@/components/mobile-nav"
|
|||||||
import { ModeSwitcher } from "@/components/mode-switcher"
|
import { ModeSwitcher } from "@/components/mode-switcher"
|
||||||
import { SiteConfig } from "@/components/site-config"
|
import { SiteConfig } from "@/components/site-config"
|
||||||
import { Separator } from "@/registry/new-york-v4/ui/separator"
|
import { Separator } from "@/registry/new-york-v4/ui/separator"
|
||||||
|
import { Button } from "@/styles/radix-nova/ui/button"
|
||||||
import { ProjectForm } from "@/app/(create)/components/project-form"
|
import { ProjectForm } from "@/app/(create)/components/project-form"
|
||||||
import { V0Button } from "@/app/(create)/components/v0-button"
|
import { V0Button } from "@/app/(create)/components/v0-button"
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { Label } from "@/examples/base/ui/label"
|
import { THEMES } from "@/lib/themes"
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
import { useThemeConfig } from "@/components/active-theme"
|
||||||
|
import { Label } from "@/styles/base-nova/ui/label"
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
@@ -9,11 +12,7 @@ import {
|
|||||||
SelectLabel,
|
SelectLabel,
|
||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
SelectValue,
|
SelectValue,
|
||||||
} from "@/examples/base/ui/select"
|
} from "@/styles/base-nova/ui/select"
|
||||||
|
|
||||||
import { THEMES } from "@/lib/themes"
|
|
||||||
import { cn } from "@/lib/utils"
|
|
||||||
import { useThemeConfig } from "@/components/active-theme"
|
|
||||||
|
|
||||||
import { CopyCodeButton } from "./theme-customizer"
|
import { CopyCodeButton } from "./theme-customizer"
|
||||||
|
|
||||||
|
|||||||
@@ -74,21 +74,21 @@ Path to the CSS file that imports Tailwind CSS into your project.
|
|||||||
|
|
||||||
### tailwind.baseColor
|
### tailwind.baseColor
|
||||||
|
|
||||||
This is used to generate the default color palette for your components. **This cannot be changed after initialization.**
|
This is used to generate the default theme tokens for your components. **This cannot be changed after initialization.**
|
||||||
|
|
||||||
```json title="components.json"
|
```json title="components.json"
|
||||||
{
|
{
|
||||||
"tailwind": {
|
"tailwind": {
|
||||||
"baseColor": "gray" | "neutral" | "slate" | "stone" | "zinc" | "mauve" | "olive" | "mist" | "taupe"
|
"baseColor": "neutral" | "stone" | "zinc" | "mauve" | "olive" | "mist" | "taupe"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### tailwind.cssVariables
|
### tailwind.cssVariables
|
||||||
|
|
||||||
You can choose between using CSS variables or Tailwind CSS utility classes for theming.
|
We use and recommend CSS variables for theming.
|
||||||
|
|
||||||
To use utility classes for theming set `tailwind.cssVariables` to `false`. For CSS variables, set `tailwind.cssVariables` to `true`.
|
Set `tailwind.cssVariables` to `true` to generate semantic theme tokens like `background`, `foreground`, and `primary`. Set it to `false` to generate inline Tailwind color utilities instead.
|
||||||
|
|
||||||
```json title="components.json"
|
```json title="components.json"
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ description: Every component recreated in Figma. With customizable props, typogr
|
|||||||
|
|
||||||
## Paid
|
## Paid
|
||||||
|
|
||||||
- [shadcn/ui kit](https://shadcndesign.com) by [ Matt Wierzbicki](https://x.com/matsugfx) - A premium, always up-to-date UI kit for Figma - shadcn/ui compatible and optimized for smooth design-to-dev handoff.
|
- [shadcn/ui kit](https://shadcndesign.com) by [Matt Wierzbicki](https://x.com/matsugfx) - A premium, always up-to-date UI kit for Figma - shadcn/ui compatible and optimized for smooth design-to-dev handoff.
|
||||||
- [Shadcraft UI Kit](https://shadcraft.com) - The most advanced shadcn-compatible kit with instant theming via [tweakcn](https://tweakcn.com), a pro library of components and templates, and complete coverage of shadcn components and blocks.
|
- [shadcncraft Design System](https://shadcncraft.com) - Production-ready shadcn/ui kit with Pro React blocks and 1:1 Figma alignment. Design and ship faster with tweakcn theming, AI-assisted workflows, and Figma to React export, built for real product UIs.
|
||||||
- [shadcn/studio UI Kit](https://shadcnstudio.com/figma) - Accelerate design & development with a shadcn/ui compatible Figma kit with updated components, 550+ blocks, 10+ templates, 20+ themes, and an AI tool that converts designs into shadcn/ui code.
|
- [shadcn/studio UI Kit](https://shadcnstudio.com/figma) - Accelerate design & development with a shadcn/ui compatible Figma kit with updated components, 550+ blocks, 10+ templates, 20+ themes, and an AI tool that converts designs into shadcn/ui code.
|
||||||
- [Shadcnblocks.com](https://www.shadcnblocks.com) - A Premium Shadcn Figma UI Kit with components, 500+ pro blocks, shadcn theme variables, light/dark mode and Figma MCP ready.
|
- [Shadcnblocks.com](https://www.shadcnblocks.com) - A Premium Shadcn Figma UI Kit with components, 500+ pro blocks, shadcn theme variables, light/dark mode and Figma MCP ready.
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ shadcn/ui hands you the actual component code. You have full control to customiz
|
|||||||
|
|
||||||
_In a typical library, if you need to change a button’s behavior, you have to override styles or wrap the component. With shadcn/ui, you simply edit the button code directly._
|
_In a typical library, if you need to change a button’s behavior, you have to override styles or wrap the component. With shadcn/ui, you simply edit the button code directly._
|
||||||
|
|
||||||
<Accordion collapsible>
|
<Accordion type="single" collapsible>
|
||||||
<AccordionItem value="faq-1" className="border-none">
|
<AccordionItem value="faq-1" className="border-none">
|
||||||
<AccordionTrigger>
|
<AccordionTrigger>
|
||||||
How do I pull upstream updates in an Open Code approach?
|
How do I pull upstream updates in an Open Code approach?
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ title: Your project is ready!
|
|||||||
description: You've created a new project with shadcn/ui.
|
description: You've created a new project with shadcn/ui.
|
||||||
---
|
---
|
||||||
|
|
||||||
Here's a few things you can do to get started building with shadcn/ui.
|
Here are a few things you can do to get started building with shadcn/ui.
|
||||||
|
|
||||||
## Add Components
|
## Add Components
|
||||||
|
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ The process for adding components is the same as above. Select a flag to resolve
|
|||||||
|
|
||||||
## Upgrade Status
|
## Upgrade Status
|
||||||
|
|
||||||
To make it easy for you track the progress of the upgrade, I've created a table below with React 19 support status for the shadcn/ui dependencies.
|
To make it easy for you to track the progress of the upgrade, here is a table with the React 19 support status for the shadcn/ui dependencies.
|
||||||
|
|
||||||
- ✅ - Works with React 19 using npm, pnpm, and bun.
|
- ✅ - Works with React 19 using npm, pnpm, and bun.
|
||||||
- 🚧 - Works with React 19 using pnpm and bun. Requires flag for npm. PR is in progress.
|
- 🚧 - Works with React 19 using pnpm and bun. Requires flag for npm. PR is in progress.
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ Here's how you do it:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
This change makes it much simpler to access your theme variables in both utility classes and outside of CSS for eg. using color values in JavaScript.
|
This change makes it much simpler to access your theme variables in both utility classes and outside of CSS, e.g. using color values in JavaScript.
|
||||||
|
|
||||||
### 3. Update colors for charts
|
### 3. Update colors for charts
|
||||||
|
|
||||||
@@ -281,7 +281,7 @@ function AccordionItem({
|
|||||||
|
|
||||||
We've deprecated `tailwindcss-animate` in favor of `tw-animate-css`.
|
We've deprecated `tailwindcss-animate` in favor of `tw-animate-css`.
|
||||||
|
|
||||||
New project will have `tw-animate-css` installed by default.
|
New projects will have `tw-animate-css` installed by default.
|
||||||
|
|
||||||
For existing projects, follow the steps below to migrate.
|
For existing projects, follow the steps below to migrate.
|
||||||
|
|
||||||
|
|||||||
@@ -1,46 +1,48 @@
|
|||||||
---
|
---
|
||||||
title: Theming
|
title: Theming
|
||||||
description: Using CSS Variables and color utilities for theming.
|
description: Using CSS variables and theme tokens.
|
||||||
---
|
---
|
||||||
|
|
||||||
You can choose between using CSS variables (recommended) or utility classes for theming.
|
<Callout>
|
||||||
|
|
||||||
## CSS Variables
|
Want to build your theme visually? Use [shadcn/create](/create) to preview colors, radius, fonts, and icons, then generate a preset for your project.
|
||||||
|
|
||||||
|
</Callout>
|
||||||
|
|
||||||
|
We use and recommend CSS variables for theming.
|
||||||
|
|
||||||
|
This gives you semantic theme tokens like `background`, `foreground`, and `primary` that components use by default. Override those tokens in your CSS to change the look of your app without rewriting component classes.
|
||||||
|
|
||||||
```tsx /bg-background/ /text-foreground/
|
```tsx /bg-background/ /text-foreground/
|
||||||
<div className="bg-background text-foreground" />
|
<div className="bg-background text-foreground" />
|
||||||
```
|
```
|
||||||
|
|
||||||
To use CSS variables for theming set `tailwind.cssVariables` to `true` in your `components.json` file.
|
To use CSS variables for theming, set `tailwind.cssVariables` to `true` in your `components.json` file. This is the default.
|
||||||
|
|
||||||
```json {8} title="components.json" showLineNumbers
|
```json {8} title="components.json" showLineNumbers
|
||||||
{
|
{
|
||||||
"style": "new-york",
|
"style": "base-nova",
|
||||||
"rsc": true,
|
"rsc": true,
|
||||||
"tailwind": {
|
"tailwind": {
|
||||||
"config": "",
|
"config": "",
|
||||||
"css": "app/globals.css",
|
"css": "app/globals.css",
|
||||||
"baseColor": "neutral",
|
"baseColor": "neutral",
|
||||||
"cssVariables": true
|
"cssVariables": true
|
||||||
},
|
}
|
||||||
"aliases": {
|
|
||||||
"components": "@/components",
|
|
||||||
"utils": "@/lib/utils",
|
|
||||||
"ui": "@/components/ui",
|
|
||||||
"lib": "@/lib",
|
|
||||||
"hooks": "@/hooks"
|
|
||||||
},
|
|
||||||
"iconLibrary": "lucide"
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Convention
|
Tailwind maps these tokens into utilities like `bg-background`, `text-foreground`, `border-border`, and `ring-ring`.
|
||||||
|
|
||||||
We use a simple `background` and `foreground` convention for colors. The `background` variable is used for the background color of the component and the `foreground` variable is used for the text color.
|
Dark mode works by overriding the same tokens inside a `.dark` selector. See the [dark mode docs](/docs/dark-mode/next) for adding a theme provider and toggling the `.dark` class.
|
||||||
|
|
||||||
|
## Token Convention
|
||||||
|
|
||||||
|
We use semantic background and foreground pairs. The base token controls the surface color and the `-foreground` token controls the text and icon color that sits on that surface.
|
||||||
|
|
||||||
<Callout className="mt-4">
|
<Callout className="mt-4">
|
||||||
|
|
||||||
The `background` suffix is omitted when the variable is used for the background color of the component.
|
The background suffix is omitted for the surface token. For example, `primary` pairs with `primary-foreground`.
|
||||||
|
|
||||||
</Callout>
|
</Callout>
|
||||||
|
|
||||||
@@ -57,11 +59,148 @@ The `background` color of the following component will be `var(--primary)` and t
|
|||||||
<div className="bg-primary text-primary-foreground">Hello</div>
|
<div className="bg-primary text-primary-foreground">Hello</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
## List of variables
|
## Theme Tokens
|
||||||
|
|
||||||
Here's the list of variables available for customization:
|
These tokens live in your CSS file under `:root` and `.dark`.
|
||||||
|
|
||||||
|
| Token | What it controls | Used by |
|
||||||
|
| ------------------------------------------------ | ------------------------------------------------------ | ---------------------------------------------------------------------------- |
|
||||||
|
| `background` / `foreground` | The default app background and text color. | The page shell, page sections, and default text. |
|
||||||
|
| `card` / `card-foreground` | Elevated surfaces and the content inside them. | `Card`, dashboard panels, settings panels. |
|
||||||
|
| `popover` / `popover-foreground` | Floating surfaces and the content inside them. | `Popover`, `DropdownMenu`, `ContextMenu`, and other overlays. |
|
||||||
|
| `primary` / `primary-foreground` | High-emphasis actions and brand surfaces. | Default `Button`, selected states, badges, and active accents. |
|
||||||
|
| `secondary` / `secondary-foreground` | Lower-emphasis filled actions and supporting surfaces. | Secondary buttons, secondary badges, and supporting UI. |
|
||||||
|
| `muted` / `muted-foreground` | Subtle surfaces and lower-emphasis content. | Descriptions, placeholders, empty states, helper text, and subdued surfaces. |
|
||||||
|
| `accent` / `accent-foreground` | Interactive hover, focus, and active surfaces. | Ghost buttons, menu highlight states, hovered rows, and selected items. |
|
||||||
|
| `destructive` | Destructive actions and error emphasis. | Destructive buttons, invalid states, and destructive menu items. |
|
||||||
|
| `border` | Default borders and separators. | Cards, menus, tables, separators, and layout dividers. |
|
||||||
|
| `input` | Form control borders and input surface treatment. | `Input`, `Textarea`, `Select`, and outline-style controls. |
|
||||||
|
| `ring` | Focus rings and outlines. | Buttons, inputs, checkboxes, menus, and other focusable controls. |
|
||||||
|
| `chart-1` ... `chart-5` | The default chart palette. | Charts and chart-driven dashboard blocks. |
|
||||||
|
| `sidebar` / `sidebar-foreground` | The base sidebar surface and default sidebar text. | The `Sidebar` container and its default content. |
|
||||||
|
| `sidebar-primary` / `sidebar-primary-foreground` | High-emphasis actions inside the sidebar. | Active items, icon tiles, badges, and sidebar CTAs. |
|
||||||
|
| `sidebar-accent` / `sidebar-accent-foreground` | Hover and selected states inside the sidebar. | Sidebar menu hover states, open items, and interactive rows. |
|
||||||
|
| `sidebar-border` | Sidebar-specific borders and separators. | Sidebar headers, groups, and internal dividers. |
|
||||||
|
| `sidebar-ring` | Sidebar-specific focus rings. | Focused controls inside the sidebar. |
|
||||||
|
| `radius` | The base corner radius scale. | Cards, inputs, buttons, popovers, and the derived `radius-*` tokens. |
|
||||||
|
|
||||||
|
<Callout className="mt-4">
|
||||||
|
|
||||||
|
The chart tokens are covered in more detail in the [Chart theming docs](/docs/components/chart#theming).
|
||||||
|
|
||||||
|
</Callout>
|
||||||
|
|
||||||
|
## Radius Scale
|
||||||
|
|
||||||
|
`--radius` is the base radius token for your theme.
|
||||||
|
|
||||||
|
We derive a small radius scale from it so components can use consistent corner sizes while still sharing a single source of truth.
|
||||||
|
|
||||||
```css title="app/globals.css" showLineNumbers
|
```css title="app/globals.css" showLineNumbers
|
||||||
|
@theme inline {
|
||||||
|
--radius-sm: calc(var(--radius) * 0.6);
|
||||||
|
--radius-md: calc(var(--radius) * 0.8);
|
||||||
|
--radius-lg: var(--radius);
|
||||||
|
--radius-xl: calc(var(--radius) * 1.4);
|
||||||
|
--radius-2xl: calc(var(--radius) * 1.8);
|
||||||
|
--radius-3xl: calc(var(--radius) * 2.2);
|
||||||
|
--radius-4xl: calc(var(--radius) * 2.6);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This means:
|
||||||
|
|
||||||
|
- `radius-lg` is the base value.
|
||||||
|
- Smaller radii scale down from `--radius`.
|
||||||
|
- Larger radii scale up from `--radius`.
|
||||||
|
- Changing `--radius` updates the entire radius scale.
|
||||||
|
|
||||||
|
## Adding New Tokens
|
||||||
|
|
||||||
|
To add a new token, define it under `:root` and `.dark`, then expose it to Tailwind with `@theme inline`.
|
||||||
|
|
||||||
|
```css title="app/globals.css" showLineNumbers
|
||||||
|
:root {
|
||||||
|
--warning: oklch(0.84 0.16 84);
|
||||||
|
--warning-foreground: oklch(0.28 0.07 46);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dark {
|
||||||
|
--warning: oklch(0.41 0.11 46);
|
||||||
|
--warning-foreground: oklch(0.99 0.02 95);
|
||||||
|
}
|
||||||
|
|
||||||
|
@theme inline {
|
||||||
|
--color-warning: var(--warning);
|
||||||
|
--color-warning-foreground: var(--warning-foreground);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
You can now use `bg-warning` and `text-warning-foreground` in your components.
|
||||||
|
|
||||||
|
```tsx /bg-warning/ /text-warning-foreground/
|
||||||
|
<div className="bg-warning text-warning-foreground" />
|
||||||
|
```
|
||||||
|
|
||||||
|
## Base Colors
|
||||||
|
|
||||||
|
`tailwind.baseColor` controls the default token values generated for your project when you run `init` or use a preset.
|
||||||
|
|
||||||
|
The available base colors are: **Neutral**, **Stone**, **Zinc**, **Mauve**, **Olive**, **Mist**, and **Taupe**.
|
||||||
|
|
||||||
|
## Default Theme CSS
|
||||||
|
|
||||||
|
The following is the full default `neutral` theme scaffold. Copy it into your global CSS file and adjust the tokens as needed.
|
||||||
|
|
||||||
|
<CodeCollapsibleWrapper>
|
||||||
|
|
||||||
|
```css showLineNumbers title="app/globals.css"
|
||||||
|
@import "tailwindcss";
|
||||||
|
@import "shadcn/tailwind.css";
|
||||||
|
|
||||||
|
@custom-variant dark (&:is(.dark *));
|
||||||
|
|
||||||
|
@theme inline {
|
||||||
|
--color-background: var(--background);
|
||||||
|
--color-foreground: var(--foreground);
|
||||||
|
--color-card: var(--card);
|
||||||
|
--color-card-foreground: var(--card-foreground);
|
||||||
|
--color-popover: var(--popover);
|
||||||
|
--color-popover-foreground: var(--popover-foreground);
|
||||||
|
--color-primary: var(--primary);
|
||||||
|
--color-primary-foreground: var(--primary-foreground);
|
||||||
|
--color-secondary: var(--secondary);
|
||||||
|
--color-secondary-foreground: var(--secondary-foreground);
|
||||||
|
--color-muted: var(--muted);
|
||||||
|
--color-muted-foreground: var(--muted-foreground);
|
||||||
|
--color-accent: var(--accent);
|
||||||
|
--color-accent-foreground: var(--accent-foreground);
|
||||||
|
--color-destructive: var(--destructive);
|
||||||
|
--color-border: var(--border);
|
||||||
|
--color-input: var(--input);
|
||||||
|
--color-ring: var(--ring);
|
||||||
|
--color-chart-1: var(--chart-1);
|
||||||
|
--color-chart-2: var(--chart-2);
|
||||||
|
--color-chart-3: var(--chart-3);
|
||||||
|
--color-chart-4: var(--chart-4);
|
||||||
|
--color-chart-5: var(--chart-5);
|
||||||
|
--color-sidebar: var(--sidebar);
|
||||||
|
--color-sidebar-foreground: var(--sidebar-foreground);
|
||||||
|
--color-sidebar-primary: var(--sidebar-primary);
|
||||||
|
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
||||||
|
--color-sidebar-accent: var(--sidebar-accent);
|
||||||
|
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
||||||
|
--color-sidebar-border: var(--sidebar-border);
|
||||||
|
--color-sidebar-ring: var(--sidebar-ring);
|
||||||
|
--radius-sm: calc(var(--radius) * 0.6);
|
||||||
|
--radius-md: calc(var(--radius) * 0.8);
|
||||||
|
--radius-lg: var(--radius);
|
||||||
|
--radius-xl: calc(var(--radius) * 1.4);
|
||||||
|
--radius-2xl: calc(var(--radius) * 1.8);
|
||||||
|
--radius-3xl: calc(var(--radius) * 2.2);
|
||||||
|
--radius-4xl: calc(var(--radius) * 2.6);
|
||||||
|
}
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--radius: 0.625rem;
|
--radius: 0.625rem;
|
||||||
--background: oklch(1 0 0);
|
--background: oklch(1 0 0);
|
||||||
@@ -79,7 +218,6 @@ Here's the list of variables available for customization:
|
|||||||
--accent: oklch(0.97 0 0);
|
--accent: oklch(0.97 0 0);
|
||||||
--accent-foreground: oklch(0.205 0 0);
|
--accent-foreground: oklch(0.205 0 0);
|
||||||
--destructive: oklch(0.577 0.245 27.325);
|
--destructive: oklch(0.577 0.245 27.325);
|
||||||
--destructive-foreground: oklch(0.985 0 0);
|
|
||||||
--border: oklch(0.922 0 0);
|
--border: oklch(0.922 0 0);
|
||||||
--input: oklch(0.922 0 0);
|
--input: oklch(0.922 0 0);
|
||||||
--ring: oklch(0.708 0 0);
|
--ring: oklch(0.708 0 0);
|
||||||
@@ -103,7 +241,7 @@ Here's the list of variables available for customization:
|
|||||||
--foreground: oklch(0.985 0 0);
|
--foreground: oklch(0.985 0 0);
|
||||||
--card: oklch(0.205 0 0);
|
--card: oklch(0.205 0 0);
|
||||||
--card-foreground: oklch(0.985 0 0);
|
--card-foreground: oklch(0.985 0 0);
|
||||||
--popover: oklch(0.269 0 0);
|
--popover: oklch(0.205 0 0);
|
||||||
--popover-foreground: oklch(0.985 0 0);
|
--popover-foreground: oklch(0.985 0 0);
|
||||||
--primary: oklch(0.922 0 0);
|
--primary: oklch(0.922 0 0);
|
||||||
--primary-foreground: oklch(0.205 0 0);
|
--primary-foreground: oklch(0.205 0 0);
|
||||||
@@ -111,10 +249,9 @@ Here's the list of variables available for customization:
|
|||||||
--secondary-foreground: oklch(0.985 0 0);
|
--secondary-foreground: oklch(0.985 0 0);
|
||||||
--muted: oklch(0.269 0 0);
|
--muted: oklch(0.269 0 0);
|
||||||
--muted-foreground: oklch(0.708 0 0);
|
--muted-foreground: oklch(0.708 0 0);
|
||||||
--accent: oklch(0.371 0 0);
|
--accent: oklch(0.269 0 0);
|
||||||
--accent-foreground: oklch(0.985 0 0);
|
--accent-foreground: oklch(0.985 0 0);
|
||||||
--destructive: oklch(0.704 0.191 22.216);
|
--destructive: oklch(0.704 0.191 22.216);
|
||||||
--destructive-foreground: oklch(0.985 0 0);
|
|
||||||
--border: oklch(1 0 0 / 10%);
|
--border: oklch(1 0 0 / 10%);
|
||||||
--input: oklch(1 0 0 / 15%);
|
--input: oklch(1 0 0 / 15%);
|
||||||
--ring: oklch(0.556 0 0);
|
--ring: oklch(0.556 0 0);
|
||||||
@@ -130,43 +267,38 @@ Here's the list of variables available for customization:
|
|||||||
--sidebar-accent: oklch(0.269 0 0);
|
--sidebar-accent: oklch(0.269 0 0);
|
||||||
--sidebar-accent-foreground: oklch(0.985 0 0);
|
--sidebar-accent-foreground: oklch(0.985 0 0);
|
||||||
--sidebar-border: oklch(1 0 0 / 10%);
|
--sidebar-border: oklch(1 0 0 / 10%);
|
||||||
--sidebar-ring: oklch(0.439 0 0);
|
--sidebar-ring: oklch(0.556 0 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@layer base {
|
||||||
|
* {
|
||||||
|
@apply border-border outline-ring/50;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
@apply bg-background text-foreground;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Adding new colors
|
</CodeCollapsibleWrapper>
|
||||||
|
|
||||||
To add new colors, you need to add them to your CSS file under the `:root` and `dark` pseudo-classes. Then, use the `@theme inline` directive to make the colors available as CSS variables.
|
## Without CSS Variables
|
||||||
|
|
||||||
```css title="app/globals.css" showLineNumbers
|
If you do not want to use CSS variables, the CLI can generate components with inline Tailwind color utilities instead.
|
||||||
:root {
|
|
||||||
--warning: oklch(0.84 0.16 84);
|
|
||||||
--warning-foreground: oklch(0.28 0.07 46);
|
|
||||||
}
|
|
||||||
|
|
||||||
.dark {
|
```bash
|
||||||
--warning: oklch(0.41 0.11 46);
|
npx shadcn@latest init --no-css-variables
|
||||||
--warning-foreground: oklch(0.99 0.02 95);
|
|
||||||
}
|
|
||||||
|
|
||||||
@theme inline {
|
|
||||||
--color-warning: var(--warning);
|
|
||||||
--color-warning-foreground: var(--warning-foreground);
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
You can now use the `warning` utility class in your components.
|
This sets `tailwind.cssVariables` to `false` in your `components.json` file.
|
||||||
|
|
||||||
```tsx /bg-warning/ /text-warning-foreground/
|
```tsx /bg-zinc-950/ /text-zinc-50/ /dark:bg-white/ /dark:text-zinc-950/
|
||||||
<div className="bg-warning text-warning-foreground" />
|
<div className="bg-zinc-950 text-zinc-50 dark:bg-white dark:text-zinc-950" />
|
||||||
```
|
```
|
||||||
|
|
||||||
## Other color formats
|
<Callout className="mt-4">
|
||||||
|
|
||||||
See the [Tailwind CSS documentation](https://tailwindcss.com/docs/colors) for more information on using colors in Tailwind CSS.
|
This is an installation-time choice. To switch an existing project, delete and re-install your components.
|
||||||
|
|
||||||
## Base Colors
|
</Callout>
|
||||||
|
|
||||||
The available base colors are: **Neutral**, **Stone**, **Zinc**, **Mauve**, **Olive**, **Mist**, and **Taupe**.
|
|
||||||
|
|
||||||
You can set the base color when initializing your project using a preset or by updating the `baseColor` field in your `components.json` file.
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ date: 2024-03-22
|
|||||||
|
|
||||||
One of the most requested features since launch has been layouts: admin dashboards with sidebar, marketing page sections, cards and more.
|
One of the most requested features since launch has been layouts: admin dashboards with sidebar, marketing page sections, cards and more.
|
||||||
|
|
||||||
**Today, we're launching [**Blocks**](/blocks)**.
|
**Today, we're launching [Blocks](/blocks).**
|
||||||
|
|
||||||
<a href="/blocks">
|
<a href="/blocks">
|
||||||
<Image
|
<Image
|
||||||
|
|||||||
@@ -22,4 +22,4 @@ A fully featured input OTP component. It has support for numeric and alphanumeri
|
|||||||
|
|
||||||
[Read the docs](/docs/components/input-otp)
|
[Read the docs](/docs/components/input-otp)
|
||||||
|
|
||||||
If you have a [v0](https://v0.dev), the new components are available for generation.
|
If you have a [v0](https://v0.dev) account, the new components are available for generation.
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ The new CLI is now available. It's a complete rewrite with a lot of new features
|
|||||||
|
|
||||||
This is a major step towards distributing code that you and your LLMs can access and use.
|
This is a major step towards distributing code that you and your LLMs can access and use.
|
||||||
|
|
||||||
1. First up, the cli now has support for all major React framework out of the box. Next.js, Remix, Vite and Laravel. And when you init into a new app, we update your existing Tailwind files instead of overriding.
|
1. First up, the CLI now has support for all major React frameworks out of the box. Next.js, Remix, Vite and Laravel. And when you init into a new app, we update your existing Tailwind files instead of overriding.
|
||||||
2. A component now ship its own dependencies. Take the accordion for example, it can define its Tailwind keyframes. When you add it to your project, we'll update your tailwind.config.ts file accordingly.
|
2. A component now ships its own dependencies. Take the accordion for example, it can define its Tailwind keyframes. When you add it to your project, we'll update your tailwind.config.ts file accordingly.
|
||||||
3. You can also install remote components using url. `npx shadcn add https://acme.com/registry/navbar.json`.
|
3. You can also install remote components using url. `npx shadcn add https://acme.com/registry/navbar.json`.
|
||||||
4. We have also improve the init command. It does framework detection and can even init a brand new Next.js app in one command. `npx shadcn init`.
|
4. We have also improved the init command. It does framework detection and can even init a brand new Next.js app in one command. `npx shadcn init`.
|
||||||
5. We have created a new schema that you can use to ship your own component registry. And since it has support for urls, you can even use it to distribute private components.
|
5. We have created a new schema that you can use to ship your own component registry. And since it has support for urls, you can even use it to distribute private components.
|
||||||
6. And a few more updates like better error handling and monorepo support.
|
6. And a few more updates like better error handling and monorepo support.
|
||||||
|
|
||||||
@@ -42,4 +42,4 @@ To update an existing project to use the new CLI, update your `components.json`
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
If you're using a different import alias prefix eg `~`, replace `@` with your prefix.
|
If you're using a different import alias prefix, e.g. `~`, replace `@` with your prefix.
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
---
|
---
|
||||||
title: March 2025 - Cross-framework Route Support
|
title: April 2025 - Cross-framework Route Support
|
||||||
description: The shadcn CLI can now auto-detect your framework and adapts routes for you.
|
description: The shadcn CLI can now auto-detect your framework and adapt routes for you.
|
||||||
date: 2025-04-09
|
date: 2025-04-09
|
||||||
---
|
---
|
||||||
|
|
||||||
The shadcn CLI can now auto-detect your framework and adapts routes for you.
|
The shadcn CLI can now auto-detect your framework and adapt routes for you.
|
||||||
|
|
||||||
Works with all frameworks including Laravel, Vite and React Router.
|
Works with all frameworks including Laravel, Vite and React Router.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ We're working on zero-config MCP support for shadcn/ui registry. One command `np
|
|||||||
src="/images/mcp.jpeg"
|
src="/images/mcp.jpeg"
|
||||||
width="1432"
|
width="1432"
|
||||||
height="1050"
|
height="1050"
|
||||||
alt="Lift Mode"
|
alt="MCP Server"
|
||||||
className="mt-6 w-full overflow-hidden rounded-lg border"
|
className="mt-6 w-full overflow-hidden rounded-lg border"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user