shapes-ui 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/.github/workflows/pr-preview.yml +9 -2
  2. package/CHANGELOG.md +11 -0
  3. package/README.md +13 -0
  4. package/content/components/accordion.mdx +13 -0
  5. package/content/components/alert-dialog.mdx +34 -0
  6. package/content/components/autocomplete.mdx +62 -0
  7. package/content/components/avatar.mdx +11 -0
  8. package/content/components/button.mdx +8 -0
  9. package/content/components/checkbox.mdx +11 -0
  10. package/content/components/collapsible.mdx +11 -0
  11. package/content/components/combobox.mdx +33 -0
  12. package/content/components/context-menu.mdx +29 -0
  13. package/content/components/dialog.mdx +33 -0
  14. package/content/components/drawer.mdx +38 -0
  15. package/content/components/field.mdx +21 -0
  16. package/content/components/fieldset.mdx +10 -0
  17. package/content/components/form.mdx +8 -0
  18. package/content/components/input.mdx +4 -0
  19. package/content/components/menu.mdx +27 -0
  20. package/content/components/menubar.mdx +31 -0
  21. package/content/components/meter.mdx +14 -0
  22. package/content/components/navigation-menu.mdx +28 -0
  23. package/content/components/number-field.mdx +25 -0
  24. package/content/components/popover.mdx +22 -0
  25. package/content/components/preview-card.mdx +14 -2
  26. package/content/components/progress.mdx +15 -1
  27. package/content/components/radio.mdx +11 -0
  28. package/content/components/scroll-area.mdx +23 -0
  29. package/content/components/select.mdx +27 -0
  30. package/content/components/separator.mdx +29 -0
  31. package/content/components/slider.mdx +4 -0
  32. package/content/components/switch.mdx +4 -0
  33. package/content/components/tabs.mdx +15 -0
  34. package/content/components/toast.mdx +10 -0
  35. package/content/components/toggle-group.mdx +37 -0
  36. package/content/components/toggle.mdx +12 -0
  37. package/content/components/toolbar.mdx +22 -0
  38. package/content/components/tooltip.mdx +13 -0
  39. package/content/docs/installation.mdx +30 -0
  40. package/content-collections.ts +65 -1
  41. package/dist/cli.js +947 -101
  42. package/examples/__index.tsx +136 -68
  43. package/examples/autocomplete-align.tsx +39 -0
  44. package/examples/autocomplete-controlled.tsx +44 -0
  45. package/examples/autocomplete-groups.tsx +65 -0
  46. package/examples/autocomplete-no-clear.tsx +40 -0
  47. package/examples/avatar-demo.tsx +3 -3
  48. package/examples/input-group-with-button.tsx +1 -1
  49. package/examples/separator-demo.tsx +13 -0
  50. package/examples/separator-horizontal.tsx +18 -0
  51. package/package.json +19 -18
  52. package/public/base-ui.svg +1 -0
  53. package/src/assets/base-ui.svg +1 -0
  54. package/src/commands/add.ts +79 -38
  55. package/src/commands/cli.ts +50 -3
  56. package/src/commands/create.ts +262 -0
  57. package/src/commands/init.ts +45 -12
  58. package/src/commands/palette.ts +55 -0
  59. package/src/components/docs/layout/footer.tsx +2 -2
  60. package/src/components/docs/layout/header.tsx +7 -9
  61. package/src/components/docs/layout/mobile-menu.tsx +0 -1
  62. package/src/components/docs/layout/nav-list.tsx +2 -2
  63. package/src/components/docs/layout/page-header.tsx +52 -7
  64. package/src/components/docs/layout/split-layout.tsx +9 -10
  65. package/src/components/docs/layout/table-of-content.tsx +145 -0
  66. package/src/components/docs/markdown/components.tsx +142 -29
  67. package/src/components/docs/markdown/copy-button.tsx +41 -0
  68. package/src/components/docs/markdown/installation-block.tsx +5 -24
  69. package/src/components/docs/markdown/render-preview.tsx +1 -1
  70. package/src/components/ui/button-group.tsx +1 -1
  71. package/src/components/ui/scroll-area.tsx +11 -2
  72. package/src/lib/docs-headings.ts +72 -0
  73. package/src/routeTree.gen.ts +60 -3
  74. package/src/routes/__root.tsx +2 -2
  75. package/src/routes/components.$slug.tsx +20 -4
  76. package/src/routes/docs.$slug.tsx +78 -0
  77. package/src/routes/docs.tsx +15 -0
  78. package/src/styles/styles.css +1 -1
  79. package/src/utils/cli-utils.ts +8 -8
  80. package/src/utils/dependency-installer.ts +30 -0
  81. package/src/utils/package-manager.ts +4 -4
  82. package/src/utils/palette.ts +666 -0
  83. package/src/utils/schema.ts +6 -0
