@trycompai/design-system 1.0.3 → 1.0.4

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/README.md CHANGED
@@ -82,6 +82,7 @@ export function MyComponent() {
82
82
  | Export | Description |
83
83
  | ------------------------------------------ | ---------------------------------- |
84
84
  | `@trycompai/design-system` | All components |
85
+ | `@trycompai/design-system/icons` | Carbon icons re-exported |
85
86
  | `@trycompai/design-system/cn` | `cn()` utility for merging classes |
86
87
  | `@trycompai/design-system/globals.css` | Global CSS with theme variables |
87
88
  | `@trycompai/design-system/tailwind.config` | Tailwind configuration |
@@ -98,12 +99,110 @@ The design system includes:
98
99
  - **Navigation**: `Tabs`, `Breadcrumb`, `Pagination`, `NavigationMenu`, `DropdownMenu`
99
100
  - **Utility**: `Separator`, `Skeleton`, `Spinner`, `ScrollArea`, `Collapsible`
100
101
 
102
+ ## Theme Switching
103
+
104
+ The design system uses CSS class-based theming. Dark mode is enabled by adding the `.dark` class to the `<html>` element.
105
+
106
+ ### Theme Components
107
+
108
+ Two components are available for theme switching:
109
+
110
+ ```tsx
111
+ import { ThemeSwitcher, ThemeToggle } from '@trycompai/design-system';
112
+
113
+ // 3-option switcher: light, dark, system
114
+ <ThemeSwitcher
115
+ value={theme}
116
+ onChange={(theme) => handleThemeChange(theme)}
117
+ showSystem={true} // optional, defaults to true
118
+ size="default" // 'sm' | 'default'
119
+ />
120
+
121
+ // Simple light/dark toggle
122
+ <ThemeToggle
123
+ isDark={isDark}
124
+ onChange={(isDark) => handleToggle(isDark)}
125
+ size="default" // 'sm' | 'default'
126
+ />
127
+ ```
128
+
129
+ ### Manual Implementation
130
+
131
+ To switch themes, toggle the `.dark` class on the document:
132
+
133
+ ```tsx
134
+ 'use client';
135
+
136
+ import { useState, useEffect } from 'react';
137
+ import { ThemeToggle } from '@trycompai/design-system';
138
+
139
+ function MyThemeToggle() {
140
+ const [isDark, setIsDark] = useState(false);
141
+
142
+ // Sync with current theme on mount
143
+ useEffect(() => {
144
+ setIsDark(document.documentElement.classList.contains('dark'));
145
+ }, []);
146
+
147
+ const handleThemeChange = (dark: boolean) => {
148
+ setIsDark(dark);
149
+ if (dark) {
150
+ document.documentElement.classList.add('dark');
151
+ } else {
152
+ document.documentElement.classList.remove('dark');
153
+ }
154
+ // Optional: persist to localStorage
155
+ localStorage.setItem('theme', dark ? 'dark' : 'light');
156
+ };
157
+
158
+ return <ThemeToggle isDark={isDark} onChange={handleThemeChange} />;
159
+ }
160
+ ```
161
+
162
+ ### With next-themes (Optional)
163
+
164
+ For more features like system preference detection and SSR support, you can use `next-themes`:
165
+
166
+ ```bash
167
+ npm install next-themes
168
+ ```
169
+
170
+ ```tsx
171
+ // app/layout.tsx
172
+ import { ThemeProvider } from 'next-themes';
173
+
174
+ export default function RootLayout({ children }) {
175
+ return (
176
+ <html lang="en" suppressHydrationWarning>
177
+ <body>
178
+ <ThemeProvider attribute="class" defaultTheme="system" enableSystem>
179
+ {children}
180
+ </ThemeProvider>
181
+ </body>
182
+ </html>
183
+ );
184
+ }
185
+ ```
186
+
187
+ ```tsx
188
+ // components/theme-toggle.tsx
189
+ 'use client';
190
+
191
+ import { useTheme } from 'next-themes';
192
+ import { ThemeSwitcher } from '@trycompai/design-system';
193
+
194
+ export function MyThemeSwitcher() {
195
+ const { theme, setTheme } = useTheme();
196
+ return <ThemeSwitcher value={theme} onChange={setTheme} />;
197
+ }
198
+ ```
199
+
101
200
  ## Design Principles
102
201
 
103
202
  - **No className prop**: Components use variants and props, not className overrides
104
203
  - **Semantic tokens**: Uses CSS variables for consistent theming
105
- - **Dark mode**: Full dark mode support via `next-themes`
106
- - **Accessible**: Built on Radix UI primitives
204
+ - **Dark mode**: Full dark mode support via `.dark` class
205
+ - **Accessible**: Built on Base UI primitives
107
206
 
108
207
  ## License
109
208
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trycompai/design-system",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Design system for Comp AI - shadcn-style components with Tailwind CSS",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -3,7 +3,7 @@ import { useRender } from '@base-ui/react/use-render';
3
3
  import { cva, type VariantProps } from 'class-variance-authority';
4
4
 
5
5
  const badgeVariants = cva(
6
- 'gap-1 rounded-sm px-1.5 py-1 text-[10px] font-semibold uppercase tracking-wider leading-none transition-colors has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 [&>svg]:size-2.5! inline-flex items-center justify-center w-fit whitespace-nowrap shrink-0 [&>svg]:pointer-events-none focus-visible:ring-ring/50 focus-visible:ring-[3px] overflow-hidden antialiased select-none',
6
+ 'gap-1 rounded-sm px-1.5 py-1 text-[10px] font-semibold uppercase tracking-wider leading-none [text-box-trim:both] [text-box-edge:cap_alphabetic] transition-colors has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 [&>svg]:size-2.5! inline-flex items-center justify-center w-fit whitespace-nowrap shrink-0 [&>svg]:pointer-events-none focus-visible:ring-ring/50 focus-visible:ring-[3px] overflow-hidden antialiased select-none',
7
7
  {
8
8
  variants: {
9
9
  variant: {
@@ -5,19 +5,20 @@ import * as React from 'react';
5
5
  import { Spinner } from './spinner';
6
6
 
7
7
  const buttonVariants = cva(
8
- "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:aria-invalid:border-destructive/50 rounded-lg border border-transparent bg-clip-padding text-sm font-medium focus-visible:ring-[3px] aria-invalid:ring-[3px] [&_svg:not([class*='size-'])]:size-4 inline-flex items-center justify-center whitespace-nowrap transition-all duration-150 ease-out active:scale-[0.98] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none shrink-0 [&_svg]:shrink-0 outline-none group/button select-none cursor-pointer",
8
+ "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:aria-invalid:border-destructive/50 rounded-md border border-transparent text-sm font-medium leading-none [text-box-trim:both] [text-box-edge:cap_alphabetic] focus-visible:ring-[3px] aria-invalid:ring-[3px] [&_svg:not([class*='size-'])]:size-4 inline-flex items-center justify-center whitespace-nowrap transition-all duration-200 ease-out active:scale-[0.97] active:duration-75 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none shrink-0 [&_svg]:shrink-0 outline-none group/button select-none cursor-pointer",
9
9
  {
10
10
  variants: {
11
11
  variant: {
12
- default: 'bg-primary text-primary-foreground hover:bg-primary/80',
12
+ default:
13
+ 'bg-primary text-primary-foreground hover:bg-primary/90',
13
14
  outline:
14
- 'border-border bg-background hover:bg-muted hover:text-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 aria-expanded:bg-muted aria-expanded:text-foreground shadow-xs',
15
+ 'border-border! bg-background hover:bg-muted hover:text-foreground dark:bg-input/30 dark:hover:bg-input/50 aria-expanded:bg-muted aria-expanded:text-foreground',
15
16
  secondary:
16
17
  'bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground',
17
18
  ghost:
18
19
  'hover:bg-muted hover:text-foreground dark:hover:bg-muted/50 aria-expanded:bg-muted aria-expanded:text-foreground',
19
20
  destructive:
20
- 'bg-destructive/10 hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/20 text-destructive focus-visible:border-destructive/40 dark:hover:bg-destructive/30',
21
+ 'bg-destructive/10 text-destructive hover:bg-destructive/15 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 focus-visible:border-destructive/40 dark:bg-destructive/20 dark:hover:bg-destructive/30',
21
22
  link: 'text-primary underline-offset-4 hover:underline',
22
23
  },
23
24
  width: {
@@ -26,15 +27,15 @@ const buttonVariants = cva(
26
27
  },
27
28
  size: {
28
29
  default:
29
- 'h-8 gap-1.5 px-2.5 in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2',
30
- xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
31
- sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
30
+ 'h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2',
31
+ xs: "h-6 gap-1 px-2 text-xs has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
32
+ sm: "h-7 gap-1 px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
32
33
  lg: 'h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3',
33
34
  icon: 'size-8',
34
35
  'icon-xs':
35
- "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
36
+ "size-6 [&_svg:not([class*='size-'])]:size-3",
36
37
  'icon-sm':
37
- 'size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg',
38
+ 'size-7',
38
39
  'icon-lg': 'size-9',
39
40
  // Round icon buttons - for avatar triggers and circular icons
40
41
  'icon-round': 'size-8 rounded-full',
@@ -2,7 +2,7 @@ import { cva, type VariantProps } from 'class-variance-authority';
2
2
  import * as React from 'react';
3
3
 
4
4
  const cardVariants = cva(
5
- 'bg-card text-card-foreground border border-border/40 shadow-[0_1px_3px_0_rgb(0_0_0/0.06)] overflow-hidden rounded-xl py-4 text-sm has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl group/card flex flex-col',
5
+ 'bg-card text-card-foreground border border-border/40 shadow-[0_1px_3px_0_rgb(0_0_0/0.06)] overflow-hidden rounded-md py-4 text-sm has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-md *:[img:last-child]:rounded-b-md group/card flex flex-col',
6
6
  {
7
7
  variants: {
8
8
  width: {
@@ -116,7 +116,7 @@ function CardHeader({ ...props }: Omit<React.ComponentProps<'div'>, 'className'>
116
116
  return (
117
117
  <div
118
118
  data-slot="card-header"
119
- className="gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]"
119
+ className="gap-1 rounded-t-md px-4 group-data-[size=sm]/card:px-3 [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]"
120
120
  {...props}
121
121
  />
122
122
  );
@@ -156,7 +156,7 @@ function CardFooter({ ...props }: Omit<React.ComponentProps<'div'>, 'className'>
156
156
  return (
157
157
  <div
158
158
  data-slot="card-footer"
159
- className="bg-muted/50 rounded-b-xl border-t p-4 group-data-[size=sm]/card:p-3 flex items-center"
159
+ className="bg-muted/50 rounded-b-md border-t p-4 group-data-[size=sm]/card:p-3 flex items-center"
160
160
  {...props}
161
161
  />
162
162
  );
@@ -89,7 +89,7 @@
89
89
  --card-foreground: oklch(0.145 0 0);
90
90
  --popover: oklch(1 0 0);
91
91
  --popover-foreground: oklch(0.145 0 0);
92
- --primary: oklch(0.596 0.145 163.225);
92
+ --primary: oklch(0.3797 0.077172 167.6784);
93
93
  --primary-foreground: oklch(0.979 0.021 166.113);
94
94
  --secondary: oklch(0.92 0.001 286.375);
95
95
  --secondary-foreground: oklch(0.21 0.006 285.885);
@@ -101,7 +101,7 @@
101
101
  --success: oklch(0.6 0.16 145);
102
102
  --warning: oklch(0.75 0.15 85);
103
103
  --info: oklch(0.6 0.15 250);
104
- --border: oklch(0.922 0 0);
104
+ --border: oklch(0.85 0 0);
105
105
  --input: oklch(0.922 0 0);
106
106
  --ring: oklch(0.708 0 0);
107
107
  --chart-1: oklch(0.845 0.143 164.978);
@@ -186,10 +186,10 @@
186
186
  --color-chart-3: var(--chart-3);
187
187
  --color-chart-4: var(--chart-4);
188
188
  --color-chart-5: var(--chart-5);
189
- --radius-sm: calc(var(--radius) - 4px);
190
- --radius-md: calc(var(--radius) - 2px);
189
+ --radius-sm: calc(var(--radius) - 2px);
190
+ --radius-md: calc(var(--radius) - 1px);
191
191
  --radius-lg: var(--radius);
192
- --radius-xl: calc(var(--radius) + 4px);
192
+ --radius-xl: calc(var(--radius) + 2px);
193
193
  --color-sidebar: var(--sidebar);
194
194
  --color-sidebar-foreground: var(--sidebar-foreground);
195
195
  --color-sidebar-primary: var(--sidebar-primary);