@foundrykit/primitives 0.1.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.
- package/components.json +20 -0
- package/dist/chunk-A3U73FA7.js +33 -0
- package/dist/chunk-AADRFFPH.js +171 -0
- package/dist/chunk-FUWID6MC.js +42 -0
- package/dist/chunk-FYCANIVJ.js +69 -0
- package/dist/chunk-I44GXEPN.js +20 -0
- package/dist/chunk-J4CRGO2P.js +46 -0
- package/dist/chunk-J57CV3VT.js +28 -0
- package/dist/chunk-KZMSLRLW.js +25 -0
- package/dist/chunk-PHMEWMFS.js +233 -0
- package/dist/chunk-QL4XJD7Y.js +24 -0
- package/dist/chunk-SKR3J46C.js +17 -0
- package/dist/chunk-U2EIVYWP.js +33 -0
- package/dist/chunk-UZIMC7AQ.js +63 -0
- package/dist/chunk-VSXKLSEP.js +105 -0
- package/dist/chunk-VVNIYCKH.js +55 -0
- package/dist/chunk-XQAJQKO7.js +47 -0
- package/dist/chunk-YTUI6MCB.js +52 -0
- package/dist/components/avatar/index.cjs +92 -0
- package/dist/components/avatar/index.d.cts +9 -0
- package/dist/components/avatar/index.d.ts +9 -0
- package/dist/components/avatar/index.js +11 -0
- package/dist/components/badge/index.cjs +67 -0
- package/dist/components/badge/index.d.cts +13 -0
- package/dist/components/badge/index.d.ts +13 -0
- package/dist/components/badge/index.js +8 -0
- package/dist/components/breadcrumb/index.cjs +135 -0
- package/dist/components/breadcrumb/index.d.cts +14 -0
- package/dist/components/breadcrumb/index.d.ts +14 -0
- package/dist/components/breadcrumb/index.js +18 -0
- package/dist/components/button/index.cjs +77 -0
- package/dist/components/button/index.d.cts +15 -0
- package/dist/components/button/index.d.ts +15 -0
- package/dist/components/button/index.js +8 -0
- package/dist/components/card/index.cjs +102 -0
- package/dist/components/card/index.d.cts +10 -0
- package/dist/components/card/index.d.ts +10 -0
- package/dist/components/card/index.js +16 -0
- package/dist/components/checkbox/index.cjs +68 -0
- package/dist/components/checkbox/index.d.cts +7 -0
- package/dist/components/checkbox/index.d.ts +7 -0
- package/dist/components/checkbox/index.js +7 -0
- package/dist/components/dropdown/index.cjs +282 -0
- package/dist/components/dropdown/index.d.cts +28 -0
- package/dist/components/dropdown/index.d.ts +28 -0
- package/dist/components/dropdown/index.js +35 -0
- package/dist/components/input/index.cjs +59 -0
- package/dist/components/input/index.d.cts +7 -0
- package/dist/components/input/index.d.ts +7 -0
- package/dist/components/input/index.js +6 -0
- package/dist/components/label/index.cjs +59 -0
- package/dist/components/label/index.d.cts +7 -0
- package/dist/components/label/index.d.ts +7 -0
- package/dist/components/label/index.js +7 -0
- package/dist/components/popover/index.cjs +84 -0
- package/dist/components/popover/index.d.cts +10 -0
- package/dist/components/popover/index.d.ts +10 -0
- package/dist/components/popover/index.js +13 -0
- package/dist/components/radio-group/index.cjs +83 -0
- package/dist/components/radio-group/index.d.cts +8 -0
- package/dist/components/radio-group/index.d.ts +8 -0
- package/dist/components/radio-group/index.js +9 -0
- package/dist/components/select/index.cjs +215 -0
- package/dist/components/select/index.d.cts +18 -0
- package/dist/components/select/index.d.ts +18 -0
- package/dist/components/select/index.js +25 -0
- package/dist/components/separator/index.cjs +63 -0
- package/dist/components/separator/index.d.cts +7 -0
- package/dist/components/separator/index.d.ts +7 -0
- package/dist/components/separator/index.js +7 -0
- package/dist/components/skeleton/index.cjs +41 -0
- package/dist/components/skeleton/index.d.cts +5 -0
- package/dist/components/skeleton/index.d.ts +5 -0
- package/dist/components/skeleton/index.js +6 -0
- package/dist/components/switch/index.cjs +68 -0
- package/dist/components/switch/index.d.cts +7 -0
- package/dist/components/switch/index.d.ts +7 -0
- package/dist/components/switch/index.js +7 -0
- package/dist/components/tabs/index.cjs +107 -0
- package/dist/components/tabs/index.d.cts +10 -0
- package/dist/components/tabs/index.d.ts +10 -0
- package/dist/components/tabs/index.js +13 -0
- package/dist/components/textarea/index.cjs +44 -0
- package/dist/components/textarea/index.d.cts +6 -0
- package/dist/components/textarea/index.d.ts +6 -0
- package/dist/components/textarea/index.js +6 -0
- package/dist/index.cjs +1275 -0
- package/dist/index.d.cts +46 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +298 -0
- package/eslint.config.js +4 -0
- package/package.json +67 -0
- package/postcss.config.mjs +6 -0
- package/registry.json +51 -0
- package/src/components/avatar/config.ts +46 -0
- package/src/components/avatar/index.tsx +53 -0
- package/src/components/badge/config.ts +56 -0
- package/src/components/badge/index.tsx +46 -0
- package/src/components/breadcrumb/config.ts +121 -0
- package/src/components/breadcrumb/index.tsx +109 -0
- package/src/components/button/config.ts +76 -0
- package/src/components/button/index.tsx +62 -0
- package/src/components/card/config.ts +89 -0
- package/src/components/card/index.tsx +83 -0
- package/src/components/checkbox/config.ts +46 -0
- package/src/components/checkbox/index.tsx +32 -0
- package/src/components/dialog/config.ts +582 -0
- package/src/components/dialog/index.tsx +143 -0
- package/src/components/dropdown/config.ts +262 -0
- package/src/components/dropdown/index.tsx +257 -0
- package/src/components/input/config.ts +64 -0
- package/src/components/input/index.tsx +25 -0
- package/src/components/label/config.ts +72 -0
- package/src/components/label/index.tsx +24 -0
- package/src/components/popover/config.ts +219 -0
- package/src/components/popover/index.tsx +48 -0
- package/src/components/radio-group/config.ts +303 -0
- package/src/components/radio-group/index.tsx +45 -0
- package/src/components/select/config.ts +277 -0
- package/src/components/select/index.tsx +185 -0
- package/src/components/separator/config.ts +63 -0
- package/src/components/separator/index.tsx +28 -0
- package/src/components/skeleton/config.ts +77 -0
- package/src/components/skeleton/index.tsx +13 -0
- package/src/components/switch/config.ts +165 -0
- package/src/components/switch/index.tsx +31 -0
- package/src/components/tabs/config.ts +335 -0
- package/src/components/tabs/index.tsx +66 -0
- package/src/components/textarea/config.ts +117 -0
- package/src/components/textarea/index.tsx +18 -0
- package/src/index.ts +87 -0
- package/tsconfig.json +9 -0
- package/tsconfig.lint.json +8 -0
- package/tsup.config.ts +29 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
3
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
4
|
+
|
|
5
|
+
import { cn } from '@foundrykit/utils';
|
|
6
|
+
|
|
7
|
+
const badgeVariants = cva(
|
|
8
|
+
'inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden',
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default:
|
|
13
|
+
'border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90',
|
|
14
|
+
secondary:
|
|
15
|
+
'border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90',
|
|
16
|
+
destructive:
|
|
17
|
+
'border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',
|
|
18
|
+
outline:
|
|
19
|
+
'text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
defaultVariants: {
|
|
23
|
+
variant: 'default',
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
function Badge({
|
|
29
|
+
className,
|
|
30
|
+
variant,
|
|
31
|
+
asChild = false,
|
|
32
|
+
...props
|
|
33
|
+
}: React.ComponentProps<'span'> &
|
|
34
|
+
VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
|
|
35
|
+
const Comp = asChild ? Slot : 'span';
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Comp
|
|
39
|
+
data-slot='badge'
|
|
40
|
+
className={cn(badgeVariants({ variant }), className)}
|
|
41
|
+
{...props}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { Badge, badgeVariants };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { ComponentConfig } from '@foundrykit/types';
|
|
2
|
+
|
|
3
|
+
export const breadcrumbConfig: ComponentConfig = {
|
|
4
|
+
name: 'Breadcrumb',
|
|
5
|
+
description: 'Navigation breadcrumb component',
|
|
6
|
+
category: 'primitives',
|
|
7
|
+
tags: ['navigation', 'breadcrumb', 'menu'],
|
|
8
|
+
preview: {
|
|
9
|
+
type: 'static',
|
|
10
|
+
html: '<div class="flex h-12 w-full items-center justify-center rounded-md bg-gray-200"><div class="flex items-center space-x-1"><div class="h-3 w-3 rounded bg-gray-400"></div><div class="h-2 w-2 rotate-45 bg-gray-300"></div><div class="h-1 w-8 rounded bg-gray-400"></div><div class="h-2 w-2 rotate-45 bg-gray-300"></div><div class="h-1 w-6 rounded bg-gray-400"></div></div></div>',
|
|
11
|
+
},
|
|
12
|
+
variants: [
|
|
13
|
+
{
|
|
14
|
+
name: 'Default',
|
|
15
|
+
description: 'Default breadcrumb navigation',
|
|
16
|
+
code: '<Breadcrumb items={[{ label: "Home", href: "/" }, { label: "Products", href: "/products" }, { label: "Current" }]} />',
|
|
17
|
+
preview: {
|
|
18
|
+
type: 'component',
|
|
19
|
+
component: 'Breadcrumb',
|
|
20
|
+
props: {
|
|
21
|
+
children: {
|
|
22
|
+
component: 'BreadcrumbList',
|
|
23
|
+
props: {
|
|
24
|
+
children: [
|
|
25
|
+
{
|
|
26
|
+
component: 'BreadcrumbItem',
|
|
27
|
+
props: {
|
|
28
|
+
children: {
|
|
29
|
+
component: 'BreadcrumbLink',
|
|
30
|
+
props: { href: '/', children: 'Home' },
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
component: 'BreadcrumbSeparator',
|
|
36
|
+
props: {},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
component: 'BreadcrumbItem',
|
|
40
|
+
props: {
|
|
41
|
+
children: {
|
|
42
|
+
component: 'BreadcrumbLink',
|
|
43
|
+
props: { href: '/products', children: 'Products' },
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
component: 'BreadcrumbSeparator',
|
|
49
|
+
props: {},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
component: 'BreadcrumbItem',
|
|
53
|
+
props: {
|
|
54
|
+
children: {
|
|
55
|
+
component: 'BreadcrumbPage',
|
|
56
|
+
props: { children: 'Current' },
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'With Icons',
|
|
68
|
+
description: 'Breadcrumb with custom icons',
|
|
69
|
+
code: '<Breadcrumb items={[{ label: "Home", href: "/", icon: HomeIcon }, { label: "Settings", href: "/settings", icon: SettingsIcon }]} />',
|
|
70
|
+
preview: {
|
|
71
|
+
type: 'component',
|
|
72
|
+
component: 'Breadcrumb',
|
|
73
|
+
props: {
|
|
74
|
+
children: {
|
|
75
|
+
component: 'BreadcrumbList',
|
|
76
|
+
props: {
|
|
77
|
+
children: [
|
|
78
|
+
{
|
|
79
|
+
component: 'BreadcrumbItem',
|
|
80
|
+
props: {
|
|
81
|
+
children: [
|
|
82
|
+
{
|
|
83
|
+
component: 'Home',
|
|
84
|
+
props: { className: 'h-4 w-4' },
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
component: 'BreadcrumbLink',
|
|
88
|
+
props: { href: '/', children: 'Home' },
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
component: 'BreadcrumbSeparator',
|
|
95
|
+
props: {},
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
component: 'BreadcrumbItem',
|
|
99
|
+
props: {
|
|
100
|
+
children: [
|
|
101
|
+
{
|
|
102
|
+
component: 'Settings',
|
|
103
|
+
props: { className: 'h-4 w-4' },
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
component: 'BreadcrumbLink',
|
|
107
|
+
props: { href: '/settings', children: 'Settings' },
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
dependencies: ['utils'],
|
|
120
|
+
files: ['components/primitives/breadcrumb/index.tsx'],
|
|
121
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
3
|
+
import { ChevronRight, MoreHorizontal } from 'lucide-react';
|
|
4
|
+
|
|
5
|
+
import { cn } from '@foundrykit/utils';
|
|
6
|
+
|
|
7
|
+
function Breadcrumb({ ...props }: React.ComponentProps<'nav'>) {
|
|
8
|
+
return <nav aria-label='breadcrumb' data-slot='breadcrumb' {...props} />;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function BreadcrumbList({ className, ...props }: React.ComponentProps<'ol'>) {
|
|
12
|
+
return (
|
|
13
|
+
<ol
|
|
14
|
+
data-slot='breadcrumb-list'
|
|
15
|
+
className={cn(
|
|
16
|
+
'text-muted-foreground flex flex-wrap items-center gap-1.5 break-words text-sm sm:gap-2.5',
|
|
17
|
+
className
|
|
18
|
+
)}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function BreadcrumbItem({ className, ...props }: React.ComponentProps<'li'>) {
|
|
25
|
+
return (
|
|
26
|
+
<li
|
|
27
|
+
data-slot='breadcrumb-item'
|
|
28
|
+
className={cn('inline-flex items-center gap-1.5', className)}
|
|
29
|
+
{...props}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function BreadcrumbLink({
|
|
35
|
+
asChild,
|
|
36
|
+
className,
|
|
37
|
+
...props
|
|
38
|
+
}: React.ComponentProps<'a'> & {
|
|
39
|
+
asChild?: boolean;
|
|
40
|
+
}) {
|
|
41
|
+
const Comp = asChild ? Slot : 'a';
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Comp
|
|
45
|
+
data-slot='breadcrumb-link'
|
|
46
|
+
className={cn('hover:text-foreground transition-colors', className)}
|
|
47
|
+
{...props}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function BreadcrumbPage({ className, ...props }: React.ComponentProps<'span'>) {
|
|
53
|
+
return (
|
|
54
|
+
<span
|
|
55
|
+
data-slot='breadcrumb-page'
|
|
56
|
+
role='link'
|
|
57
|
+
aria-disabled='true'
|
|
58
|
+
aria-current='page'
|
|
59
|
+
className={cn('text-foreground font-normal', className)}
|
|
60
|
+
{...props}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function BreadcrumbSeparator({
|
|
66
|
+
children,
|
|
67
|
+
className,
|
|
68
|
+
...props
|
|
69
|
+
}: React.ComponentProps<'li'>) {
|
|
70
|
+
return (
|
|
71
|
+
<li
|
|
72
|
+
data-slot='breadcrumb-separator'
|
|
73
|
+
role='presentation'
|
|
74
|
+
aria-hidden='true'
|
|
75
|
+
className={cn('[&>svg]:size-3.5', className)}
|
|
76
|
+
{...props}
|
|
77
|
+
>
|
|
78
|
+
{children ?? <ChevronRight />}
|
|
79
|
+
</li>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function BreadcrumbEllipsis({
|
|
84
|
+
className,
|
|
85
|
+
...props
|
|
86
|
+
}: React.ComponentProps<'span'>) {
|
|
87
|
+
return (
|
|
88
|
+
<span
|
|
89
|
+
data-slot='breadcrumb-ellipsis'
|
|
90
|
+
role='presentation'
|
|
91
|
+
aria-hidden='true'
|
|
92
|
+
className={cn('flex size-9 items-center justify-center', className)}
|
|
93
|
+
{...props}
|
|
94
|
+
>
|
|
95
|
+
<MoreHorizontal className='size-4' />
|
|
96
|
+
<span className='sr-only'>More</span>
|
|
97
|
+
</span>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export {
|
|
102
|
+
Breadcrumb,
|
|
103
|
+
BreadcrumbList,
|
|
104
|
+
BreadcrumbItem,
|
|
105
|
+
BreadcrumbLink,
|
|
106
|
+
BreadcrumbPage,
|
|
107
|
+
BreadcrumbSeparator,
|
|
108
|
+
BreadcrumbEllipsis,
|
|
109
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ComponentConfig } from '@foundrykit/types';
|
|
2
|
+
|
|
3
|
+
export const buttonConfig: ComponentConfig = {
|
|
4
|
+
name: 'Button',
|
|
5
|
+
description: 'Versatile button component with multiple variants and sizes',
|
|
6
|
+
category: 'primitives',
|
|
7
|
+
tags: ['form', 'interactive'],
|
|
8
|
+
preview: {
|
|
9
|
+
type: 'static',
|
|
10
|
+
html: '<div class="flex h-12 w-full items-center justify-center rounded-md bg-gray-200"><div class="h-8 w-20 rounded bg-gray-400 flex items-center justify-center text-xs text-white">Button</div></div>',
|
|
11
|
+
},
|
|
12
|
+
variants: [
|
|
13
|
+
{
|
|
14
|
+
name: 'Default',
|
|
15
|
+
description: 'Primary button with default styling',
|
|
16
|
+
code: '<Button>Default Button</Button>',
|
|
17
|
+
preview: {
|
|
18
|
+
type: 'component',
|
|
19
|
+
component: 'Button',
|
|
20
|
+
props: { children: 'Default Button' },
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'Outline',
|
|
25
|
+
description: 'Button with outline styling',
|
|
26
|
+
code: '<Button variant="outline">Outline Button</Button>',
|
|
27
|
+
preview: {
|
|
28
|
+
type: 'component',
|
|
29
|
+
component: 'Button',
|
|
30
|
+
props: { variant: 'outline', children: 'Outline Button' },
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'Secondary',
|
|
35
|
+
description: 'Secondary button styling',
|
|
36
|
+
code: '<Button variant="secondary">Secondary Button</Button>',
|
|
37
|
+
preview: {
|
|
38
|
+
type: 'component',
|
|
39
|
+
component: 'Button',
|
|
40
|
+
props: { variant: 'secondary', children: 'Secondary Button' },
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'Destructive',
|
|
45
|
+
description: 'Button for destructive actions',
|
|
46
|
+
code: '<Button variant="destructive">Destructive Button</Button>',
|
|
47
|
+
preview: {
|
|
48
|
+
type: 'component',
|
|
49
|
+
component: 'Button',
|
|
50
|
+
props: { variant: 'destructive', children: 'Destructive Button' },
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'Small',
|
|
55
|
+
description: 'Small button size',
|
|
56
|
+
code: '<Button size="sm">Small Button</Button>',
|
|
57
|
+
preview: {
|
|
58
|
+
type: 'component',
|
|
59
|
+
component: 'Button',
|
|
60
|
+
props: { size: 'sm', children: 'Small Button' },
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'Large',
|
|
65
|
+
description: 'Large button size',
|
|
66
|
+
code: '<Button size="lg">Large Button</Button>',
|
|
67
|
+
preview: {
|
|
68
|
+
type: 'component',
|
|
69
|
+
component: 'Button',
|
|
70
|
+
props: { size: 'lg', children: 'Large Button' },
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
dependencies: ['utils'],
|
|
75
|
+
files: ['components/primitives/button/index.tsx'],
|
|
76
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
3
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
4
|
+
|
|
5
|
+
import { cn } from '@foundrykit/utils';
|
|
6
|
+
|
|
7
|
+
const buttonVariants = cva(
|
|
8
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default:
|
|
13
|
+
'bg-primary text-primary-foreground shadow-xs hover:bg-primary/90',
|
|
14
|
+
destructive:
|
|
15
|
+
'bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',
|
|
16
|
+
outline:
|
|
17
|
+
'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50',
|
|
18
|
+
secondary:
|
|
19
|
+
'bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80',
|
|
20
|
+
ghost:
|
|
21
|
+
'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',
|
|
22
|
+
link: 'text-primary underline-offset-4 hover:underline',
|
|
23
|
+
},
|
|
24
|
+
size: {
|
|
25
|
+
default: 'h-9 px-4 py-2 has-[>svg]:px-3',
|
|
26
|
+
sm: 'h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5',
|
|
27
|
+
lg: 'h-10 rounded-md px-6 has-[>svg]:px-4',
|
|
28
|
+
icon: 'size-9',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
defaultVariants: {
|
|
32
|
+
variant: 'default',
|
|
33
|
+
size: 'default',
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
export interface ButtonProps
|
|
39
|
+
extends React.ComponentProps<'button'>,
|
|
40
|
+
VariantProps<typeof buttonVariants> {
|
|
41
|
+
asChild?: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function Button({
|
|
45
|
+
className,
|
|
46
|
+
variant,
|
|
47
|
+
size,
|
|
48
|
+
asChild = false,
|
|
49
|
+
...props
|
|
50
|
+
}: ButtonProps) {
|
|
51
|
+
const Comp = asChild ? Slot : 'button';
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<Comp
|
|
55
|
+
data-slot='button'
|
|
56
|
+
className={cn(buttonVariants({ variant, size, className }))}
|
|
57
|
+
{...props}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { Button, buttonVariants };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { ComponentConfig } from '@foundrykit/types';
|
|
2
|
+
|
|
3
|
+
export const cardConfig: ComponentConfig = {
|
|
4
|
+
name: 'Card',
|
|
5
|
+
description: 'Container component for content organization',
|
|
6
|
+
category: 'primitives',
|
|
7
|
+
tags: ['container', 'layout', 'content'],
|
|
8
|
+
preview: {
|
|
9
|
+
type: 'static',
|
|
10
|
+
html: '<div class="flex h-12 w-full flex-col justify-center rounded-md border border-gray-200 bg-white p-2"><div class="mb-1 h-2 w-full rounded bg-gray-200"></div><div class="h-1 w-3/4 rounded bg-gray-200"></div></div>',
|
|
11
|
+
},
|
|
12
|
+
variants: [
|
|
13
|
+
{
|
|
14
|
+
name: 'Default',
|
|
15
|
+
description: 'Default card with header and content',
|
|
16
|
+
code: '<Card><CardHeader><CardTitle>Card Title</CardTitle><CardDescription>Card description</CardDescription></CardHeader><CardContent>Card content</CardContent></Card>',
|
|
17
|
+
preview: {
|
|
18
|
+
type: 'component',
|
|
19
|
+
component: 'Card',
|
|
20
|
+
props: {
|
|
21
|
+
children: [
|
|
22
|
+
{
|
|
23
|
+
component: 'CardHeader',
|
|
24
|
+
props: {
|
|
25
|
+
children: [
|
|
26
|
+
{ component: 'CardTitle', props: { children: 'Card Title' } },
|
|
27
|
+
{
|
|
28
|
+
component: 'CardDescription',
|
|
29
|
+
props: { children: 'Card description' },
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{ component: 'CardContent', props: { children: 'Card content' } },
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'Simple',
|
|
41
|
+
description: 'Simple card without header',
|
|
42
|
+
code: '<Card><CardContent>Simple card content</CardContent></Card>',
|
|
43
|
+
preview: {
|
|
44
|
+
type: 'component',
|
|
45
|
+
component: 'Card',
|
|
46
|
+
props: {
|
|
47
|
+
children: {
|
|
48
|
+
component: 'CardContent',
|
|
49
|
+
props: { children: 'Simple card content' },
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'With Footer',
|
|
56
|
+
description: 'Card with footer actions',
|
|
57
|
+
code: '<Card><CardHeader><CardTitle>Card with Footer</CardTitle></CardHeader><CardContent>Content</CardContent><CardFooter><Button>Action</Button></CardFooter></Card>',
|
|
58
|
+
preview: {
|
|
59
|
+
type: 'component',
|
|
60
|
+
component: 'Card',
|
|
61
|
+
props: {
|
|
62
|
+
children: [
|
|
63
|
+
{
|
|
64
|
+
component: 'CardHeader',
|
|
65
|
+
props: {
|
|
66
|
+
children: {
|
|
67
|
+
component: 'CardTitle',
|
|
68
|
+
props: { children: 'Card with Footer' },
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
{ component: 'CardContent', props: { children: 'Content' } },
|
|
73
|
+
{
|
|
74
|
+
component: 'CardFooter',
|
|
75
|
+
props: {
|
|
76
|
+
children: {
|
|
77
|
+
component: 'Button',
|
|
78
|
+
props: { children: 'Action' },
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
dependencies: ['utils'],
|
|
88
|
+
files: ['components/primitives/card/index.tsx'],
|
|
89
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { cn } from '@foundrykit/utils';
|
|
4
|
+
|
|
5
|
+
const Card = React.forwardRef<
|
|
6
|
+
HTMLDivElement,
|
|
7
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
8
|
+
>(({ className, ...props }, ref) => (
|
|
9
|
+
<div
|
|
10
|
+
ref={ref}
|
|
11
|
+
className={cn(
|
|
12
|
+
'bg-card text-card-foreground rounded-xl border shadow',
|
|
13
|
+
className
|
|
14
|
+
)}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
));
|
|
18
|
+
Card.displayName = 'Card';
|
|
19
|
+
|
|
20
|
+
const CardHeader = React.forwardRef<
|
|
21
|
+
HTMLDivElement,
|
|
22
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
23
|
+
>(({ className, ...props }, ref) => (
|
|
24
|
+
<div
|
|
25
|
+
ref={ref}
|
|
26
|
+
className={cn('flex flex-col space-y-1.5 p-6', className)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
));
|
|
30
|
+
CardHeader.displayName = 'CardHeader';
|
|
31
|
+
|
|
32
|
+
const CardTitle = React.forwardRef<
|
|
33
|
+
HTMLParagraphElement,
|
|
34
|
+
React.HTMLAttributes<HTMLHeadingElement>
|
|
35
|
+
>(({ className, ...props }, ref) => (
|
|
36
|
+
<h3
|
|
37
|
+
ref={ref}
|
|
38
|
+
className={cn('font-semibold leading-none tracking-tight', className)}
|
|
39
|
+
{...props}
|
|
40
|
+
/>
|
|
41
|
+
));
|
|
42
|
+
CardTitle.displayName = 'CardTitle';
|
|
43
|
+
|
|
44
|
+
const CardDescription = React.forwardRef<
|
|
45
|
+
HTMLParagraphElement,
|
|
46
|
+
React.HTMLAttributes<HTMLParagraphElement>
|
|
47
|
+
>(({ className, ...props }, ref) => (
|
|
48
|
+
<p
|
|
49
|
+
ref={ref}
|
|
50
|
+
className={cn('text-muted-foreground text-sm', className)}
|
|
51
|
+
{...props}
|
|
52
|
+
/>
|
|
53
|
+
));
|
|
54
|
+
CardDescription.displayName = 'CardDescription';
|
|
55
|
+
|
|
56
|
+
const CardContent = React.forwardRef<
|
|
57
|
+
HTMLDivElement,
|
|
58
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
59
|
+
>(({ className, ...props }, ref) => (
|
|
60
|
+
<div ref={ref} className={cn('p-6 pt-0', className)} {...props} />
|
|
61
|
+
));
|
|
62
|
+
CardContent.displayName = 'CardContent';
|
|
63
|
+
|
|
64
|
+
const CardFooter = React.forwardRef<
|
|
65
|
+
HTMLDivElement,
|
|
66
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
67
|
+
>(({ className, ...props }, ref) => (
|
|
68
|
+
<div
|
|
69
|
+
ref={ref}
|
|
70
|
+
className={cn('flex items-center p-6 pt-0', className)}
|
|
71
|
+
{...props}
|
|
72
|
+
/>
|
|
73
|
+
));
|
|
74
|
+
CardFooter.displayName = 'CardFooter';
|
|
75
|
+
|
|
76
|
+
export {
|
|
77
|
+
Card,
|
|
78
|
+
CardHeader,
|
|
79
|
+
CardFooter,
|
|
80
|
+
CardTitle,
|
|
81
|
+
CardDescription,
|
|
82
|
+
CardContent,
|
|
83
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ComponentConfig } from '@foundrykit/types';
|
|
2
|
+
|
|
3
|
+
export const checkboxConfig: ComponentConfig = {
|
|
4
|
+
name: 'Checkbox',
|
|
5
|
+
description: 'Accessible checkbox component built with Radix UI primitives',
|
|
6
|
+
category: 'primitives',
|
|
7
|
+
tags: ['form', 'input', 'interactive'],
|
|
8
|
+
preview: {
|
|
9
|
+
type: 'static',
|
|
10
|
+
html: '<div class="flex h-12 w-full items-center justify-center rounded-md bg-gray-200"><div class="h-4 w-4 rounded border border-gray-400 bg-white flex items-center justify-center"><div class="h-3 w-3 bg-blue-500 rounded-sm"></div></div></div>',
|
|
11
|
+
},
|
|
12
|
+
variants: [
|
|
13
|
+
{
|
|
14
|
+
name: 'Default',
|
|
15
|
+
description: 'Standard checkbox with default styling',
|
|
16
|
+
code: '<Checkbox />',
|
|
17
|
+
preview: {
|
|
18
|
+
type: 'component',
|
|
19
|
+
component: 'Checkbox',
|
|
20
|
+
props: {},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'Checked',
|
|
25
|
+
description: 'Checkbox in checked state',
|
|
26
|
+
code: '<Checkbox defaultChecked />',
|
|
27
|
+
preview: {
|
|
28
|
+
type: 'component',
|
|
29
|
+
component: 'Checkbox',
|
|
30
|
+
props: { defaultChecked: true },
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'Disabled',
|
|
35
|
+
description: 'Disabled checkbox',
|
|
36
|
+
code: '<Checkbox disabled />',
|
|
37
|
+
preview: {
|
|
38
|
+
type: 'component',
|
|
39
|
+
component: 'Checkbox',
|
|
40
|
+
props: { disabled: true },
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
dependencies: ['utils'],
|
|
45
|
+
files: ['components/primitives/checkbox/index.tsx'],
|
|
46
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
5
|
+
import { CheckIcon } from 'lucide-react';
|
|
6
|
+
|
|
7
|
+
import { cn } from '@foundrykit/utils';
|
|
8
|
+
|
|
9
|
+
function Checkbox({
|
|
10
|
+
className,
|
|
11
|
+
...props
|
|
12
|
+
}: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
|
|
13
|
+
return (
|
|
14
|
+
<CheckboxPrimitive.Root
|
|
15
|
+
data-slot='checkbox'
|
|
16
|
+
className={cn(
|
|
17
|
+
'border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive shadow-xs peer size-4 shrink-0 rounded-[4px] border outline-none transition-shadow focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50',
|
|
18
|
+
className
|
|
19
|
+
)}
|
|
20
|
+
{...props}
|
|
21
|
+
>
|
|
22
|
+
<CheckboxPrimitive.Indicator
|
|
23
|
+
data-slot='checkbox-indicator'
|
|
24
|
+
className='flex items-center justify-center text-current transition-none'
|
|
25
|
+
>
|
|
26
|
+
<CheckIcon className='size-3.5' />
|
|
27
|
+
</CheckboxPrimitive.Indicator>
|
|
28
|
+
</CheckboxPrimitive.Root>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { Checkbox };
|