@@ -10,6 +10,28 @@ description: Popover component that displays content anchored to a trigger eleme
10
10
 
11
11
  <InstallationBlock name="popover" />
12
12
 
13
+ ## Usage
14
+
15
+ <UsageSection
16
+ from="@/components/ui/popover"
17
+ imports={[
18
+ "Popover",
19
+ "PopoverPopup",
20
+ "PopoverDescription",
21
+ "PopoverClose",
22
+ "PopoverTitle",
23
+ "PopoverTrigger",
24
+ ]}
25
+ anatomy={`<Popover>
26
+ <PopoverTrigger />
27
+ <PopoverPopup>
28
+ <PopoverTitle />
29
+ <PopoverDescription />
30
+ <PopoverClose />
31
+ </PopoverPopup>
32
+ </Popover>;`}
33
+ />
34
+
13
35
  ## Examples
14
36
 
15
37
  ### Basic
@@ -4,13 +4,25 @@ slug: preview-card
4
4
  description: Component that displays a preview of linked content when hovered.
5
5
  ---
6
6
 
7
- <RenderPreview name={'preview-card-demo'} />
8
-
7
+ <RenderPreview name={"preview-card-demo"} />
9
8
 
10
9
  ## Installation
10
+
11
11
  <InstallationBlock name="preview-card" />
12
12
 
13
+ ## Usage
14
+
15
+ <UsageSection
16
+ from="@/components/ui/preview-card"
17
+ imports={["PreviewCard", "PreviewCardTrigger", "PreviewCardPopup"]}
18
+ anatomy={`<PreviewCard>
19
+ <PreviewCardTrigger />
20
+ <PreviewCardPopup />
21
+ </PreviewCard>;`}
22
+ />
23
+
13
24
  ## Examples
14
25
 
15
26
  ### Composed as CTA
27
+
16
28
  <RenderPreview name="preview-card-links" />
@@ -4,4 +4,18 @@ slug: progress
4
4
  description: Progress bar component for displaying the status of a task.
5
5
  ---
6
6
 
7
- <RenderPreview name={'progress-demo'} />
7
+ <RenderPreview name={"progress-demo"} />
8
+
9
+ ## Usage
10
+
11
+ <UsageSection
12
+ from="@/components/ui/progress"
13
+ imports={["Progress", "ProgressLabel", "ProgressValue", "ProgressTrack", "ProgressIndicator"]}
14
+ anatomy={`<Progress>
15
+ <ProgressLabel />
16
+ <ProgressValue />
17
+ <ProgressTrack>
18
+ <ProgressIndicator />
19
+ </ProgressTrack>
20
+ </Progress>;`}
21
+ />
@@ -10,6 +10,17 @@ description: Radio button component for selecting a single option from a group.
10
10
 
11
11
  <InstallationBlock name="radio" />
12
12
 
13
+ ## Usage
14
+
15
+ <UsageSection
16
+ from="@/components/ui/radio"
17
+ imports={["Radio", "RadioGroup"]}
18
+ anatomy={`<RadioGroup>
19
+ <Radio value="one" />
20
+ <Radio value="two" />
21
+ </RadioGroup>;`}
22
+ />
23
+
13
24
  ## Examples
14
25
 
15
26
  ### Orientation
@@ -9,3 +9,26 @@ description: A scroll area component that provides a customizable and accessible
9
9
  ## Installation
10
10
 
11
11
  <InstallationBlock name="scroll-area" />
