@crystallize/design-system 1.23.6 → 1.24.1

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/dist/index.mjs CHANGED
@@ -115,10 +115,49 @@ var Checkbox = forwardRef2((props, ref) => {
115
115
  });
116
116
  Checkbox.displayName = "Checkbox";
117
117
 
118
+ // src/collapsible/collapsible.tsx
119
+ import { cx } from "class-variance-authority";
120
+ import * as CollapsiblePrimitives from "@radix-ui/react-collapsible";
121
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
122
+ function Content2({ className, ...delegated }) {
123
+ return /* @__PURE__ */ jsx4(CollapsiblePrimitives.Content, {
124
+ ...delegated,
125
+ className: cx("c-collapsible-content", className)
126
+ });
127
+ }
128
+ function CollapsibleTrigger({
129
+ children,
130
+ arrowPosition,
131
+ className,
132
+ ...delegated
133
+ }) {
134
+ return /* @__PURE__ */ jsx4(CollapsiblePrimitives.Trigger, {
135
+ asChild: true,
136
+ ...delegated,
137
+ className: cx("c-collapsible-trigger", arrowPosition === "right" ? "arrow-right" : "", className),
138
+ children: /* @__PURE__ */ jsxs2("div", {
139
+ children: [
140
+ arrowPosition && /* @__PURE__ */ jsx4(Icon.Caret, {
141
+ className: "c-collapsible-arrow",
142
+ fill: "purple-50-900",
143
+ width: 10,
144
+ height: 10
145
+ }),
146
+ children
147
+ ]
148
+ })
149
+ });
150
+ }
151
+ var Collapsible = {
152
+ Root: CollapsiblePrimitives.Root,
153
+ Trigger: CollapsibleTrigger,
154
+ Content: Content2
155
+ };
156
+
118
157
  // src/inline-radio/inline-radio.tsx
119
- import { cx, cva as cva3 } from "class-variance-authority";
158
+ import { cx as cx2, cva as cva3 } from "class-variance-authority";
120
159
  import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
