@codapet/design-system 0.7.5 → 0.7.6

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/AGENTS.md CHANGED
@@ -61,6 +61,12 @@ These are the foot-guns. Knowing them prevents most "why does my Button look wro
61
61
 
62
62
  - Standard shadcn pattern: `react-hook-form` + `zod` + `Form / FormField / FormItem / FormLabel / FormControl / FormMessage`. Same API as shadcn — no surprises here.
63
63
 
64
+ ### Accordion
65
+
66
+ - Adds a `variant` prop on `<Accordion>`: `default` (shadcn-equivalent, bottom-stripe items) or `outlined` (each item is its own bordered card with taller trigger and roomier padding). Reach for `variant="outlined"` on FAQ sections, settings panels, or any "stacked cards" pattern.
67
+ - Variant propagates to children via context — set it once on the root, not on every `AccordionItem`/`Trigger`/`Content`.
68
+ - Plus/Minus (or any custom) icons are opt-in via `collapsedIcon`/`expandedIcon` on `AccordionTrigger`. The default remains a rotating `ChevronDown`.
69
+
64
70
  ### Dialog vs SmartDialog
65
71
 
66
72
  - `Dialog`/`Drawer` are the standard Radix/Vaul primitives.
package/dist/index.d.mts CHANGED
@@ -44,7 +44,10 @@ import * as TogglePrimitive from '@radix-ui/react-toggle';
44
44
  import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
45
45
  import { ClassValue } from 'clsx';
46
46
 
47
- declare function Accordion({ ...props }: React$1.ComponentProps<typeof AccordionPrimitive.Root>): react_jsx_runtime.JSX.Element;
47
+ type AccordionVariant = 'default' | 'outlined';
48
+ declare function Accordion({ variant, className, ...props }: React$1.ComponentProps<typeof AccordionPrimitive.Root> & {
49
+ variant?: AccordionVariant;
50
+ }): react_jsx_runtime.JSX.Element;
48
51
  declare function AccordionItem({ className, ...props }: React$1.ComponentProps<typeof AccordionPrimitive.Item>): react_jsx_runtime.JSX.Element;
49
52
  declare function AccordionTrigger({ className, children, expandedIcon, collapsedIcon, ...props }: React$1.ComponentProps<typeof AccordionPrimitive.Trigger> & {
50
53
  expandedIcon?: React$1.ReactNode;
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  // src/components/ui/accordion.tsx
4
- import "react";
4
+ import * as React from "react";
5
5
  import * as AccordionPrimitive from "@radix-ui/react-accordion";
6
6
  import { ChevronDownIcon } from "lucide-react";
7
7
 
@@ -14,20 +14,40 @@ function cn(...inputs) {
14
14
 
15
15
  // src/components/ui/accordion.tsx
16
16
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
17
+ var AccordionContext = React.createContext({
18
+ variant: "default"
19
+ });
17
20
  function Accordion({
21
+ variant = "default",
22
+ className,
18
23
  ...props
19
24
  }) {
20
- return /* @__PURE__ */ jsx(AccordionPrimitive.Root, { "data-slot": "accordion", ...props });
25
+ return /* @__PURE__ */ jsx(AccordionContext.Provider, { value: { variant }, children: /* @__PURE__ */ jsx(
26
+ AccordionPrimitive.Root,
27
+ {
28
+ "data-slot": "accordion",
29
+ "data-variant": variant,
30
+ className: cn(
31
+ variant === "outlined" && "flex flex-col gap-3",
32
+ className
33
+ ),
34
+ ...props
35
+ }
36
+ ) });
21
37
  }
22
38
  function AccordionItem({
23
39
  className,
24
40
  ...props
25
41
  }) {
42
+ const { variant } = React.useContext(AccordionContext);
26
43
  return /* @__PURE__ */ jsx(
27
44
  AccordionPrimitive.Item,
28
45
  {
29
46
  "data-slot": "accordion-item",
30
- className: cn("border-b last:border-b-0", className),
47
+ className: cn(
48
+ variant === "outlined" ? "rounded-lg border" : "border-b last:border-b-0",
49
+ className
50
+ ),
31
51
  ...props
32
52
  }
33
53
  );
@@ -39,20 +59,26 @@ function AccordionTrigger({
39
59
  collapsedIcon,
40
60
  ...props
41
61
  }) {
62
+ const { variant } = React.useContext(AccordionContext);
42
63
  const hasCustomIcon = expandedIcon !== void 0 || collapsedIcon !== void 0;
64
+ const animatedIconSwap = variant === "outlined" && collapsedIcon !== void 0 && expandedIcon !== void 0;
43
65
  return /* @__PURE__ */ jsx(AccordionPrimitive.Header, { className: "flex", children: /* @__PURE__ */ jsxs(
44
66
  AccordionPrimitive.Trigger,
45
67
  {
46
68
  "data-slot": "accordion-trigger",
47
69
  className: cn(
48
70
  "group focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50",
71
+ variant === "outlined" && "min-h-16 items-center gap-8 px-5 py-4 text-base lg:px-6 lg:text-lg lg:leading-7 hover:no-underline",
49
72
  !hasCustomIcon && "[&[data-state=open]>svg]:rotate-180",
50
73
  className
51
74
  ),
52
75
  ...props,
53
76
  children: [
54
77
  children,
55
- hasCustomIcon ? /* @__PURE__ */ jsxs(Fragment, { children: [
78
+ hasCustomIcon ? animatedIconSwap ? /* @__PURE__ */ jsxs("span", { className: "pointer-events-none grid shrink-0 text-muted-foreground *:[grid-area:1/1] *:transition-[rotate,opacity] *:duration-300 *:ease-[cubic-bezier(0.33,1,0.68,1)]", children: [
79
+ /* @__PURE__ */ jsx("span", { className: "group-data-[state=open]:rotate-90 group-data-[state=open]:opacity-0", children: collapsedIcon }),
80
+ /* @__PURE__ */ jsx("span", { className: "-rotate-90 opacity-0 group-data-[state=open]:rotate-0 group-data-[state=open]:opacity-100", children: expandedIcon })
81
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
56
82
  collapsedIcon !== void 0 && /* @__PURE__ */ jsx("span", { className: "group-data-[state=open]:hidden pointer-events-none shrink-0 text-muted-foreground", children: collapsedIcon }),
57
83
  expandedIcon !== void 0 && /* @__PURE__ */ jsx("span", { className: "group-data-[state=closed]:hidden pointer-events-none shrink-0 text-muted-foreground", children: expandedIcon })
58
84
  ] }) : /* @__PURE__ */ jsx(ChevronDownIcon, { className: "text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-400" })
@@ -65,13 +91,23 @@ function AccordionContent({
65
91
  children,
66
92
  ...props
67
93
  }) {
94
+ const { variant } = React.useContext(AccordionContext);
68
95
  return /* @__PURE__ */ jsx(
69
96
  AccordionPrimitive.Content,
70
97
  {
71
98
  "data-slot": "accordion-content",
72
99
  className: "data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",
73
100
  ...props,
74
- children: /* @__PURE__ */ jsx("div", { className: cn("pt-0 pb-4", className), children })
101
+ children: /* @__PURE__ */ jsx(
102
+ "div",
103
+ {
104
+ className: cn(
105
+ variant === "outlined" ? "px-5 pb-5 lg:px-6 lg:pb-6" : "pt-0 pb-4",
106
+ className
107
+ ),
108
+ children
109
+ }
110
+ )
75
111
  }
76
112
  );
77
113
  }