12
+
13
+ ## Usage
14
+
15
+ <UsageSection
16
+ from="@/components/ui/scroll-area"
17
+ imports={[
18
+ "ScrollArea",
19
+ "ScrollAreaViewPort",
20
+ "ScrollAreaContent",
21
+ "ScrollAreaScrollbar",
22
+ "ScrollAreaThumb",
23
+ "ScrollAreaCorner",
24
+ ]}
25
+ anatomy={`<ScrollArea>
26
+ <ScrollAreaViewPort>
27
+ <ScrollAreaContent />
28
+ </ScrollAreaViewPort>
29
+ <ScrollAreaScrollbar>
30
+ <ScrollAreaThumb />
31
+ </ScrollAreaScrollbar>
32
+ <ScrollAreaCorner />
33
+ </ScrollArea>;`}
34
+ />
@@ -12,6 +12,33 @@ description: Select component for choosing a predefined value in a dropdown menu
12
12
 
13
13
  ## Usage
14
14
 
15
+ <UsageSection
16
+ from="@/components/ui/select"
17
+ imports={[
18
+ "Select",
19
+ "SelectPopup",
20
+ "SelectGroup",
21
+ "SelectItem",
22
+ "SelectLabel",
23
+ "SelectScrollDownButton",
24
+ "SelectScrollUpButton",
25
+ "SelectSeparator",
26
+ "SelectTrigger",
27
+ "SelectValue",
28
+ ]}
29
+ anatomy={`<Select>
30
+ <SelectTrigger>
31
+ <SelectValue />
32
+ </SelectTrigger>
33
+ <SelectPopup>
34
+ <SelectGroup>
35
+ <SelectLabel />
36
+ <SelectItem />
37
+ </SelectGroup>
38
+ </SelectPopup>
39
+ </Select>;`}
40
+ />
41
+
15
42
  ## Examples
16
43
 
17
44
  ### Alignment
@@ -0,0 +1,29 @@
1
+ ---
2
+ title: Separator
3
+ slug: separator
4
+ description: A visual and semantic divider used to separate related content.
5
+ ---
6
+
7
+ <RenderPreview name="separator-horizontal" />
8
+
9
+ ## Installation
10
+
11
+ <InstallationBlock name="separator" />
12
+
13
+ ## Usage
14
+
15
+ <UsageSection from="@/components/ui/separator" imports={["Separator"]} anatomy={`<Separator />;`} />
16
+
17
+ ## Examples
18
+
19
+ ### Horizontal
20
+
21
+ Use the default horizontal orientation to separate sections.
22
+
23
+ <RenderPreview name="separator-horizontal" />
24
+
25
+ ### Vertical
26
+
27
+ Use `orientation="vertical"` when separating inline items.
28
+
29
+ <RenderPreview name="separator-demo" />
@@ -10,6 +10,10 @@ description: Slider component for selecting a value or range of values.
10
10
 
11
11
  <InstallationBlock name="slider" />
12
12
 
13
+ ## Usage
14
+
15
+ <UsageSection from="@/components/ui/slider" imports={["Slider"]} anatomy={`<Slider />;`} />
16
+
13
17
  ## Examples
14
18
 
15
19
  ### Basic
@@ -10,6 +10,10 @@ description: Switch component that indicates whether a setting is on or off.
10
10
 
11
11
  <InstallationBlock name="switch" />
12
12
 
13
+ ## Usage
14
+
15
+ <UsageSection from="@/components/ui/switch" imports={["Switch"]} anatomy={`<Switch />;`} />
16
+
13
17
  ## Examples
14
18
 
15
19
  ### With Label
@@ -10,6 +10,21 @@ description: Tabs component for toggling between related panels on the same page
10
10
 
11
11
  <InstallationBlock name="tabs" />
12
12
 
13
+ ## Usage
14
+
15
+ <UsageSection
16
+ from="@/components/ui/tabs"
17
+ imports={["Tabs", "TabsList", "TabsTrigger", "TabsPanel", "tabsListVariants"]}
18
+ anatomy={`<Tabs defaultValue="tab-1">
19
+ <TabsList>
20
+ <TabsTrigger value="tab-1" />
21
+ <TabsTrigger value="tab-2" />
22
+ </TabsList>
23
+ <TabsPanel value="tab-1" />
24
+ <TabsPanel value="tab-2" />
25
+ </Tabs>;`}
26
+ />
27
+
13
28
  ## Examples