121
- import { jsx as jsx4 } from "react/jsx-runtime";
160
+ import { jsx as jsx5 } from "react/jsx-runtime";
122
161
  var inlineRadioGroupStyles = cva3("c-inline-radio-group", {
123
162
  variants: {
124
163
  size: {
@@ -133,16 +172,16 @@ var inlineRadioGroupStyles = cva3("c-inline-radio-group", {
133
172
  }
134
173
  });
135
174
  function InlineRadioGroup({ size, className, ...delegated }) {
136
- return /* @__PURE__ */ jsx4(RadioGroupPrimitive.Root, {
175
+ return /* @__PURE__ */ jsx5(RadioGroupPrimitive.Root, {
137
176
  ...delegated,
138
177
  className: inlineRadioGroupStyles({ size, className })
139
178
  });
140
179
  }
141
180
  function InlineRadioItem({ children, className, ...delegated }) {
142
- return /* @__PURE__ */ jsx4(RadioGroupPrimitive.Item, {
181
+ return /* @__PURE__ */ jsx5(RadioGroupPrimitive.Item, {
143
182
  ...delegated,
144
- className: cx("c-inline-radio", className),
145
- children: /* @__PURE__ */ jsx4(RadioGroupPrimitive.Indicator, {
183
+ className: cx2("c-inline-radio", className),
184
+ children: /* @__PURE__ */ jsx5(RadioGroupPrimitive.Indicator, {
146
185
  forceMount: true,
147
186
  children
148
187
  })
@@ -154,14 +193,14 @@ var InlineRadio = {
154
193
  };
155
194
 
156
195
  // src/progress/progress.tsx
157
- import { cx as cx2 } from "class-variance-authority";
196
+ import { cx as cx3 } from "class-variance-authority";
158
197
  import * as ProgressPrimitives from "@radix-ui/react-progress";
159
- import { jsx as jsx5 } from "react/jsx-runtime";
198
+ import { jsx as jsx6 } from "react/jsx-runtime";
160
199
  function Progress({ className, value }) {
161
- return /* @__PURE__ */ jsx5(ProgressPrimitives.Root, {
162
- className: cx2(className, "c-progress-root"),
200
+ return /* @__PURE__ */ jsx6(ProgressPrimitives.Root, {
201
+ className: cx3(className, "c-progress-root"),
163
202
  value,
164
- children: /* @__PURE__ */ jsx5(ProgressPrimitives.Indicator, {
203
+ children: /* @__PURE__ */ jsx6(ProgressPrimitives.Indicator, {
165
204
  className: "c-progress-indicator",
166
205
  style: { transform: `translateX(-${100 - (value ?? 0)}%)` }
167
206
  })
@@ -170,12 +209,12 @@ function Progress({ className, value }) {
170
209
 
171
210
  // src/radio/radio.tsx
172
211
  import * as RadioGroupPrimitive2 from "@radix-ui/react-radio-group";
173
- import { jsx as jsx6 } from "react/jsx-runtime";
212
+ import { jsx as jsx7 } from "react/jsx-runtime";
174
213
  function RadioGroupItem(props) {
175
- return /* @__PURE__ */ jsx6(RadioGroupPrimitive2.Item, {
214
+ return /* @__PURE__ */ jsx7(RadioGroupPrimitive2.Item, {
176
215
  ...props,
177
216
  className: "c-radio-item",
178
- children: /* @__PURE__ */ jsx6(RadioGroupPrimitive2.Indicator, {
217
+ children: /* @__PURE__ */ jsx7(RadioGroupPrimitive2.Indicator, {
179
218
  className: "c-radio-indicator"
180
219
  })
181
220
  });
@@ -187,19 +226,20 @@ var Radio = {
187
226
 
188
227
  // src/select/select-item.tsx
189
228
  import { forwardRef as forwardRef3 } from "react";
229
+ import { cx as cx4 } from "class-variance-authority";
190
230
  import * as SelectPrimitives from "@radix-ui/react-select";
191
- import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
231
+ import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
192
232
  var SelectItem = forwardRef3((props, ref) => {
193
- const { children, ...delegated } = props;
194
- return /* @__PURE__ */ jsxs2(SelectPrimitives.Item, {
195
- className: "c-select-item",
233
+ const { children, className, ...delegated } = props;
234
+ return /* @__PURE__ */ jsxs3(SelectPrimitives.Item, {
235
+ className: cx4("c-select-item", className),
196
236
  ref,
197
237
  ...delegated,
198
238
  children: [
199
- /* @__PURE__ */ jsx7(SelectPrimitives.ItemText, {
239
+ /* @__PURE__ */ jsx8(SelectPrimitives.ItemText, {
200
240
  children
201
241
  }),
202
- /* @__PURE__ */ jsx7(SelectPrimitives.ItemIndicator, {})
242
+ /* @__PURE__ */ jsx8(SelectPrimitives.ItemIndicator, {})
203
243
  ]
204
244
  });
205
245
  });
@@ -209,7 +249,7 @@ SelectItem.displayName = "SelectItem";
209
249
  import { forwardRef as forwardRef4 } from "react";
210
250
  import { cva as cva4 } from "class-variance-authority";
211
251
  import * as SelectPrimitives2 from "@radix-ui/react-select";
212
- import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
252
+ import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
213
253
  var selectTriggerStyles = cva4("c-select-trigger", {
214
254
  variants: {
215
255
  size: {
@@ -225,34 +265,34 @@ var selectTriggerStyles = cva4("c-select-trigger", {
225
265
  });
226
266
  var SelectContainer = forwardRef4(
227
267
  ({ children, id, placeholder, disabled, size, triggerClassName, ...delegated }, ref) => {
228
- return /* @__PURE__ */ jsxs3(SelectPrimitives2.Root, {
268
+ return /* @__PURE__ */ jsxs4(SelectPrimitives2.Root, {
229
269
  ...delegated,
230
270
  children: [
231
- /* @__PURE__ */ jsxs3(SelectPrimitives2.Trigger, {
271
+ /* @__PURE__ */ jsxs4(SelectPrimitives2.Trigger, {
232
272
  ref,
233
273
  className: selectTriggerStyles({ size, className: triggerClassName }),
234
274
  disabled,
235
275
  id,
236
276
  children: [
237
- /* @__PURE__ */ jsx8(SelectPrimitives2.Value, {
238
- placeholder: /* @__PURE__ */ jsx8("span", {
277
+ /* @__PURE__ */ jsx9(SelectPrimitives2.Value, {
278
+ placeholder: /* @__PURE__ */ jsx9("span", {
239
279
  className: "c-select-value",
240
280
  children: placeholder ?? "Select..."
241
281
  })
242
282
  }),
243
- /* @__PURE__ */ jsx8(Icon.Arrow, {})
283
+ /* @__PURE__ */ jsx9(Icon.Arrow, {})
244
284
  ]
245
285
  }),
246
- /* @__PURE__ */ jsx8(SelectPrimitives2.Portal, {
247
- children: /* @__PURE__ */ jsxs3(SelectPrimitives2.Content, {
286
+ /* @__PURE__ */ jsx9(SelectPrimitives2.Portal, {
287
+ children: /* @__PURE__ */ jsxs4(SelectPrimitives2.Content, {
248
288
  className: "c-select-content",
249
289
  children: [
250
- /* @__PURE__ */ jsx8(SelectPrimitives2.ScrollUpButton, {}),
251
- /* @__PURE__ */ jsx8(SelectPrimitives2.Viewport, {
290
+ /* @__PURE__ */ jsx9(SelectPrimitives2.ScrollUpButton, {}),
291
+ /* @__PURE__ */ jsx9(SelectPrimitives2.Viewport, {
252
292
  className: "c-select-viewport",
253
293
  children
254
294
  }),
255
- /* @__PURE__ */ jsx8(SelectPrimitives2.ScrollDownButton, {})
295
+ /* @__PURE__ */ jsx9(SelectPrimitives2.ScrollDownButton, {})
256
296
  ]
257
297
  })
258
298
  })
@@ -270,22 +310,22 @@ var Select = {
270
310
 
271
311
  // src/slider/slider.tsx
272
312
  import { forwardRef as forwardRef5 } from "react";
273
- import { cx as cx3 } from "class-variance-authority";
313
+ import { cx as cx5 } from "class-variance-authority";
274
314
  import * as SliderPrimitive from "@radix-ui/react-slider";
275
- import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
315
+ import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
276
316
  var Slider = forwardRef5(({ className, transparentRange, ...delegated }, ref) => {
277
- return /* @__PURE__ */ jsxs4(SliderPrimitive.Root, {
278
- className: cx3("c-slider-root", className),
317
+ return /* @__PURE__ */ jsxs5(SliderPrimitive.Root, {
318
+ className: cx5("c-slider-root", className),
279
319
  ref,
280
320
  ...delegated,
281
321
  children: [
282
- /* @__PURE__ */ jsx9(SliderPrimitive.Track, {
322
+ /* @__PURE__ */ jsx10(SliderPrimitive.Track, {
283
323
  className: "c-slider-track",
284
- children: /* @__PURE__ */ jsx9(SliderPrimitive.Range, {
324
+ children: /* @__PURE__ */ jsx10(SliderPrimitive.Range, {
285
325
  className: `c-slider-range ${transparentRange ? "c-slider-range-transparent" : ""}`
286
326
  })
287
327
  }),
288
- /* @__PURE__ */ jsx9(SliderPrimitive.Thumb, {
328
+ /* @__PURE__ */ jsx10(SliderPrimitive.Thumb, {
289
329
  className: "c-slider-thumb"
290
330
  })
291
331
  ]
@@ -293,15 +333,15 @@ var Slider = forwardRef5(({ className, transparentRange, ...delegated }, ref) =>
293
333
  });
294
334
 
295
335
  // src/stack-icon/stack-icon.tsx
296
- import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
336
+ import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
297
337
  function StackIcon({ type, children, size = 18 }) {
298
- return /* @__PURE__ */ jsxs5("span", {
338
+ return /* @__PURE__ */ jsxs6("span", {
299
339
  className: "c-stack-icon",
300
340
  children: [
301
- type === "create" && /* @__PURE__ */ jsx10("span", {
341
+ type === "create" && /* @__PURE__ */ jsx11("span", {
302
342
  style: { width: size, height: size },
303
343
  className: "c-stack-icon__icon",
304
- children: /* @__PURE__ */ jsx10(Icon.Add, {
344
+ children: /* @__PURE__ */ jsx11(Icon.Add, {
305
345
  width: size - 4,
306
346
  height: size - 4
307
347
  })
@@ -312,8 +352,8 @@ function StackIcon({ type, children, size = 18 }) {
312
352
  }
313
353
 
314
354
  // src/tag/tag.tsx
315
- import { cva as cva5, cx as cx4 } from "class-variance-authority";
316
- import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
355
+ import { cva as cva5, cx as cx6 } from "class-variance-authority";
356
+ import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
317
357
  var tagStyles = cva5("c-tag", {
318
358
  variants: {
319
359
  variant: {
@@ -343,28 +383,28 @@ function Tag({
343
383
  showRemoveOnHover,
344
384
  ...delegated
345
385
  }) {
346
- return /* @__PURE__ */ jsxs6("div", {
386
+ return /* @__PURE__ */ jsxs7("div", {
347
387
  className: tagStyles({ className, variant, size }),
348
388
  ...delegated,
349
389
  children: [
350
- !prepend ? null : /* @__PURE__ */ jsx11("span", {
390
+ !prepend ? null : /* @__PURE__ */ jsx12("span", {
351
391
  className: "c-tag__prepend",
352
392
  children: prepend
353
393
  }),
354
394
  children,
355
- onRemove && /* @__PURE__ */ jsxs6("button", {
395
+ onRemove && /* @__PURE__ */ jsxs7("button", {
356
396
  type: "button",
357
- className: cx4("c-tag__remove-button", showRemoveOnHover ? "c-tag__remove-button--hover" : ""),
397
+ className: cx6("c-tag__remove-button", showRemoveOnHover ? "c-tag__remove-button--hover" : ""),
358
398
  onClick: (e) => {
359
399
  e.stopPropagation();
360
400
  onRemove();
361
401
  },
362
402
  children: [
363
- /* @__PURE__ */ jsx11(Icon.Cancel, {
403
+ /* @__PURE__ */ jsx12(Icon.Cancel, {
364
404
  width: 12,
365
405
  height: 12
366
406
  }),
367
- /* @__PURE__ */ jsx11("span", {
407
+ /* @__PURE__ */ jsx12("span", {
368
408
  className: "c-tag__remove-button-text",
369
409
  children: "Remove"
370
410
  })
@@ -376,12 +416,12 @@ function Tag({
376
416
 
377
417
  // src/rich-text-editor/index.tsx
378
418
  import { lazy, Suspense } from "react";
379
- import { jsx as jsx12 } from "react/jsx-runtime";
419
+ import { jsx as jsx13 } from "react/jsx-runtime";
380
420
  var LazyRichTextEditor = lazy(() => import("./rich-text-editor-6PGBZV6U.mjs"));
381
421
  var RichTextEditor = (props) => {
382
- return /* @__PURE__ */ jsx12(Suspense, {
422
+ return /* @__PURE__ */ jsx13(Suspense, {
383
423
  fallback: null,
384
- children: /* @__PURE__ */ jsx12(LazyRichTextEditor, {
424
+ children: /* @__PURE__ */ jsx13(LazyRichTextEditor, {
385
425
  ...props
386
426
  })
387
427
  });
@@ -391,9 +431,9 @@ var RichTextEditor = (props) => {
391
431
  import { Toaster } from "sonner";
392
432
 
393
433
  // src/toast/toast.tsx
394
- import { cva as cva6, cx as cx5 } from "class-variance-authority";
434
+ import { cva as cva6, cx as cx7 } from "class-variance-authority";
395
435
  import { toast as sonnerToast } from "sonner";
396
- import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
436
+ import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
397
437
  var toastStyles = cva6("c-toast", {
398
438
  variants: {
399
439
  type: {
@@ -418,34 +458,34 @@ var toast = ({ title, message, type = "success", timeout = 6e3 }) => {
418
458
  const withMessage = !!message;
419
459
  const toastId = Date.now().toString();
420
460
  sonnerToast.custom(
421
- (id) => /* @__PURE__ */ jsxs7("div", {
461
+ (id) => /* @__PURE__ */ jsxs8("div", {
422
462
  "data-testid": `toast-${type}`,
423
- className: cx5(toastStyles({ type }), withMessage ? "c-toast-with-message" : "c-toast-title-only"),
463
+ className: cx7(toastStyles({ type }), withMessage ? "c-toast-with-message" : "c-toast-title-only"),
424
464
  children: [
425
- /* @__PURE__ */ jsx13("div", {
426
- children: /* @__PURE__ */ jsx13(ToastIcon, {
465
+ /* @__PURE__ */ jsx14("div", {
466
+ children: /* @__PURE__ */ jsx14(ToastIcon, {
427
467
  width: 26,
428
468
  height: 26
429
469
  })
430
470
  }),
431
- /* @__PURE__ */ jsxs7("div", {
471
+ /* @__PURE__ */ jsxs8("div", {
432
472
  children: [
433
- /* @__PURE__ */ jsx13("div", {
473
+ /* @__PURE__ */ jsx14("div", {
434
474
  className: "c-toast-title",
435
475
  children: title
436
476
  }),
437
- !!message && /* @__PURE__ */ jsx13("div", {
477
+ !!message && /* @__PURE__ */ jsx14("div", {
438
478
  className: "c-toast-message",
439
479
  children: message
440
480
  })
441
481
  ]
442
482
  }),
443
- /* @__PURE__ */ jsx13("div", {
483
+ /* @__PURE__ */ jsx14("div", {
444
484
  className: "c-toast-close",
445
- children: /* @__PURE__ */ jsx13(IconButton, {
485
+ children: /* @__PURE__ */ jsx14(IconButton, {
446
486
  onClick: () => sonnerToast.dismiss(id),
447
487
  size: "xs",
448
- children: /* @__PURE__ */ jsx13(Icon.Cancel, {
488
+ children: /* @__PURE__ */ jsx14(Icon.Cancel, {
449
489
  width: 12,
450
490
  height: 12
451
491
  })
@@ -466,7 +506,7 @@ toast.dismiss = sonnerToast.dismiss;
466
506
  // src/switch/switch.tsx
467
507
  import { cva as cva7 } from "class-variance-authority";
468
508
  import * as RadixSwitch from "@radix-ui/react-switch";
469
- import { jsx as jsx14 } from "react/jsx-runtime";
509
+ import { jsx as jsx15 } from "react/jsx-runtime";
470
510
  var switchStyles = cva7(["c-switch-root"], {
471
511
  variants: {
472
512
  size: {
@@ -479,10 +519,10 @@ var switchStyles = cva7(["c-switch-root"], {
479
519
  }
480
520
  });
481
521
  function Switch({ size, ...props }) {
482
- return /* @__PURE__ */ jsx14(RadixSwitch.Root, {
522
+ return /* @__PURE__ */ jsx15(RadixSwitch.Root, {
483
523
  ...props,
484
524
  className: switchStyles({ size }),
485
- children: /* @__PURE__ */ jsx14(RadixSwitch.Thumb, {
525
+ children: /* @__PURE__ */ jsx15(RadixSwitch.Thumb, {
486
526
  className: "c-switch-thumb"
487
527
  })
488
528
  });
@@ -499,6 +539,8 @@ export {
499
539
  Button,
500
540
  Card,
501
541
  Checkbox,
542
+ Collapsible,
543
+ CollapsibleTrigger,
502
544
  Dialog,
503
545
  DropdownMenu,
504
546
  Icon,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crystallize/design-system",
3
- "version": "1.23.6",
3
+ "version": "1.24.1",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -38,6 +38,7 @@
38
38
  "@lexical/utils": "0.12.4",
39
39
  "@lexical/yjs": "0.12.4",
40
40
  "@radix-ui/react-checkbox": "1.0.1",
41
+ "@radix-ui/react-collapsible": "1.0.0",
41
42
  "@radix-ui/react-dialog": "1.0.2",
42
43
  "@radix-ui/react-dropdown-menu": "2.0.1",
43
44
  "@radix-ui/react-popover": "1.0.0",
@@ -50,6 +51,7 @@
50
51
  "class-variance-authority": "^0.4.0",
51
52
  "lexical": "0.12.4",
52
53
  "sonner": "^0.6.2",
54
+ "tailwindcss-radix": "^2.6.1",
53
55
  "use-debounce": "8.0.4"
54
56
  },
55
57
  "peerDependencies": {
@@ -0,0 +1,19 @@
1
+ .c-collapsible-content {
2
+ @apply overflow-hidden radix-state-closed:animate-collapsible-close radix-state-open:animate-collapsible-open;
3
+ }
4
+
5
+ .c-collapsible-trigger {
6
+ @apply flex gap-2 items-center;
7
+
8
+ &.arrow-right {
9
+ @apply flex-row-reverse justify-end;
10
+ }
11
+ }
12
+
13
+ .c-collapsible-arrow {
14
+ transition: 0.3s;
15
+ }
16
+
17
+ .c-collapsible-trigger[data-state='open'] .c-collapsible-arrow {
18
+ transform: rotate(180deg);
19
+ }
@@ -0,0 +1,61 @@
1
+ import { useState } from 'react';
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+
4
+ import { Card } from '../card';
5
+ import { Collapsible, CollapsibleTrigger } from './collapsible';
6
+
7
+ const meta: Meta<typeof CollapsibleTrigger> = {
8
+ title: 'Components/Collapsible',
9
+ component: CollapsibleTrigger,
10
+ argTypes: {
11
+ arrowPosition: {
12
+ options: ['right', 'left', undefined],
13
+ description: 'Trigger prop to control arrow visibility and position',
14
+ defaultValue: undefined,
15
+ control: {
16
+ type: 'select',
17
+ },
18
+ },
19
+ },
20
+ };
21
+ export default meta;
22
+ type Story = StoryObj<typeof CollapsibleTrigger>;
23
+
24
+ export const Example: Story = {
25
+ args: {
26
+ arrowPosition: 'right',
27
+ },
28
+ render: args => (
29
+ <Card style={{ padding: 0 }}>
30
+ <Collapsible.Root>
31
+ <div style={{ cursor: 'pointer', padding: '32px' }}>
32
+ <Collapsible.Trigger arrowPosition={args.arrowPosition}>
33
+ <div>Expand</div>
34
+ </Collapsible.Trigger>
35
+ </div>
36
+ <Collapsible.Content>
37
+ <p style={{ padding: '0 32px' }}>
38
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam dui sem, fermentum vitae, sagittis id,
39
+ malesuada in, quam. Cras elementum. Curabitur ligula sapien, pulvinar a vestibulum quis, facilisis vel
40
+ sapien. Ut tempus purus at lorem. Pellentesque ipsum. Sed elit dui, pellentesque a, faucibus vel, interdum
41
+ nec, diam. Maecenas sollicitudin. Praesent id justo in neque elementum ultrices. Etiam neque. Integer
42
+ tempor. Fusce nibh.
43
+ </p>
44
+ </Collapsible.Content>
45
+ </Collapsible.Root>
46
+ </Card>
47
+ ),
48
+ };
49
+
50
+ export const Controlled = () => {
51
+ const [isOpen, setIsOpen] = useState(false);
52
+
53
+ return (
54
+ <Collapsible.Root open={isOpen} onOpenChange={o => setIsOpen(o)}>
55
+ <Collapsible.Trigger>Click me</Collapsible.Trigger>
56
+ <Collapsible.Content>
57
+ <div>Content</div>
58
+ </Collapsible.Content>
59
+ </Collapsible.Root>
60
+ );
61
+ };
@@ -0,0 +1,43 @@
1
+ import type { ComponentProps } from 'react';
2
+ import { cx } from 'class-variance-authority';
3
+ import * as CollapsiblePrimitives from '@radix-ui/react-collapsible';
4
+ import type { CollapsibleTriggerProps } from '@radix-ui/react-collapsible';
5
+
6
+ import './collapsible.css';
7
+ import { Icon } from '../iconography';
8
+
9
+ type CollapsibleContentProps = ComponentProps<typeof CollapsiblePrimitives.Content>;
10
+
11
+ function Content({ className, ...delegated }: CollapsibleContentProps) {
12
+ return <CollapsiblePrimitives.Content {...delegated} className={cx('c-collapsible-content', className)} />;
13
+ }
14
+
15
+ type CollapsibleTriggerPropsExtendedProps = CollapsibleTriggerProps & {
16
+ arrowPosition?: 'left' | 'right';
17
+ };
18
+
19
+ export function CollapsibleTrigger({
20
+ children,
21
+ arrowPosition,
22
+ className,
23
+ ...delegated
24
+ }: CollapsibleTriggerPropsExtendedProps) {
25
+ return (
26
+ <CollapsiblePrimitives.Trigger
27
+ asChild
28
+ {...delegated}
29
+ className={cx('c-collapsible-trigger', arrowPosition === 'right' ? 'arrow-right' : '', className)}
30
+ >
31
+ <div>
32
+ {arrowPosition && <Icon.Caret className="c-collapsible-arrow" fill="purple-50-900" width={10} height={10} />}
33
+ {children}
34
+ </div>
35
+ </CollapsiblePrimitives.Trigger>
36
+ );
37
+ }
38
+
39
+ export const Collapsible = {
40
+ Root: CollapsiblePrimitives.Root,
41
+ Trigger: CollapsibleTrigger,
42
+ Content,
43
+ };
@@ -0,0 +1 @@
1
+ export * from './collapsible';
package/src/index.ts CHANGED
@@ -9,6 +9,7 @@ export * from './avatar';
9
9
  export * from './button';
10
10
  export * from './card';
11
11
  export * from './checkbox';
12
+ export * from './collapsible';
12
13
  export * from './dialog';
13
14
  export * from './dropdown-menu';
14
15
  export * from './icon-button';
@@ -1,14 +1,15 @@
1
1
  import { ComponentProps, forwardRef } from 'react';
2
+ import { cx } from 'class-variance-authority';
2
3
  import * as SelectPrimitives from '@radix-ui/react-select';
3
4
 
4
5
  export type SelectItemRef = HTMLDivElement;
5
6
  export type SelectItemProps = ComponentProps<typeof SelectPrimitives.Item>;
6
7
 
7
8
  export const SelectItem = forwardRef<SelectItemRef, SelectItemProps>((props, ref) => {
8
- const { children, ...delegated } = props;
9
+ const { children, className, ...delegated } = props;
9
10
 
10
11
  return (
11
- <SelectPrimitives.Item className="c-select-item" ref={ref} {...delegated}>
12
+ <SelectPrimitives.Item className={cx('c-select-item', className)} ref={ref} {...delegated}>
12
13
  <SelectPrimitives.ItemText>{children}</SelectPrimitives.ItemText>
13
14
  <SelectPrimitives.ItemIndicator />
14
15
  </SelectPrimitives.Item>
@@ -40,6 +40,14 @@ module.exports = {
40
40
  inherit: 'inherit',
41
41
  },
42
42
  keyframes: {
43
+ 'collapsible-open': {
44
+ '0%': { height: '0' },
45
+ '100%': { height: 'var(--radix-collapsible-content-height)' },
46
+ },
47
+ 'collapsible-close': {
48
+ '0%': { height: 'var(--radix-collapsible-content-height)' },
49
+ '100%': { height: '0' },
50
+ },
43
51
  spin: {
44
52
  '0%': {
45
53
  transform: 'rotate(0deg)',
@@ -56,6 +64,8 @@ module.exports = {
56
64
  },
57
65
  },
58
66
  animation: {
67
+ 'collapsible-open': 'collapsible-open 300ms ease-out forwards',
68
+ 'collapsible-close': 'collapsible-close 300ms ease-out forwards',
59
69
  spin: 'spin 2s linear infinite',
60
70
  },
61
71
  boxShadow: {
@@ -64,5 +74,5 @@ module.exports = {
64
74
  },
65
75
  },
66
76
  },
67
- plugins: [colorsPlugin],
77
+ plugins: [colorsPlugin, require('tailwindcss-radix')(), require('@tailwindcss/container-queries')],
68
78
  };