@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,185 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
5
|
+
import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from 'lucide-react';
|
|
6
|
+
|
|
7
|
+
import { cn } from '@foundrykit/utils';
|
|
8
|
+
|
|
9
|
+
function Select({
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof SelectPrimitive.Root>) {
|
|
12
|
+
return <SelectPrimitive.Root data-slot='select' {...props} />;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function SelectGroup({
|
|
16
|
+
...props
|
|
17
|
+
}: React.ComponentProps<typeof SelectPrimitive.Group>) {
|
|
18
|
+
return <SelectPrimitive.Group data-slot='select-group' {...props} />;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function SelectValue({
|
|
22
|
+
...props
|
|
23
|
+
}: React.ComponentProps<typeof SelectPrimitive.Value>) {
|
|
24
|
+
return <SelectPrimitive.Value data-slot='select-value' {...props} />;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function SelectTrigger({
|
|
28
|
+
className,
|
|
29
|
+
size = 'default',
|
|
30
|
+
children,
|
|
31
|
+
...props
|
|
32
|
+
}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
|
|
33
|
+
size?: 'sm' | 'default';
|
|
34
|
+
}) {
|
|
35
|
+
return (
|
|
36
|
+
<SelectPrimitive.Trigger
|
|
37
|
+
data-slot='select-trigger'
|
|
38
|
+
data-size={size}
|
|
39
|
+
className={cn(
|
|
40
|
+
"border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 shadow-xs flex w-fit items-center justify-between gap-2 whitespace-nowrap rounded-md border bg-transparent px-3 py-2 text-sm outline-none transition-[color,box-shadow] focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
41
|
+
className
|
|
42
|
+
)}
|
|
43
|
+
{...props}
|
|
44
|
+
>
|
|
45
|
+
{children}
|
|
46
|
+
<SelectPrimitive.Icon asChild>
|
|
47
|
+
<ChevronDownIcon className='size-4 opacity-50' />
|
|
48
|
+
</SelectPrimitive.Icon>
|
|
49
|
+
</SelectPrimitive.Trigger>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function SelectContent({
|
|
54
|
+
className,
|
|
55
|
+
children,
|
|
56
|
+
position = 'popper',
|
|
57
|
+
...props
|
|
58
|
+
}: React.ComponentProps<typeof SelectPrimitive.Content>) {
|
|
59
|
+
return (
|
|
60
|
+
<SelectPrimitive.Portal>
|
|
61
|
+
<SelectPrimitive.Content
|
|
62
|
+
data-slot='select-content'
|
|
63
|
+
className={cn(
|
|
64
|
+
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 max-h-(--radix-select-content-available-height) origin-(--radix-select-content-transform-origin) relative z-50 min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border shadow-md',
|
|
65
|
+
position === 'popper' &&
|
|
66
|
+
'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
|
|
67
|
+
className
|
|
68
|
+
)}
|
|
69
|
+
position={position}
|
|
70
|
+
{...props}
|
|
71
|
+
>
|
|
72
|
+
<SelectScrollUpButton />
|
|
73
|
+
<SelectPrimitive.Viewport
|
|
74
|
+
className={cn(
|
|
75
|
+
'p-1',
|
|
76
|
+
position === 'popper' &&
|
|
77
|
+
'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1'
|
|
78
|
+
)}
|
|
79
|
+
>
|
|
80
|
+
{children}
|
|
81
|
+
</SelectPrimitive.Viewport>
|
|
82
|
+
<SelectScrollDownButton />
|
|
83
|
+
</SelectPrimitive.Content>
|
|
84
|
+
</SelectPrimitive.Portal>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function SelectLabel({
|
|
89
|
+
className,
|
|
90
|
+
...props
|
|
91
|
+
}: React.ComponentProps<typeof SelectPrimitive.Label>) {
|
|
92
|
+
return (
|
|
93
|
+
<SelectPrimitive.Label
|
|
94
|
+
data-slot='select-label'
|
|
95
|
+
className={cn('text-muted-foreground px-2 py-1.5 text-xs', className)}
|
|
96
|
+
{...props}
|
|
97
|
+
/>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function SelectItem({
|
|
102
|
+
className,
|
|
103
|
+
children,
|
|
104
|
+
...props
|
|
105
|
+
}: React.ComponentProps<typeof SelectPrimitive.Item>) {
|
|
106
|
+
return (
|
|
107
|
+
<SelectPrimitive.Item
|
|
108
|
+
data-slot='select-item'
|
|
109
|
+
className={cn(
|
|
110
|
+
"focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground outline-hidden *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2 relative flex w-full cursor-default select-none items-center gap-2 rounded-sm py-1.5 pl-2 pr-8 text-sm data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
111
|
+
className
|
|
112
|
+
)}
|
|
113
|
+
{...props}
|
|
114
|
+
>
|
|
115
|
+
<span className='absolute right-2 flex size-3.5 items-center justify-center'>
|
|
116
|
+
<SelectPrimitive.ItemIndicator>
|
|
117
|
+
<CheckIcon className='size-4' />
|
|
118
|
+
</SelectPrimitive.ItemIndicator>
|
|
119
|
+
</span>
|
|
120
|
+
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
|
121
|
+
</SelectPrimitive.Item>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function SelectSeparator({
|
|
126
|
+
className,
|
|
127
|
+
...props
|
|
128
|
+
}: React.ComponentProps<typeof SelectPrimitive.Separator>) {
|
|
129
|
+
return (
|
|
130
|
+
<SelectPrimitive.Separator
|
|
131
|
+
data-slot='select-separator'
|
|
132
|
+
className={cn('bg-border pointer-events-none -mx-1 my-1 h-px', className)}
|
|
133
|
+
{...props}
|
|
134
|
+
/>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function SelectScrollUpButton({
|
|
139
|
+
className,
|
|
140
|
+
...props
|
|
141
|
+
}: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) {
|
|
142
|
+
return (
|
|
143
|
+
<SelectPrimitive.ScrollUpButton
|
|
144
|
+
data-slot='select-scroll-up-button'
|
|
145
|
+
className={cn(
|
|
146
|
+
'flex cursor-default items-center justify-center py-1',
|
|
147
|
+
className
|
|
148
|
+
)}
|
|
149
|
+
{...props}
|
|
150
|
+
>
|
|
151
|
+
<ChevronUpIcon className='size-4' />
|
|
152
|
+
</SelectPrimitive.ScrollUpButton>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function SelectScrollDownButton({
|
|
157
|
+
className,
|
|
158
|
+
...props
|
|
159
|
+
}: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) {
|
|
160
|
+
return (
|
|
161
|
+
<SelectPrimitive.ScrollDownButton
|
|
162
|
+
data-slot='select-scroll-down-button'
|
|
163
|
+
className={cn(
|
|
164
|
+
'flex cursor-default items-center justify-center py-1',
|
|
165
|
+
className
|
|
166
|
+
)}
|
|
167
|
+
{...props}
|
|
168
|
+
>
|
|
169
|
+
<ChevronDownIcon className='size-4' />
|
|
170
|
+
</SelectPrimitive.ScrollDownButton>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export {
|
|
175
|
+
Select,
|
|
176
|
+
SelectContent,
|
|
177
|
+
SelectGroup,
|
|
178
|
+
SelectItem,
|
|
179
|
+
SelectLabel,
|
|
180
|
+
SelectScrollDownButton,
|
|
181
|
+
SelectScrollUpButton,
|
|
182
|
+
SelectSeparator,
|
|
183
|
+
SelectTrigger,
|
|
184
|
+
SelectValue,
|
|
185
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ComponentConfig } from '@foundrykit/types';
|
|
2
|
+
|
|
3
|
+
export const separatorConfig: ComponentConfig = {
|
|
4
|
+
name: 'Separator',
|
|
5
|
+
description: 'Visual separator component for dividing content',
|
|
6
|
+
category: 'primitives',
|
|
7
|
+
tags: ['layout', 'ui'],
|
|
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="w-full h-px bg-gray-300"></div></div>',
|
|
11
|
+
},
|
|
12
|
+
variants: [
|
|
13
|
+
{
|
|
14
|
+
name: 'Default',
|
|
15
|
+
description: 'Basic horizontal separator',
|
|
16
|
+
code: '<Separator />',
|
|
17
|
+
preview: {
|
|
18
|
+
type: 'component',
|
|
19
|
+
component: 'Separator',
|
|
20
|
+
props: {},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'Vertical',
|
|
25
|
+
description: 'Vertical separator for horizontal layouts',
|
|
26
|
+
code: '<div class="flex h-4 items-center space-x-4"><div>Left</div><Separator orientation="vertical" /><div>Right</div></div>',
|
|
27
|
+
preview: {
|
|
28
|
+
type: 'component',
|
|
29
|
+
component: 'Separator',
|
|
30
|
+
props: { orientation: 'vertical' },
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'With Text',
|
|
35
|
+
description: 'Separator with centered text',
|
|
36
|
+
code: `<div class="relative">
|
|
37
|
+
<div class="absolute inset-0 flex items-center">
|
|
38
|
+
<Separator />
|
|
39
|
+
</div>
|
|
40
|
+
<div class="relative flex justify-center text-xs uppercase">
|
|
41
|
+
<span class="bg-background px-2 text-muted-foreground">Or continue with</span>
|
|
42
|
+
</div>
|
|
43
|
+
</div>`,
|
|
44
|
+
preview: {
|
|
45
|
+
type: 'component',
|
|
46
|
+
component: 'Separator',
|
|
47
|
+
props: {},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'Custom Styling',
|
|
52
|
+
description: 'Separator with custom styling',
|
|
53
|
+
code: '<Separator className="my-4 bg-blue-200" />',
|
|
54
|
+
preview: {
|
|
55
|
+
type: 'component',
|
|
56
|
+
component: 'Separator',
|
|
57
|
+
props: { className: 'my-4 bg-blue-200' },
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
dependencies: ['utils'],
|
|
62
|
+
files: ['components/primitives/separator/index.tsx'],
|
|
63
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
|
5
|
+
|
|
6
|
+
import { cn } from '@foundrykit/utils';
|
|
7
|
+
|
|
8
|
+
function Separator({
|
|
9
|
+
className,
|
|
10
|
+
orientation = 'horizontal',
|
|
11
|
+
decorative = true,
|
|
12
|
+
...props
|
|
13
|
+
}: React.ComponentProps<typeof SeparatorPrimitive.Root>) {
|
|
14
|
+
return (
|
|
15
|
+
<SeparatorPrimitive.Root
|
|
16
|
+
data-slot='separator'
|
|
17
|
+
decorative={decorative}
|
|
18
|
+
orientation={orientation}
|
|
19
|
+
className={cn(
|
|
20
|
+
'bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=vertical]:h-full data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px',
|
|
21
|
+
className
|
|
22
|
+
)}
|
|
23
|
+
{...props}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { Separator };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ComponentConfig } from '@foundrykit/types';
|
|
2
|
+
|
|
3
|
+
export const skeletonConfig: ComponentConfig = {
|
|
4
|
+
name: 'Skeleton',
|
|
5
|
+
description: 'Skeleton loading component for content placeholders',
|
|
6
|
+
category: 'primitives',
|
|
7
|
+
tags: ['loading', 'ui'],
|
|
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-32 rounded bg-gray-300 animate-pulse"></div></div>',
|
|
11
|
+
},
|
|
12
|
+
variants: [
|
|
13
|
+
{
|
|
14
|
+
name: 'Default',
|
|
15
|
+
description: 'Basic skeleton with default styling',
|
|
16
|
+
code: '<Skeleton className="h-4 w-[250px]" />',
|
|
17
|
+
preview: {
|
|
18
|
+
type: 'component',
|
|
19
|
+
component: 'Skeleton',
|
|
20
|
+
props: { className: 'h-4 w-[250px]' },
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'Card Layout',
|
|
25
|
+
description: 'Skeleton for card content layout',
|
|
26
|
+
code: `<div class="flex flex-col space-y-3">
|
|
27
|
+
<Skeleton className="h-[125px] w-[250px] rounded-xl" />
|
|
28
|
+
<div class="space-y-2">
|
|
29
|
+
<Skeleton className="h-4 w-[250px]" />
|
|
30
|
+
<Skeleton className="h-4 w-[200px]" />
|
|
31
|
+
</div>
|
|
32
|
+
</div>`,
|
|
33
|
+
preview: {
|
|
34
|
+
type: 'component',
|
|
35
|
+
component: 'Skeleton',
|
|
36
|
+
props: { className: 'h-4 w-[250px]' },
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'Avatar',
|
|
41
|
+
description: 'Skeleton for avatar placeholder',
|
|
42
|
+
code: '<Skeleton className="h-12 w-12 rounded-full" />',
|
|
43
|
+
preview: {
|
|
44
|
+
type: 'component',
|
|
45
|
+
component: 'Skeleton',
|
|
46
|
+
props: { className: 'h-12 w-12 rounded-full' },
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'List Items',
|
|
51
|
+
description: 'Skeleton for list item layout',
|
|
52
|
+
code: `<div class="space-y-4">
|
|
53
|
+
<div class="flex items-center space-x-4">
|
|
54
|
+
<Skeleton className="h-12 w-12 rounded-full" />
|
|
55
|
+
<div class="space-y-2">
|
|
56
|
+
<Skeleton className="h-4 w-[250px]" />
|
|
57
|
+
<Skeleton className="h-4 w-[200px]" />
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
<div class="flex items-center space-x-4">
|
|
61
|
+
<Skeleton className="h-12 w-12 rounded-full" />
|
|
62
|
+
<div class="space-y-2">
|
|
63
|
+
<Skeleton className="h-4 w-[250px]" />
|
|
64
|
+
<Skeleton className="h-4 w-[200px]" />
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
</div>`,
|
|
68
|
+
preview: {
|
|
69
|
+
type: 'component',
|
|
70
|
+
component: 'Skeleton',
|
|
71
|
+
props: { className: 'h-4 w-[250px]' },
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
dependencies: ['utils'],
|
|
76
|
+
files: ['components/primitives/skeleton/index.tsx'],
|
|
77
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cn } from '@foundrykit/utils';
|
|
2
|
+
|
|
3
|
+
function Skeleton({ className, ...props }: React.ComponentProps<'div'>) {
|
|
4
|
+
return (
|
|
5
|
+
<div
|
|
6
|
+
data-slot='skeleton'
|
|
7
|
+
className={cn('bg-accent animate-pulse rounded-md', className)}
|
|
8
|
+
{...props}
|
|
9
|
+
/>
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { Skeleton };
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { ComponentConfig } from '@foundrykit/types';
|
|
2
|
+
|
|
3
|
+
export const switchConfig: ComponentConfig = {
|
|
4
|
+
name: 'Switch',
|
|
5
|
+
description: 'Toggle switch component for boolean values',
|
|
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-6 w-11 rounded-full bg-blue-500 flex items-center justify-end px-1"><div class="h-4 w-4 rounded-full bg-white"></div></div></div>',
|
|
11
|
+
},
|
|
12
|
+
variants: [
|
|
13
|
+
{
|
|
14
|
+
name: 'Default',
|
|
15
|
+
description: 'Basic switch with default styling',
|
|
16
|
+
code: '<Switch />',
|
|
17
|
+
preview: {
|
|
18
|
+
type: 'component',
|
|
19
|
+
component: 'Switch',
|
|
20
|
+
props: {},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'With Label',
|
|
25
|
+
description: 'Switch with associated label',
|
|
26
|
+
code: `<div class="flex items-center space-x-2">
|
|
27
|
+
<Switch id="airplane-mode" />
|
|
28
|
+
<Label htmlFor="airplane-mode">Airplane Mode</Label>
|
|
29
|
+
</div>`,
|
|
30
|
+
preview: {
|
|
31
|
+
type: 'component',
|
|
32
|
+
component: 'div',
|
|
33
|
+
props: {
|
|
34
|
+
className: 'flex items-center space-x-2',
|
|
35
|
+
children: [
|
|
36
|
+
{
|
|
37
|
+
component: 'Switch',
|
|
38
|
+
props: { id: 'airplane-mode' },
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
component: 'Label',
|
|
42
|
+
props: { htmlFor: 'airplane-mode', children: 'Airplane Mode' },
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'Checked',
|
|
50
|
+
description: 'Switch in checked state',
|
|
51
|
+
code: '<Switch defaultChecked />',
|
|
52
|
+
preview: {
|
|
53
|
+
type: 'component',
|
|
54
|
+
component: 'Switch',
|
|
55
|
+
props: { defaultChecked: true },
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'Disabled',
|
|
60
|
+
description: 'Disabled switch',
|
|
61
|
+
code: `<div class="flex items-center space-x-2">
|
|
62
|
+
<Switch disabled />
|
|
63
|
+
<Label htmlFor="disabled" className="text-muted-foreground">Disabled</Label>
|
|
64
|
+
</div>`,
|
|
65
|
+
preview: {
|
|
66
|
+
type: 'component',
|
|
67
|
+
component: 'div',
|
|
68
|
+
props: {
|
|
69
|
+
className: 'flex items-center space-x-2',
|
|
70
|
+
children: [
|
|
71
|
+
{
|
|
72
|
+
component: 'Switch',
|
|
73
|
+
props: { disabled: true },
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
component: 'Label',
|
|
77
|
+
props: {
|
|
78
|
+
htmlFor: 'disabled',
|
|
79
|
+
className: 'text-muted-foreground',
|
|
80
|
+
children: 'Disabled'
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: 'Multiple Switches',
|
|
89
|
+
description: 'Multiple switches with different states',
|
|
90
|
+
code: `<div class="space-y-4">
|
|
91
|
+
<div class="flex items-center justify-between">
|
|
92
|
+
<Label htmlFor="notifications">Notifications</Label>
|
|
93
|
+
<Switch id="notifications" defaultChecked />
|
|
94
|
+
</div>
|
|
95
|
+
<div class="flex items-center justify-between">
|
|
96
|
+
<Label htmlFor="marketing">Marketing emails</Label>
|
|
97
|
+
<Switch id="marketing" />
|
|
98
|
+
</div>
|
|
99
|
+
<div class="flex items-center justify-between">
|
|
100
|
+
<Label htmlFor="updates">System updates</Label>
|
|
101
|
+
<Switch id="updates" defaultChecked />
|
|
102
|
+
</div>
|
|
103
|
+
</div>`,
|
|
104
|
+
preview: {
|
|
105
|
+
type: 'component',
|
|
106
|
+
component: 'div',
|
|
107
|
+
props: {
|
|
108
|
+
className: 'space-y-4',
|
|
109
|
+
children: [
|
|
110
|
+
{
|
|
111
|
+
component: 'div',
|
|
112
|
+
props: {
|
|
113
|
+
className: 'flex items-center justify-between',
|
|
114
|
+
children: [
|
|
115
|
+
{
|
|
116
|
+
component: 'Label',
|
|
117
|
+
props: { htmlFor: 'notifications', children: 'Notifications' },
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
component: 'Switch',
|
|
121
|
+
props: { id: 'notifications', defaultChecked: true },
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
component: 'div',
|
|
128
|
+
props: {
|
|
129
|
+
className: 'flex items-center justify-between',
|
|
130
|
+
children: [
|
|
131
|
+
{
|
|
132
|
+
component: 'Label',
|
|
133
|
+
props: { htmlFor: 'marketing', children: 'Marketing emails' },
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
component: 'Switch',
|
|
137
|
+
props: { id: 'marketing' },
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
component: 'div',
|
|
144
|
+
props: {
|
|
145
|
+
className: 'flex items-center justify-between',
|
|
146
|
+
children: [
|
|
147
|
+
{
|
|
148
|
+
component: 'Label',
|
|
149
|
+
props: { htmlFor: 'updates', children: 'System updates' },
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
component: 'Switch',
|
|
153
|
+
props: { id: 'updates', defaultChecked: true },
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
],
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
dependencies: ['utils', 'label'],
|
|
164
|
+
files: ['components/primitives/switch/index.tsx'],
|
|
165
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import * as SwitchPrimitive from '@radix-ui/react-switch';
|
|
5
|
+
|
|
6
|
+
import { cn } from '@foundrykit/utils';
|
|
7
|
+
|
|
8
|
+
function Switch({
|
|
9
|
+
className,
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof SwitchPrimitive.Root>) {
|
|
12
|
+
return (
|
|
13
|
+
<SwitchPrimitive.Root
|
|
14
|
+
data-slot='switch'
|
|
15
|
+
className={cn(
|
|
16
|
+
'data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 shadow-xs peer inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent outline-none transition-all focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50',
|
|
17
|
+
className
|
|
18
|
+
)}
|
|
19
|
+
{...props}
|
|
20
|
+
>
|
|
21
|
+
<SwitchPrimitive.Thumb
|
|
22
|
+
data-slot='switch-thumb'
|
|
23
|
+
className={cn(
|
|
24
|
+
'bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0'
|
|
25
|
+
)}
|
|
26
|
+
/>
|
|
27
|
+
</SwitchPrimitive.Root>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { Switch };
|