14
29
 
15
30
  ### Default
@@ -10,6 +10,16 @@ description: A brief message that appears temporarily to inform users of an acti
10
10
 
11
11
  <InstallationBlock name="toast" />
12
12
 
13
+ ## Usage
14
+
15
+ <UsageSection
16
+ from="@/components/ui/toast"
17
+ imports={["Toast", "ToastProvider", "globalToast", "useToast"]}
18
+ anatomy={`<ToastProvider>
19
+ <Toast />
20
+ </ToastProvider>;`}
21
+ />
22
+
13
23
  ## Examples
14
24
 
15
25
  ### Positions
@@ -0,0 +1,37 @@
1
+ ---
2
+ title: Toggle Group
3
+ slug: toggle-group
4
+ description: A grouped set of toggles for single or multiple selection.
5
+ ---
6
+
7
+ <RenderPreview name="toggle-group-demo" />
8
+
9
+ ## Installation
10
+
11
+ <InstallationBlock name="toggle" />
12
+
13
+ ## Usage
14
+
15
+ <UsageSection
16
+ from="@/components/ui/toggle"
17
+ imports={["Toggle", "ToggleGroup", "toggleVariants"]}
18
+ anatomy={`<ToggleGroup>
19
+ <Toggle value="left" />
20
+ <Toggle value="center" />
21
+ <Toggle value="right" />
22
+ </ToggleGroup>;`}
23
+ />
24
+
25
+ ## Examples
26
+
27
+ ### Single
28
+
29
+ Use `ToggleGroup` for an exclusive selection.
30
+
31
+ <RenderPreview name="toggle-group-demo" />
32
+
33
+ ### Multiple
34
+
35
+ Set `multiple` on `ToggleGroup` to allow selecting more than one option.
36
+
37
+ <RenderPreview name="toggle-group-multiple" />
@@ -10,6 +10,18 @@ description: A button that can be toggled between two states.
10
10
 
11
11
  <InstallationBlock name="toggle" />
12
12
 
13
+ ## Usage
14
+
15
+ <UsageSection
16
+ from="@/components/ui/toggle"
17
+ imports={["Toggle", "toggleVariants", "ToggleGroup"]}
18
+ anatomy={`<ToggleGroup>
19
+ <Toggle value="left" />
20
+ <Toggle value="center" />
21
+ <Toggle value="right" />
22
+ </ToggleGroup>;`}
23
+ />
24
+
13
25
  ## Examples
14
26
 
15
27
  ### Toggle
@@ -10,6 +10,28 @@ description: A collection of buttons and controls organized in a horizontal bar.
10
10
 
11
11
  <InstallationBlock name="toolbar" />
12
12
 
13
+ ## Usage
14
+
15
+ <UsageSection
16
+ from="@/components/ui/toolbar"
17
+ imports={[
18
+ "Toolbar",
19
+ "ToolbarButton",
20
+ "ToolbarLink",
21
+ "ToolbarInput",
22
+ "ToolbarGroup",
23
+ "ToolbarSeparator",
24
+ ]}
25
+ anatomy={`<Toolbar>
26
+ <ToolbarGroup>
27
+ <ToolbarButton />
28
+ <ToolbarSeparator />
29
+ <ToolbarLink />
30
+ </ToolbarGroup>
31
+ <ToolbarInput />
32
+ </Toolbar>;`}
33
+ />
34
+
13
35
  ## Examples
14
36
 
15
37
  ### Demo
@@ -10,6 +10,19 @@ description: A popup that appears when an element is hovered or focused, showing
10
10
 
11
11
  <InstallationBlock name="tooltip" />
12
12
 
