@foundrykit/primitives 2.0.9 → 2.0.10

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 (131) hide show
  1. package/dist/chunk-3NQR7JZR.js +128 -0
  2. package/dist/chunk-B5YCE3UP.js +57 -0
  3. package/dist/chunk-F2TEA6ER.js +138 -0
  4. package/dist/chunk-SIQHWNPH.js +45 -0
  5. package/dist/components/dialog/index.cjs +182 -0
  6. package/dist/components/dialog/index.d.cts +38 -0
  7. package/dist/components/dialog/index.d.ts +38 -0
  8. package/dist/components/dialog/index.js +25 -0
  9. package/dist/components/input-group/index.cjs +270 -0
  10. package/dist/components/input-group/index.d.cts +44 -0
  11. package/dist/components/input-group/index.d.ts +44 -0
  12. package/dist/components/input-group/index.js +153 -0
  13. package/dist/components/sheet/index.cjs +170 -0
  14. package/dist/components/sheet/index.d.cts +31 -0
  15. package/dist/components/sheet/index.d.ts +31 -0
  16. package/dist/components/sheet/index.js +21 -0
  17. package/dist/components/toggle/index.cjs +81 -0
  18. package/dist/components/toggle/index.d.cts +26 -0
  19. package/dist/components/toggle/index.d.ts +26 -0
  20. package/dist/components/toggle/index.js +9 -0
  21. package/dist/components/tooltip/index.cjs +95 -0
  22. package/dist/components/tooltip/index.d.cts +25 -0
  23. package/dist/components/tooltip/index.d.ts +25 -0
  24. package/dist/components/tooltip/index.js +13 -0
  25. package/dist/index.d.cts +11 -105
  26. package/dist/index.d.ts +11 -105
  27. package/dist/index.js +93 -399
  28. package/package.json +200 -8
  29. package/CHANGELOG.md +0 -230
  30. package/postcss.config.mjs +0 -6
  31. package/registry.json +0 -64
  32. package/src/components/accordion/config.ts +0 -28
  33. package/src/components/accordion/index.tsx +0 -80
  34. package/src/components/alert/config.ts +0 -40
  35. package/src/components/alert/index.tsx +0 -80
  36. package/src/components/alert-dialog/config.ts +0 -28
  37. package/src/components/alert-dialog/index.tsx +0 -188
  38. package/src/components/aspect-ratio/config.ts +0 -27
  39. package/src/components/aspect-ratio/index.tsx +0 -24
  40. package/src/components/avatar/config.ts +0 -46
  41. package/src/components/avatar/index.tsx +0 -67
  42. package/src/components/badge/config.ts +0 -56
  43. package/src/components/badge/index.tsx +0 -56
  44. package/src/components/breadcrumb/config.ts +0 -121
  45. package/src/components/breadcrumb/index.tsx +0 -127
  46. package/src/components/button/config.ts +0 -97
  47. package/src/components/button/index.tsx +0 -86
  48. package/src/components/button-group/config.ts +0 -39
  49. package/src/components/button-group/index.tsx +0 -99
  50. package/src/components/card/config.ts +0 -89
  51. package/src/components/card/index.tsx +0 -90
  52. package/src/components/checkbox/config.ts +0 -46
  53. package/src/components/checkbox/index.tsx +0 -41
  54. package/src/components/collapsible/config.ts +0 -27
  55. package/src/components/collapsible/index.tsx +0 -47
  56. package/src/components/context-menu/config.ts +0 -28
  57. package/src/components/context-menu/index.tsx +0 -271
  58. package/src/components/dialog/config.ts +0 -582
  59. package/src/components/dialog/index.tsx +0 -162
  60. package/src/components/direction/config.ts +0 -28
  61. package/src/components/direction/index.tsx +0 -27
  62. package/src/components/drawer/config.ts +0 -28
  63. package/src/components/drawer/index.tsx +0 -153
  64. package/src/components/dropdown/config.ts +0 -262
  65. package/src/components/dropdown/index.tsx +0 -280
  66. package/src/components/empty/config.ts +0 -38
  67. package/src/components/empty/index.tsx +0 -127
  68. package/src/components/field/config.ts +0 -40
  69. package/src/components/field/index.tsx +0 -252
  70. package/src/components/hover-card/config.ts +0 -27
  71. package/src/components/hover-card/index.tsx +0 -56
  72. package/src/components/input/config.ts +0 -64
  73. package/src/components/input/index.tsx +0 -32
  74. package/src/components/input-group/config.ts +0 -209
  75. package/src/components/input-group/index.tsx +0 -177
  76. package/src/components/item/config.ts +0 -52
  77. package/src/components/item/index.tsx +0 -215
  78. package/src/components/kbd/config.ts +0 -38
  79. package/src/components/kbd/index.tsx +0 -40
  80. package/src/components/label/config.ts +0 -72
  81. package/src/components/label/index.tsx +0 -32
  82. package/src/components/menubar/config.ts +0 -28
  83. package/src/components/menubar/index.tsx +0 -295
  84. package/src/components/native-select/config.ts +0 -40
  85. package/src/components/native-select/index.tsx +0 -40
  86. package/src/components/navigation-menu/config.ts +0 -32
  87. package/src/components/navigation-menu/index.tsx +0 -188
  88. package/src/components/popover/config.ts +0 -222
  89. package/src/components/popover/index.tsx +0 -60
  90. package/src/components/progress/config.ts +0 -42
  91. package/src/components/progress/index.tsx +0 -39
  92. package/src/components/radio-group/config.ts +0 -303
  93. package/src/components/radio-group/index.tsx +0 -58
  94. package/src/components/resizable/config.ts +0 -28
  95. package/src/components/resizable/index.tsx +0 -67
  96. package/src/components/scroll-area/config.ts +0 -17
  97. package/src/components/scroll-area/index.tsx +0 -70
  98. package/src/components/select/config.ts +0 -277
  99. package/src/components/select/index.tsx +0 -202
  100. package/src/components/separator/config.ts +0 -63
  101. package/src/components/separator/index.tsx +0 -38
  102. package/src/components/sheet/config.ts +0 -16
  103. package/src/components/sheet/index.tsx +0 -153
  104. package/src/components/skeleton/config.ts +0 -77
  105. package/src/components/skeleton/index.tsx +0 -22
  106. package/src/components/slider/config.ts +0 -46
  107. package/src/components/slider/index.tsx +0 -76
  108. package/src/components/sonner/config.ts +0 -27
  109. package/src/components/sonner/index.tsx +0 -37
  110. package/src/components/spinner/config.ts +0 -40
  111. package/src/components/spinner/index.tsx +0 -30
  112. package/src/components/switch/config.ts +0 -171
  113. package/src/components/switch/index.tsx +0 -40
  114. package/src/components/table/config.ts +0 -38
  115. package/src/components/table/index.tsx +0 -135
  116. package/src/components/tabs/config.ts +0 -335
  117. package/src/components/tabs/index.tsx +0 -82
  118. package/src/components/textarea/config.ts +0 -117
  119. package/src/components/textarea/index.tsx +0 -26
  120. package/src/components/toggle/config.ts +0 -67
  121. package/src/components/toggle/index.tsx +0 -59
  122. package/src/components/toggle-group/config.ts +0 -46
  123. package/src/components/toggle-group/index.tsx +0 -106
  124. package/src/components/tooltip/config.ts +0 -16
  125. package/src/components/tooltip/index.tsx +0 -75
  126. package/src/components/typography/config.ts +0 -38
  127. package/src/components/typography/index.tsx +0 -172
  128. package/src/index.ts +0 -291
  129. package/tsconfig.json +0 -9
  130. package/tsconfig.lint.json +0 -8
  131. package/tsup.config.ts +0 -55
