@nswds/ui 0.0.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.
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema.json",
3
+ "style": "base-mira",
4
+ "rsc": true,
5
+ "tsx": true,
6
+ "tailwind": {
7
+ "config": "",
8
+ "css": "src/styles/globals.css",
9
+ "baseColor": "neutral",
10
+ "cssVariables": true
11
+ },
12
+ "iconLibrary": "tabler",
13
+ "aliases": {
14
+ "components": "@workspace/ui/components",
15
+ "utils": "@workspace/ui/lib/utils",
16
+ "hooks": "@workspace/ui/hooks",
17
+ "lib": "@workspace/ui/lib",
18
+ "ui": "@workspace/ui/components"
19
+ },
20
+ "rtl": true,
21
+ "menuColor": "default",
22
+ "menuAccent": "subtle"
23
+ }
@@ -0,0 +1,4 @@
1
+ import { config } from "@workspace/eslint-config/react-internal"
2
+
3
+ /** @type {import("eslint").Linter.Config} */
4
+ export default config
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@nswds/ui",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "private": false,
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "scripts": {
10
+ "lint": "eslint",
11
+ "format": "prettier --write \"**/*.{ts,tsx}\"",
12
+ "typecheck": "tsc --noEmit"
13
+ },
14
+ "dependencies": {
15
+ "@base-ui/react": "^1.5.0",
16
+ "@tabler/icons-react": "^3.44.0",
17
+ "class-variance-authority": "^0.7.1",
18
+ "clsx": "^2.1.1",
19
+ "next-themes": "^0.4.6",
20
+ "react": "^19.2.4",
21
+ "react-dom": "^19.2.4",
22
+ "shadcn": "^4.8.0",
23
+ "tailwind-merge": "^3.6.0",
24
+ "tw-animate-css": "^1.4.0",
25
+ "zod": "^3.25.76"
26
+ },
27
+ "devDependencies": {
28
+ "@tailwindcss/postcss": "^4.1.18",
29
+ "@turbo/gen": "^2.8.1",
30
+ "@types/node": "^25.1.0",
31
+ "@types/react": "^19.2.10",
32
+ "@types/react-dom": "^19.2.3",
33
+ "@workspace/eslint-config": "*",
34
+ "@workspace/typescript-config": "*",
35
+ "eslint": "^9.39.2",
36
+ "tailwindcss": "^4.1.18",
37
+ "typescript": "^5.9.3"
38
+ },
39
+ "exports": {
40
+ "./globals.css": "./src/styles/globals.css",
41
+ "./postcss.config": "./postcss.config.mjs",
42
+ "./lib/*": "./src/lib/*.ts",
43
+ "./components/*": "./src/components/*.tsx",
44
+ "./hooks/*": "./src/hooks/*.ts"
45
+ }
46
+ }
@@ -0,0 +1,6 @@
1
+ /** @type {import('postcss-load-config').Config} */
2
+ const config = {
3
+ plugins: { "@tailwindcss/postcss": {} },
4
+ };
5
+
6
+ export default config;
File without changes
@@ -0,0 +1,122 @@
1
+ import { IconPlus, IconTrash } from "@tabler/icons-react"
2
+ import type { Meta, StoryObj } from "@storybook/nextjs-vite"
3
+ import { expect } from "storybook/test"
4
+
5
+ import { Button } from "./button"
6
+
7
+ const meta = {
8
+ title: "Components/Button",
9
+ component: Button,
10
+ parameters: {
11
+ layout: "centered",
12
+ },
13
+ tags: ["autodocs", "ai-generated"],
14
+ argTypes: {
15
+ variant: {
16
+ control: "select",
17
+ options: ["default", "outline", "secondary", "ghost", "destructive", "link"],
18
+ },
19
+ size: {
20
+ control: "select",
21
+ options: ["xs", "sm", "default", "lg", "icon-xs", "icon-sm", "icon", "icon-lg"],
22
+ },
23
+ disabled: { control: "boolean" },
24
+ children: { control: "text" },
25
+ },
26
+ args: {
27
+ children: "Button",
28
+ disabled: false,
29
+ },
30
+ } satisfies Meta<typeof Button>
31
+
32
+ export default meta
33
+ type Story = StoryObj<typeof meta>
34
+
35
+ export const Default: Story = {
36
+ play: async ({ canvas }) => {
37
+ const button = canvas.getByRole("button", { name: /button/i })
38
+ // Proves the button is interactive (not disabled) — not just that it mounted.
39
+ await expect(button).not.toHaveAttribute("aria-disabled", "true")
40
+ await expect(button).toBeEnabled()
41
+ },
42
+ }
43
+
44
+ export const Variants: Story = {
45
+ render: () => (
46
+ <div className="flex flex-wrap items-center gap-2">
47
+ <Button variant="default">Default</Button>
48
+ <Button variant="outline">Outline</Button>
49
+ <Button variant="secondary">Secondary</Button>
50
+ <Button variant="ghost">Ghost</Button>
51
+ <Button variant="destructive">Destructive</Button>
52
+ <Button variant="link">Link</Button>
53
+ </div>
54
+ ),
55
+ }
56
+
57
+ export const Sizes: Story = {
58
+ render: () => (
59
+ <div className="flex flex-wrap items-end gap-2">
60
+ <Button size="xs">Extra small</Button>
61
+ <Button size="sm">Small</Button>
62
+ <Button size="default">Default</Button>
63
+ <Button size="lg">Large</Button>
64
+ </div>
65
+ ),
66
+ }
67
+
68
+ export const WithIcon: Story = {
69
+ render: () => (
70
+ <div className="flex flex-wrap items-center gap-2">
71
+ <Button>
72
+ <IconPlus data-icon="inline-start" />
73
+ Add item
74
+ </Button>
75
+ <Button variant="outline">
76
+ <IconPlus data-icon="inline-start" />
77
+ Add item
78
+ </Button>
79
+ <Button variant="destructive">
80
+ <IconTrash data-icon="inline-start" />
81
+ Delete
82
+ </Button>
83
+ </div>
84
+ ),
85
+ }
86
+
87
+ export const IconOnly: Story = {
88
+ render: () => (
89
+ <div className="flex flex-wrap items-end gap-2">
90
+ <Button size="icon-xs" variant="outline" aria-label="Add item">
91
+ <IconPlus />
92
+ </Button>
93
+ <Button size="icon-sm" variant="outline" aria-label="Add item">
94
+ <IconPlus />
95
+ </Button>
96
+ <Button size="icon" aria-label="Add item">
97
+ <IconPlus />
98
+ </Button>
99
+ <Button size="icon-lg" aria-label="Add item">
100
+ <IconPlus />
101
+ </Button>
102
+ </div>
103
+ ),
104
+ }
105
+
106
+ export const Disabled: Story = {
107
+ args: {
108
+ disabled: true,
109
+ },
110
+ }
111
+
112
+ // CssCheck — the only one in the project.
113
+ // The Button CVA root applies `font-medium` (→ font-weight: 500).
114
+ // If the shared preview failed to load globals.css / Tailwind, this
115
+ // would fall back to the browser default (400) and the assertion fails.
116
+ export const CssCheck: Story = {
117
+ args: { children: "CSS check" },
118
+ play: async ({ canvas }) => {
119
+ const button = canvas.getByRole("button", { name: /css check/i })
120
+ await expect(getComputedStyle(button).fontWeight).toBe("500")
121
+ },
122
+ }
@@ -0,0 +1,56 @@
1
+ import { Button as ButtonPrimitive } from "@base-ui/react/button"
2
+ import { cva, type VariantProps } from "class-variance-authority"
3
+
4
+ import { cn } from "@workspace/ui/lib/utils"
5
+
6
+ const buttonVariants = cva(
7
+ "group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-xs/relaxed font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: "bg-primary text-primary-foreground hover:bg-primary/80",
12
+ outline:
13
+ "border-border hover:bg-input/50 hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:bg-input/30",
14
+ secondary:
15
+ "bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
16
+ ghost:
17
+ "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
18
+ destructive:
19
+ "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
20
+ link: "text-primary underline-offset-4 hover:underline",
21
+ },
22
+ size: {
23
+ default:
24
+ "h-7 gap-1 px-2 text-xs/relaxed has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3.5",
25
+ xs: "h-5 gap-1 rounded-sm px-2 text-[0.625rem] has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-2.5",
26
+ sm: "h-6 gap-1 px-2 text-xs/relaxed has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3",
27
+ lg: "h-8 gap-1 px-2.5 text-xs/relaxed has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2 [&_svg:not([class*='size-'])]:size-4",
28
+ icon: "size-7 [&_svg:not([class*='size-'])]:size-3.5",
29
+ "icon-xs": "size-5 rounded-sm [&_svg:not([class*='size-'])]:size-2.5",
30
+ "icon-sm": "size-6 [&_svg:not([class*='size-'])]:size-3",
31
+ "icon-lg": "size-8 [&_svg:not([class*='size-'])]:size-4",
32
+ },
33
+ },
34
+ defaultVariants: {
35
+ variant: "default",
36
+ size: "default",
37
+ },
38
+ }
39
+ )
40
+
41
+ function Button({
42
+ className,
43
+ variant = "default",
44
+ size = "default",
45
+ ...props
46
+ }: ButtonPrimitive.Props & VariantProps<typeof buttonVariants>) {
47
+ return (
48
+ <ButtonPrimitive
49
+ data-slot="button"
50
+ className={cn(buttonVariants({ variant, size, className }))}
51
+ {...props}
52
+ />
53
+ )
54
+ }
55
+
56
+ export { Button, buttonVariants }