13
+ ## Usage
14
+
15
+ <UsageSection
16
+ from="@/components/ui/tooltip"
17
+ imports={["Tooltip", "TooltipTrigger", "TooltipPopup", "TooltipProvider"]}
18
+ anatomy={`<TooltipProvider>
19
+ <Tooltip>
20
+ <TooltipTrigger />
21
+ <TooltipPopup />
22
+ </Tooltip>
23
+ </TooltipProvider>;`}
24
+ />
25
+
13
26
  ## Examples
14
27
 
15
28
  ### Demo
@@ -0,0 +1,30 @@
1
+ ---
2
+ title: Installation
3
+ slug: installation
4
+ description: Set up Shapes UI in your React project.
5
+ ---
6
+
7
+ ## Requirements
8
+
9
+ - React project
10
+ - Tailwind CSS v4
11
+
12
+ ## Quick start
13
+
14
+ ```bash
15
+ npx shapes-ui init
16
+ ```
17
+
18
+ During setup, you can choose a brand palette and contrast mode. Shapes will generate semantic color tokens in your configured CSS file and keep them inside a managed block.
19
+
20
+ ## Create with full setup
21
+
22
+ ```bash
23
+ npx shapes-ui create my-app --full --palette emerald --contrast-mode deterministic
24
+ ```
25
+
26
+ ## Update palette later
27
+
28
+ ```bash
29
+ npx shapes-ui palette set blue --contrast-mode dynamic
30
+ ```
@@ -4,6 +4,8 @@ import rehypePrettyCode from "rehype-pretty-code";
4
4
  import remarkGfm from "remark-gfm";
5
5
  import { z } from "zod";
6
6
 
7
+ import { extractHeadingsFromMarkdown } from "./src/lib/docs-headings";
8
+
7
9
  const components = defineCollection({
8
10
  name: "components",
9
11
  directory: "content/components",
@@ -13,6 +15,67 @@ const components = defineCollection({
13
15
  slug: z.string(),
14
16
  description: z.string().optional(),
15
17
  content: z.string(),
18
+ referenceLink: z.string().optional(),
19
+ }),
20
+ transform: async (document, context) => {
21
+ const mdx = await compileMDX(context, document, {
22
+ files: (appender) => {
23
+ appender.file(
24
+ "@/components/docs/markdown/render-preview",
25
+ "./src/components/docs/markdown/render-preview.tsx",
26
+ );
27
+ },
28
+ remarkPlugins: [remarkGfm],
29
+ rehypePlugins: [
30
+ [
31
+ rehypePrettyCode,
32
+ {
33
+ theme: {
34
+ light: "github-light",
35
+ dark: "github-dark",
36
+ },
37
+ keepBackground: false,
38
+ transformers: [
39
+ {
40
+ name: "line-numbers",
41
+ pre(node: any) {
42
+ node.properties["data-line-numbers"] = "";
43
+ },
44
+ line(node: any, line: number) {
45
+ node.properties.className = ["line"];
46
+ node.children.unshift({
47
+ type: "element",
48
+ tagName: "span",
49
+ properties: {
50
+ className: ["line-number"],
51
+ },
52
+ children: [{ type: "text", value: String(line) }],
53
+ });
54
+ },
55
+ },
56
+ ],
57
+ },
58
+ ],
59
+ ],
60
+ });
61
+ return {
62
+ ...document,
63
+ mdx,
64
+ toc: extractHeadingsFromMarkdown(document.content),
65
+ };
66
+ },
67
+ });
68
+
69
+ const docs = defineCollection({
70
+ name: "docs",
71
+ directory: "content/docs",
72
+ include: "*.mdx",
73
+ schema: z.object({
74
+ title: z.string(),
75
+ slug: z.string(),
76
+ description: z.string().optional(),
77
+ content: z.string(),
78
+ referenceLink: z.string().optional(),
16
79
  }),
17
80
  transform: async (document, context) => {
18
81
  const mdx = await compileMDX(context, document, {
@@ -58,10 +121,11 @@ const components = defineCollection({
58
121
  return {
59
122
  ...document,
60
123
  mdx,
124
+ toc: extractHeadingsFromMarkdown(document.content),
61
125
  };
62
126
  },
63
127
  });
64
128
 
65
129
  export default defineConfig({
66
- content: [components],
130
+ content: [components, docs],
67
131
  });