@@ -1,40 +0,0 @@
1
- import type { ComponentConfig } from '@foundrykit/types';
2
-
3
- export const AlertConfig: ComponentConfig = {
4
- name: 'Alert',
5
- description:
6
- 'Displays a callout for user attention with an optional icon, title, and description.',
7
- category: 'primitives',
8
- tags: ['alert', 'callout', 'feedback'],
9
- preview: {
10
- type: 'static',
11
- html: '<div class="w-full rounded-lg border border-gray-300 bg-gray-100 px-4 py-3"><div class="mb-1 h-3 w-24 rounded bg-gray-400"></div><div class="h-2 w-40 rounded bg-gray-300"></div></div>',
12
- },
13
- variants: [
14
- {
15
- name: 'Default',
16
- description: 'Default alert',
17
- code: '<Alert><AlertTitle>Heads up!</AlertTitle><AlertDescription>You can add components.</AlertDescription></Alert>',
18
- preview: {
19
- type: 'component',
20
- component: 'Alert',
21
- props: {},
22
- },
23
- },
24
- {
25
- name: 'Destructive',
26
- description: 'Destructive alert',
27
- code: '<Alert variant="destructive"><AlertTitle>Error</AlertTitle><AlertDescription>Something went wrong.</AlertDescription></Alert>',
28
- preview: {
29
- type: 'component',
30
- component: 'Alert',
31
- props: {
32
- variant: 'destructive',
33
- },
34
- },
35
- },
36
- ],
37
- dependencies: ['utils'],
38
- packageDependencies: ['class-variance-authority'],
39
- files: ['components/primitives/alert/index.tsx'],
40
- };
@@ -1,80 +0,0 @@
1
- import { cn } from '@foundrykit/utils';
2
- import { cva, type VariantProps } from 'class-variance-authority';
3
- import type * as React from 'react';
4
-
5
- const alertVariants = cva(
6
- 'relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-4 py-3 text-sm has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current',
7
- {
8
- variants: {
9
- variant: {
10
- default: 'bg-background text-foreground',
11
- destructive:
12
- 'text-destructive bg-background *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current',
13
- },
14
- },
15
- defaultVariants: {
16
- variant: 'default',
17
- },
18
- }
19
- );
20
-
21
- /**
22
- * Callout banner for surfacing a short, important message. Compose with
23
- * {@link AlertTitle} and {@link AlertDescription}, and optionally lead with a
24
- * lucide icon. Styled via {@link alertVariants} with a `variant`
25
- * (default, destructive).
26
- *
27
- * @example
28
- * ```tsx
29
- * <Alert variant="destructive">
30
- * <AlertCircleIcon />
31
- * <AlertTitle>Something went wrong</AlertTitle>
32
- * <AlertDescription>Please try again later.</AlertDescription>
33
- * </Alert>
34
- * ```
35
- */
36
- function Alert({
37
- className,
38
- variant,
39
- ...props
40
- }: React.ComponentProps<'div'> & VariantProps<typeof alertVariants>) {
41
- return (
42
- <div
43
- data-slot='alert'
44
- role='alert'
45
- className={cn(alertVariants({ variant }), className)}
46
- {...props}
47
- />
48
- );
49
- }
50
-
51
- function AlertTitle({ className, ...props }: React.ComponentProps<'div'>) {
52
- return (
53
- <div
54
- data-slot='alert-title'
55
- className={cn(
56
- 'col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight',
57
- className
58
- )}
59
- {...props}
60
- />
61
- );
62
- }
63
-
64
- function AlertDescription({
65
- className,
66
- ...props
67
- }: React.ComponentProps<'div'>) {
68
- return (
69
- <div
70
- data-slot='alert-description'
71
- className={cn(
72
- 'text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed',
73
- className
74
- )}
75
- {...props}
76
- />
77
- );
78
- }
79
-
80
- export { Alert, AlertDescription, AlertTitle, alertVariants };
@@ -1,28 +0,0 @@
1
- import type { ComponentConfig } from '@foundrykit/types';
2
-
3
- export const AlertDialogConfig: ComponentConfig = {
4
- name: 'Alert Dialog',
5
- description:
6
- 'A modal dialog that interrupts the user with important content and expects a response.',
7
- category: 'primitives',
8
- tags: ['alert-dialog', 'modal', 'overlay', 'confirmation'],
9
- preview: {
10
- type: 'static',
11
- html: '<div class="flex h-12 w-full items-center rounded-md border border-gray-300 bg-gray-100 px-3"><span class="text-sm text-gray-600">Alert Dialog</span></div>',
12
- },
13
- variants: [
14
- {
15
- name: 'Default',
16
- description: 'Default alert dialog',
17
- code: '<AlertDialog>...</AlertDialog>',
18
- preview: {
19
- type: 'component',
20
- component: 'AlertDialog',
21
- props: {},
22
- },
23
- },
24
- ],
25
- dependencies: ['utils'],
26
- packageDependencies: ['@radix-ui/react-alert-dialog'],
27
- files: ['components/primitives/alert-dialog/index.tsx'],
28
- };
@@ -1,188 +0,0 @@
1
- 'use client';
2
-
3
- import { cn } from '@foundrykit/utils';
4
- import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
5
- import type * as React from 'react';
6
-
7
- /**
8
- * Modal confirmation dialog built on Radix `AlertDialog.Root` that interrupts
9
- * the user with important content and expects a response. Compose with
10
- * {@link AlertDialogTrigger}, {@link AlertDialogContent},
11
- * {@link AlertDialogHeader}, {@link AlertDialogFooter},
12
- * {@link AlertDialogTitle}, {@link AlertDialogDescription},
13
- * {@link AlertDialogAction} and {@link AlertDialogCancel}.
14
- *
15
- * @example
16
- * ```tsx
17
- * <AlertDialog>
18
- * <AlertDialogTrigger>Delete</AlertDialogTrigger>
19
- * <AlertDialogContent>
20
- * <AlertDialogHeader>
21
- * <AlertDialogTitle>Are you sure?</AlertDialogTitle>
22
- * <AlertDialogDescription>This cannot be undone.</AlertDialogDescription>
23
- * </AlertDialogHeader>
24
- * <AlertDialogFooter>
25
- * <AlertDialogCancel>Cancel</AlertDialogCancel>
26
- * <AlertDialogAction>Continue</AlertDialogAction>
27
- * </AlertDialogFooter>
28
- * </AlertDialogContent>
29
- * </AlertDialog>
30
- * ```
31
- */
32
- function AlertDialog({
33
- ...props
34
- }: React.ComponentProps<typeof AlertDialogPrimitive.Root>) {
35
- return <AlertDialogPrimitive.Root data-slot='alert-dialog' {...props} />;
36
- }
37
-
38
- function AlertDialogTrigger({
39
- ...props
40
- }: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>) {
41
- return (
42
- <AlertDialogPrimitive.Trigger data-slot='alert-dialog-trigger' {...props} />
43
- );
44
- }
45
-
46
- function AlertDialogPortal({
47
- ...props
48
- }: React.ComponentProps<typeof AlertDialogPrimitive.Portal>) {
49
- return (
50
- <AlertDialogPrimitive.Portal data-slot='alert-dialog-portal' {...props} />
51
- );
52
- }
53
-
54
- function AlertDialogOverlay({
55
- className,
56
- ...props
57
- }: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>) {
58
- return (
59
- <AlertDialogPrimitive.Overlay
60
- data-slot='alert-dialog-overlay'
61
- className={cn(
62
- 'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50',
63
- className
64
- )}
65
- {...props}
66
- />
67
- );
68
- }
69
-
70
- function AlertDialogContent({
71
- className,
72
- ...props
73
- }: React.ComponentProps<typeof AlertDialogPrimitive.Content>) {
74
- return (
75
- <AlertDialogPortal>
76
- <AlertDialogOverlay />
77
- <AlertDialogPrimitive.Content
78
- data-slot='alert-dialog-content'
79
- className={cn(
80
- 'bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 motion-safe:data-[state=closed]:zoom-out-95 motion-safe:data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg',
81
- className
82
- )}
83
- {...props}
84
- />
85
- </AlertDialogPortal>
86
- );
87
- }
88
-
89
- function AlertDialogHeader({
90
- className,
91
- ...props
92
- }: React.ComponentProps<'div'>) {
93
- return (
94
- <div
95
- data-slot='alert-dialog-header'
96
- className={cn('flex flex-col gap-2 text-center sm:text-left', className)}
97
- {...props}
98
- />
99
- );
100
- }
101
-
102
- function AlertDialogFooter({
103
- className,
104
- ...props
105
- }: React.ComponentProps<'div'>) {
106
- return (
107
- <div
108
- data-slot='alert-dialog-footer'
109
- className={cn(
110
- 'flex flex-col-reverse gap-2 sm:flex-row sm:justify-end',
111
- className
112
- )}
113
- {...props}
114
- />
115
- );
116
- }
117
-
118
- function AlertDialogTitle({
119
- className,
120
- ...props
121
- }: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {
122
- return (
123
- <AlertDialogPrimitive.Title
124
- data-slot='alert-dialog-title'
125
- className={cn('text-lg font-semibold', className)}
126
- {...props}
127
- />
128
- );
129
- }
130
-
131
- function AlertDialogDescription({
132
- className,
133
- ...props
134
- }: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {
135
- return (
136
- <AlertDialogPrimitive.Description
137
- data-slot='alert-dialog-description'
138
- className={cn('text-muted-foreground text-sm', className)}
139
- {...props}
140
- />
141
- );
142
- }
143
-
144
- function AlertDialogAction({
145
- className,
146
- ...props
147
- }: React.ComponentProps<typeof AlertDialogPrimitive.Action>) {
148
- return (
149
- <AlertDialogPrimitive.Action
150
- data-slot='alert-dialog-action'
151
- className={cn(
152
- "bg-primary text-primary-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 hover:bg-primary/90 inline-flex h-9 shrink-0 items-center justify-center gap-2 rounded-md px-4 py-2 text-sm font-medium whitespace-nowrap shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 has-[>svg]:px-3 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
153
- className
154
- )}
155
- {...props}
156
- />
157
- );
158
- }
159
-
160
- function AlertDialogCancel({
161
- className,
162
- ...props
163
- }: React.ComponentProps<typeof AlertDialogPrimitive.Cancel>) {
164
- return (
165
- <AlertDialogPrimitive.Cancel
166
- data-slot='alert-dialog-cancel'
167
- className={cn(
168
- "bg-background 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:border-input dark:hover:bg-input/50 hover:bg-accent hover:text-accent-foreground inline-flex h-9 shrink-0 items-center justify-center gap-2 rounded-md border px-4 py-2 text-sm font-medium whitespace-nowrap shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 has-[>svg]:px-3 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
169
- className
170
- )}
171
- {...props}
172
- />
173
- );
174
- }
175
-
176
- export {
177
- AlertDialog,
178
- AlertDialogAction,
179
- AlertDialogCancel,
180
- AlertDialogContent,
181
- AlertDialogDescription,
182
- AlertDialogFooter,
183
- AlertDialogHeader,
184
- AlertDialogOverlay,
185
- AlertDialogPortal,
186
- AlertDialogTitle,
187
- AlertDialogTrigger,
188
- };
@@ -1,27 +0,0 @@
1
- import type { ComponentConfig } from '@foundrykit/types';
2
-
3
- export const AspectRatioConfig: ComponentConfig = {
4
- name: 'Aspect Ratio',
5
- description: 'Constrains content to a desired width-to-height ratio.',
6
- category: 'primitives',
7
- tags: ['aspect-ratio', 'media', 'layout'],
8
- preview: {
9
- type: 'static',
10
- html: '<div class="flex h-12 w-full items-center rounded-md border border-gray-300 bg-gray-100 px-3"><span class="text-sm text-gray-600">Aspect Ratio</span></div>',
11
- },
12
- variants: [
13
- {
14
- name: 'Default',
15
- description: 'Sixteen-by-nine aspect ratio',
16
- code: '<AspectRatio ratio={16 / 9}>...</AspectRatio>',
17
- preview: {
18
- type: 'component',
19
- component: 'AspectRatio',
20
- props: {},
21
- },
22
- },
23
- ],
24
- dependencies: ['utils'],
25
- packageDependencies: ['@radix-ui/react-aspect-ratio'],
26
- files: ['components/primitives/aspect-ratio/index.tsx'],
27
- };
@@ -1,24 +0,0 @@
1
- 'use client';
2
-
3
- import * as AspectRatioPrimitive from '@radix-ui/react-aspect-ratio';
4
- import type * as React from 'react';
5
-
6
- /**
7
- * Constrains its content to a given width-to-height `ratio`, built on Radix
8
- * `AspectRatio.Root`. Handy for images, video embeds and media placeholders
9
- * that must keep a consistent shape as they scale.
10
- *
11
- * @example
12
- * ```tsx
13
- * <AspectRatio ratio={16 / 9}>
14
- * <img src="/cover.jpg" alt="Cover" className="h-full w-full object-cover" />
15
- * </AspectRatio>
16
- * ```
17
- */
18
- function AspectRatio({
19
- ...props
20
- }: React.ComponentProps<typeof AspectRatioPrimitive.Root>) {
21
- return <AspectRatioPrimitive.Root data-slot='aspect-ratio' {...props} />;
22
- }
23
-
24
- export { AspectRatio };
@@ -1,46 +0,0 @@
1
- import type { ComponentConfig } from '@foundrykit/types';
2
-
3
- export const avatarConfig: ComponentConfig = {
4
- name: 'Avatar',
5
- description: 'User avatar component with image fallback and initials',
6
- category: 'primitives',
7
- tags: ['user', 'profile', 'image'],
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 h-8 w-8 items-center justify-center rounded-full bg-gray-300"><div class="h-4 w-4 rounded-full bg-gray-600"></div></div></div>',
11
- },
12
- variants: [
13
- {
14
- name: 'Default',
15
- description: 'Default avatar with fallback',
16
- code: '<Avatar>JD</Avatar>',
17
- preview: {
18
- type: 'component',
19
- component: 'Avatar',
20
- props: { children: 'JD' },
21
- },
22
- },
23
- {
24
- name: 'With Image',
25
- description: 'Avatar with user image',
26
- code: '<Avatar src="/user.jpg" alt="User" />',
27
- preview: {
28
- type: 'component',
29
- component: 'Avatar',
30
- props: { src: '/user.jpg', alt: 'User' },
31
- },
32
- },
33
- {
34
- name: 'Large',
35
- description: 'Large avatar size',
36
- code: '<Avatar size="lg">JD</Avatar>',
37
- preview: {
38
- type: 'component',
39
- component: 'Avatar',
40
- props: { size: 'lg', children: 'JD' },
41
- },
42
- },
43
- ],
44
- dependencies: ['utils'],
45
- files: ['components/primitives/avatar/index.tsx'],
46
- };
@@ -1,67 +0,0 @@
1
- 'use client';
2
-
3
- import { cn } from '@foundrykit/utils';
4
- import * as AvatarPrimitive from '@radix-ui/react-avatar';
5
- import type * as React from 'react';
6
-
7
- /**
8
- * Circular avatar container built on Radix `Avatar.Root`. Compose with
9
- * {@link AvatarImage} and {@link AvatarFallback}; the fallback shows while the
10
- * image is loading or unavailable. Defaults to a `size-8` rounded shape.
11
- *
12
- * @example
13
- * ```tsx
14
- * <Avatar>
15
- * <AvatarImage src="/user.png" alt="Jane" />
16
- * <AvatarFallback>JD</AvatarFallback>
17
- * </Avatar>
18
- * ```
19
- */
20
- function Avatar({
21
- className,
22
- ...props
23
- }: React.ComponentProps<typeof AvatarPrimitive.Root>) {
24
- return (
25
- <AvatarPrimitive.Root
26
- data-slot='avatar'
27
- className={cn(
28
- 'relative flex size-8 shrink-0 overflow-hidden rounded-full',
29
- className
30
- )}
31
- {...props}
32
- />
33
- );
34
- }
35
-
36
- /** Image element (Radix `Avatar.Image`) rendered inside an {@link Avatar}. */
37
- function AvatarImage({
38
- className,
39
- ...props
40
- }: React.ComponentProps<typeof AvatarPrimitive.Image>) {
41
- return (
42
- <AvatarPrimitive.Image
43
- data-slot='avatar-image'
44
- className={cn('aspect-square size-full', className)}
45
- {...props}
46
- />
47
- );
48
- }
49
-
50
- /** Fallback (Radix `Avatar.Fallback`) shown when the image cannot be displayed. */
51
- function AvatarFallback({
52
- className,
53
- ...props
54
- }: React.ComponentProps<typeof AvatarPrimitive.Fallback>) {
55
- return (
56
- <AvatarPrimitive.Fallback
57
- data-slot='avatar-fallback'
58
- className={cn(
59
- 'bg-muted flex size-full items-center justify-center rounded-full',
60
- className
61
- )}
62
- {...props}
63
- />
64
- );
65
- }
66
-
67
- export { Avatar, AvatarFallback, AvatarImage };
@@ -1,56 +0,0 @@
1
- import type { ComponentConfig } from '@foundrykit/types';
2
-
3
- export const badgeConfig: ComponentConfig = {
4
- name: 'Badge',
5
- description: 'Small status indicators and labels',
6
- category: 'primitives',
7
- tags: ['status', 'label', 'indicator'],
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 h-6 w-16 items-center justify-center rounded-full bg-gray-300"><div class="mr-1 h-2 w-2 rounded-full bg-gray-600"></div><div class="h-1 w-6 rounded bg-gray-600"></div></div></div>',
11
- },
12
- variants: [
13
- {
14
- name: 'Default',
15
- description: 'Default badge styling',
16
- code: '<Badge>Default</Badge>',
17
- preview: {
18
- type: 'component',
19
- component: 'Badge',
20
- props: { children: 'Default' },
21
- },
22
- },
23
- {
24
- name: 'Secondary',
25
- description: 'Secondary badge variant',
26
- code: '<Badge variant="secondary">Secondary</Badge>',
27
- preview: {
28
- type: 'component',
29
- component: 'Badge',
30
- props: { variant: 'secondary', children: 'Secondary' },
31
- },
32
- },
33
- {
34
- name: 'Destructive',
35
- description: 'Destructive badge variant',
36
- code: '<Badge variant="destructive">Error</Badge>',
37
- preview: {
38
- type: 'component',
39
- component: 'Badge',
40
- props: { variant: 'destructive', children: 'Error' },
41
- },
42
- },
43
- {
44
- name: 'Outline',
45
- description: 'Outline badge variant',
46
- code: '<Badge variant="outline">Outline</Badge>',
47
- preview: {
48
- type: 'component',
49
- component: 'Badge',
50
- props: { variant: 'outline', children: 'Outline' },
51
- },
52
- },
53
- ],
54
- dependencies: ['utils'],
55
- files: ['components/primitives/badge/index.tsx'],
56
- };
@@ -1,56 +0,0 @@
1
- import { cn } from '@foundrykit/utils';
2
- import { Slot } from '@radix-ui/react-slot';
3
- import { cva, type VariantProps } from 'class-variance-authority';
4
- import type * as React from 'react';
5
-
6
- const badgeVariants = cva(
7
- 'focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-md border px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] [&>svg]:pointer-events-none [&>svg]:size-3',
8
- {
9
- variants: {
10
- variant: {
11
- default:
12
- 'bg-primary text-primary-foreground [a&]:hover:bg-primary/90 border-transparent',
13
- secondary:
14
- 'bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90 border-transparent',
15
- destructive:
16
- 'bg-destructive [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60 border-transparent text-white',
17
- outline:
18
- 'text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground',
19
- },
20
- },
21
- defaultVariants: {
22
- variant: 'default',
23
- },
24
- }
25
- );
26
-
27
- /**
28
- * Small inline label/status indicator styled via {@link badgeVariants} with a
29
- * `variant` (default, secondary, destructive, outline). Renders a `<span>` by
30
- * default; pass `asChild` to render another element (e.g. a link) via Radix
31
- * `Slot` while keeping the badge styling.
32
- *
33
- * @example
34
- * ```tsx
35
- * <Badge variant="secondary">Beta</Badge>
36
- * ```
37
- */
38
- function Badge({
39
- className,
40
- variant,
41
- asChild = false,
42
- ...props
43
- }: React.ComponentProps<'span'> &
44
- VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
45
- const Comp = asChild ? Slot : 'span';
46
-
47
- return (
48
- <Comp
49
- data-slot='badge'
50
- className={cn(badgeVariants({ variant }), className)}
51
- {...props}
52
- />
53
- );
54
- }
55
-
56
- export { Badge, badgeVariants };