@qdesignsystems/design-system-core 0.1.4 → 0.1.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 ADDED
@@ -0,0 +1,145 @@
1
+ # Q Design System — AI Agent Rules
2
+
3
+ ## CRITICAL: Component Import Rule
4
+
5
+ **NEVER install or use local shadcn/ui components (via `npx shadcn@latest add ...`).**
6
+ **ALWAYS import components from `@qdesignsystems/design-system-core`.**
7
+
8
+ This project uses a pre-built design system package. All components are already available — do not scaffold new ones.
9
+
10
+ ---
11
+
12
+ ## How to Import Components
13
+
14
+ All components come from one package:
15
+
16
+ ```tsx
17
+ import { Button, Card, Input, Badge, ... } from '@qdesignsystems/design-system-core';
18
+ ```
19
+
20
+ ### Base Components
21
+
22
+ ```tsx
23
+ import {
24
+ // Layout
25
+ Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent, CardAction,
26
+
27
+ // Inputs
28
+ Button, Input, Textarea, Checkbox, RadioGroup, RadioGroupItem, Switch, Toggle,
29
+
30
+ // Display
31
+ Badge, Alert, AlertTitle, AlertDescription, Separator, Skeleton, Label,
32
+
33
+ // Navigation
34
+ Pagination, PaginationContent, PaginationLink, PaginationItem,
35
+ PaginationPrevious, PaginationNext, PaginationEllipsis,
36
+
37
+ // Overlay
38
+ Popover, PopoverTrigger, PopoverContent,
39
+ DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem,
40
+ DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuGroup,
41
+
42
+ // Structure
43
+ Accordion, AccordionItem, AccordionTrigger, AccordionContent,
44
+ Collapsible, CollapsibleTrigger, CollapsibleContent,
45
+
46
+ // Form
47
+ Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField,
48
+
49
+ // Sidebar
50
+ Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent,
51
+ SidebarGroupLabel, SidebarHeader, SidebarMenu, SidebarMenuButton,
52
+ SidebarMenuItem, SidebarProvider, SidebarTrigger, SidebarInset,
53
+
54
+ // Utilities
55
+ cn, ThemeProvider,
56
+ } from '@qdesignsystems/design-system-core';
57
+ ```
58
+
59
+ ### Pre-built Composite Components
60
+
61
+ These are ready-to-use demo components. Use them as-is or as a starting point:
62
+
63
+ ```tsx
64
+ // Buttons
65
+ import { Button14, Button16, Button17, Button19, Button20 } from '@qdesignsystems/design-system-core';
66
+
67
+ // Button Groups
68
+ import { ButtonGroup01, ButtonGroup02, ButtonGroup03 } from '@qdesignsystems/design-system-core';
69
+
70
+ // Cards
71
+ import { Card01, Card02, Card03, Card04, Card05, Card06, Card10, Card13, Card14 } from '@qdesignsystems/design-system-core';
72
+
73
+ // Inputs
74
+ import { Input01, Input02, Input03 /* ... up to Input46 */ } from '@qdesignsystems/design-system-core';
75
+
76
+ // Badges
77
+ import { Badge01, Badge02 /* ... up to Badge24 */ } from '@qdesignsystems/design-system-core';
78
+
79
+ // Forms
80
+ import { Form01, Form02, Form03 /* ... up to Form10 */ } from '@qdesignsystems/design-system-core';
81
+
82
+ // Checkboxes
83
+ import { Checkbox01, Checkbox02 /* ... up to Checkbox16 */ } from '@qdesignsystems/design-system-core';
84
+
85
+ // Radio Groups
86
+ import { RadioGroup01, RadioGroup02 /* ... up to RadioGroup13 */ } from '@qdesignsystems/design-system-core';
87
+
88
+ // Dropdowns
89
+ import { DropdownMenu01, DropdownMenu05, DropdownMenu08, DropdownMenu09 } from '@qdesignsystems/design-system-core';
90
+
91
+ // Popovers
92
+ import { Popover01, Popover02 /* ... up to Popover12 */ } from '@qdesignsystems/design-system-core';
93
+
94
+ // Pagination
95
+ import { Pagination01, Pagination02 /* ... up to Pagination15 */ } from '@qdesignsystems/design-system-core';
96
+
97
+ // Calendars
98
+ import { Calendar01, Calendar02 /* ... up to Calendar21 */ } from '@qdesignsystems/design-system-core';
99
+
100
+ // Comboboxes
101
+ import { Combobox01, Combobox02 /* ... up to Combobox12 */ } from '@qdesignsystems/design-system-core';
102
+
103
+ // Data Tables
104
+ import { DataTable01, DataTable02, DataTable03, DataTable05, DataTable07, DataTable08, DataTable09, DataTable13 } from '@qdesignsystems/design-system-core';
105
+
106
+ // Collapsibles
107
+ import { Collapsible01, Collapsible02 /* ... up to Collapsible09 */ } from '@qdesignsystems/design-system-core';
108
+
109
+ // Toasts / Notifications
110
+ import { Sonner01, Sonner02 /* ... up to Sonner20 */ } from '@qdesignsystems/design-system-core';
111
+ ```
112
+
113
+ ---
114
+
115
+ ## Rules
116
+
117
+ 1. **Never run `npx shadcn@latest add <component>`** — components already exist in the package
118
+ 2. **Never create files in `src/components/ui/`** — do not scaffold local shadcn components
119
+ 3. **Always import from `@qdesignsystems/design-system-core`**
120
+ 4. **Use Tailwind utility classes** for layout and spacing — the theme CSS variables are already loaded
121
+ 5. **Do not add a `:root { }` or `.dark { }` block** to any CSS file — this overrides the theme
122
+
123
+ ---
124
+
125
+ ## CSS Setup (must be correct)
126
+
127
+ `src/main.tsx` must have these imports at the very top:
128
+
129
+ ```tsx
130
+ import '@qdesignsystems/design-system-core/styles.css';
131
+ import '@qdesignsystems/theme-myra/styles.css'; // or theme-q
132
+ ```
133
+
134
+ `src/index.css` must NOT contain `:root { }` or `.dark { }` variable blocks. It should only contain:
135
+
136
+ ```css
137
+ @tailwind base;
138
+ @tailwind components;
139
+ @tailwind utilities;
140
+
141
+ @layer base {
142
+ * { @apply border-border; }
143
+ body { @apply bg-background text-foreground; }
144
+ }
145
+ ```
package/README.md CHANGED
@@ -1,45 +1,99 @@
1
- # @q-designsystem/core
1
+ # @qdesignsystems/design-system-core
2
2
 
3
- Core React component library built on shadcn/ui.
3
+ Core component library for the Q Design System, built on shadcn/ui and Radix UI.
4
4
 
5
- ## Installation
5
+ ---
6
+
7
+ ## Quick Setup
8
+
9
+ ### Step 1 — Install
10
+
11
+ ```bash
12
+ # With the MYRA theme
13
+ npm install @qdesignsystems/design-system-core@latest @qdesignsystems/theme-myra@latest
14
+
15
+ # With the Q theme
16
+ npm install @qdesignsystems/design-system-core@latest @qdesignsystems/theme-q@latest
17
+ ```
18
+
19
+ ### Step 2 — Run the init command
20
+
21
+ The init command automatically patches your `index.css` and `main.tsx` for you:
6
22
 
7
23
  ```bash
8
- npm install @q-designsystem/core
24
+ # For the MYRA theme
25
+ npx qds-init --theme=myra
26
+
27
+ # For the Q theme
28
+ npx qds-init --theme=q
9
29
  ```
10
30
 
11
- ## Usage
31
+ This will:
32
+ 1. Remove the default `:root { }` and `.dark { }` CSS variable blocks from `src/index.css` (they override the theme if left in)
33
+ 2. Add the correct CSS imports to `src/main.tsx` in the right order
34
+
35
+ ### Step 3 — Done
36
+
37
+ Your app now uses the Q Design System with the selected theme.
38
+
39
+ ---
40
+
41
+ ## Manual Setup
42
+
43
+ If you prefer to set things up manually:
44
+
45
+ ### 1. Add imports to `src/main.tsx` (at the very top, before all other imports)
12
46
 
13
47
  ```tsx
14
- import { Button, ThemeProvider } from '@q-designsystem/core';
15
- import '@q-designsystem/core/styles';
16
-
17
- function App() {
18
- return (
19
- <ThemeProvider defaultTheme="light">
20
- <Button>Click me</Button>
21
- </ThemeProvider>
22
- );
48
+ import '@qdesignsystems/design-system-core/styles.css';
49
+ import '@qdesignsystems/theme-myra/styles.css'; // or theme-q
50
+ ```
51
+
52
+ ### 2. Clean up `src/index.css`
53
+
54
+ Remove the `:root { }` and `.dark { }` blocks that contain CSS variable declarations (lines like `--primary: ...`, `--background: ...`). These override the theme.
55
+
56
+ Your `index.css` should contain only:
57
+
58
+ ```css
59
+ @tailwind base;
60
+ @tailwind components;
61
+ @tailwind utilities;
62
+
63
+ @layer base {
64
+ * {
65
+ @apply border-border;
66
+ }
67
+ body {
68
+ @apply bg-background text-foreground;
69
+ }
23
70
  }
24
71
  ```
25
72
 
26
- ## Components
73
+ > **Why?** CSS follows "last one wins". The default `index.css` in a Vite/shadcn project contains hardcoded CSS variable values that override the theme package's variables. Removing them lets the theme apply correctly.
27
74
 
28
- All components are built on shadcn/ui and use CSS variables for theming.
75
+ ---
29
76
 
30
- ### Button
77
+ ## Available Themes
78
+
79
+ | Package | Description |
80
+ |---|---|
81
+ | `@qdesignsystems/theme-myra` | MYRA theme — blue primary, warm background |
82
+ | `@qdesignsystems/theme-q` | Q theme — black primary, clean minimal |
83
+
84
+ ---
85
+
86
+ ## Import Order
87
+
88
+ The import order in `main.tsx` matters:
31
89
 
32
90
  ```tsx
33
- import { Button } from '@q-designsystem/core';
34
-
35
- <Button variant="default">Default</Button>
36
- <Button variant="destructive">Destructive</Button>
37
- <Button variant="outline">Outline</Button>
38
- <Button variant="secondary">Secondary</Button>
39
- <Button variant="ghost">Ghost</Button>
40
- <Button variant="link">Link</Button>
41
- ```
91
+ // 1. Core styles (defines base variables)
92
+ import '@qdesignsystems/design-system-core/styles.css';
42
93
 
43
- ## Theming
94
+ // 2. Theme styles (overrides base variables with theme values)
95
+ import '@qdesignsystems/theme-myra/styles.css';
44
96
 
45
- Components use CSS variables that can be customized via themes. See `@q-designsystem/themes` for theme definitions.
97
+ // 3. Your app styles (should NOT contain :root variable blocks)
98
+ import './index.css';
99
+ ```
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@qdesignsystems/design-system-core",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
7
7
  },
8
8
  "description": "Core component library built on shadcn/ui",
9
+ "bin": {
10
+ "qds-init": "./scripts/init.cjs"
11
+ },
9
12
  "main": "./dist/index.js",
10
13
  "module": "./dist/index.mjs",
11
14
  "types": "./dist/index.d.ts",
@@ -24,7 +27,10 @@
24
27
  "**/*.css"
25
28
  ],
26
29
  "files": [
27
- "dist"
30
+ "dist",
31
+ "scripts/init.cjs",
32
+ "README.md",
33
+ "AGENTS.md"
28
34
  ],
29
35
  "scripts": {
30
36
  "build": "tsup && node scripts/strip-css-sourcemap.cjs",
@@ -0,0 +1,172 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+
7
+ const RESET = '\x1b[0m';
8
+ const GREEN = '\x1b[32m';
9
+ const YELLOW = '\x1b[33m';
10
+ const CYAN = '\x1b[36m';
11
+ const RED = '\x1b[31m';
12
+ const BOLD = '\x1b[1m';
13
+
14
+ function log(color, symbol, msg) {
15
+ console.log(`${color}${symbol}${RESET} ${msg}`);
16
+ }
17
+
18
+ // ─── Resolve project root (where package.json lives) ─────────────────────────
19
+ // When run via npx inside a project, cwd is the project root.
20
+ const projectRoot = process.cwd();
21
+
22
+ // ─── Detect theme from argv ───────────────────────────────────────────────────
23
+ const args = process.argv.slice(2);
24
+ const themeArg = args.find(a => a.startsWith('--theme='));
25
+ const theme = themeArg ? themeArg.replace('--theme=', '').toLowerCase() : null;
26
+
27
+ const SUPPORTED_THEMES = ['myra', 'q'];
28
+
29
+ console.log('');
30
+ console.log(`${BOLD}${CYAN}Q Design System — Init${RESET}`);
31
+ console.log('─'.repeat(40));
32
+
33
+ if (theme && !SUPPORTED_THEMES.includes(theme)) {
34
+ log(RED, '✖', `Unknown theme "${theme}". Supported themes: ${SUPPORTED_THEMES.join(', ')}`);
35
+ process.exit(1);
36
+ }
37
+
38
+ // ─── 1. Patch index.css ───────────────────────────────────────────────────────
39
+ const CSS_CANDIDATES = [
40
+ 'src/index.css',
41
+ 'src/App.css',
42
+ 'src/globals.css',
43
+ 'src/global.css',
44
+ 'src/styles/index.css',
45
+ 'src/styles/globals.css',
46
+ ];
47
+
48
+ const CLEAN_CSS = `@tailwind base;
49
+ @tailwind components;
50
+ @tailwind utilities;
51
+
52
+ @layer base {
53
+ * {
54
+ @apply border-border;
55
+ }
56
+ body {
57
+ @apply bg-background text-foreground;
58
+ }
59
+ }
60
+ `;
61
+
62
+ // Regex that matches a :root { ... } or .dark { ... } block containing CSS vars
63
+ const CSS_VAR_BLOCK_RE = /(?::root|\.dark)\s*\{[^}]*--[a-zA-Z][^}]*\}/gs;
64
+
65
+ let cssPatched = false;
66
+ for (const candidate of CSS_CANDIDATES) {
67
+ const cssPath = path.join(projectRoot, candidate);
68
+ if (fs.existsSync(cssPath)) {
69
+ const original = fs.readFileSync(cssPath, 'utf8');
70
+ if (CSS_VAR_BLOCK_RE.test(original)) {
71
+ // Remove :root and .dark CSS variable blocks, keep the rest
72
+ const patched = original.replace(CSS_VAR_BLOCK_RE, '').replace(/\n{3,}/g, '\n\n').trim();
73
+ // Ensure Tailwind directives are present
74
+ const hasTailwind = patched.includes('@tailwind base');
75
+ const final = hasTailwind ? patched + '\n' : CLEAN_CSS;
76
+ fs.writeFileSync(cssPath, final, 'utf8');
77
+ log(GREEN, '✔', `Removed CSS variable overrides from ${candidate}`);
78
+ cssPatched = true;
79
+ } else {
80
+ log(GREEN, '✔', `${candidate} looks clean — no CSS variable overrides found`);
81
+ cssPatched = true;
82
+ }
83
+ break;
84
+ }
85
+ }
86
+
87
+ if (!cssPatched) {
88
+ log(YELLOW, '⚠', 'Could not find index.css — please manually remove :root { } and .dark { } variable blocks');
89
+ }
90
+
91
+ // ─── 2. Patch main entry file ─────────────────────────────────────────────────
92
+ const ENTRY_CANDIDATES = [
93
+ 'src/main.tsx',
94
+ 'src/main.ts',
95
+ 'src/index.tsx',
96
+ 'src/index.ts',
97
+ 'src/main.jsx',
98
+ 'src/index.jsx',
99
+ ];
100
+
101
+ const CORE_IMPORT = `import '@qdesignsystems/design-system-core/styles.css';`;
102
+ const THEME_IMPORT = theme ? `import '@qdesignsystems/theme-${theme}/styles.css';` : null;
103
+
104
+ let entryPatched = false;
105
+ for (const candidate of ENTRY_CANDIDATES) {
106
+ const entryPath = path.join(projectRoot, candidate);
107
+ if (fs.existsSync(entryPath)) {
108
+ let content = fs.readFileSync(entryPath, 'utf8');
109
+ let changed = false;
110
+
111
+ if (!content.includes(CORE_IMPORT)) {
112
+ content = CORE_IMPORT + '\n' + content;
113
+ changed = true;
114
+ }
115
+
116
+ if (THEME_IMPORT && !content.includes(THEME_IMPORT)) {
117
+ // Insert theme import right after core import
118
+ content = content.replace(CORE_IMPORT, CORE_IMPORT + '\n' + THEME_IMPORT);
119
+ changed = true;
120
+ }
121
+
122
+ if (changed) {
123
+ fs.writeFileSync(entryPath, content, 'utf8');
124
+ log(GREEN, '✔', `Added theme imports to ${candidate}`);
125
+ } else {
126
+ log(GREEN, '✔', `${candidate} already has the correct imports`);
127
+ }
128
+ entryPatched = true;
129
+ break;
130
+ }
131
+ }
132
+
133
+ if (!entryPatched) {
134
+ log(YELLOW, '⚠', 'Could not find main entry file — please add imports manually (see below)');
135
+ }
136
+
137
+ // ─── 3. Copy AGENTS.md to project root ───────────────────────────────────────
138
+ // AGENTS.md tells AI assistants (Lovable, Cursor, etc.) to use our components
139
+ const agentsSrc = path.join(__dirname, '..', 'AGENTS.md');
140
+ const agentsDest = path.join(projectRoot, 'AGENTS.md');
141
+
142
+ if (fs.existsSync(agentsSrc)) {
143
+ if (fs.existsSync(agentsDest)) {
144
+ log(GREEN, '✔', 'AGENTS.md already exists at project root');
145
+ } else {
146
+ fs.copyFileSync(agentsSrc, agentsDest);
147
+ log(GREEN, '✔', 'Copied AGENTS.md to project root (tells AI to use design system components)');
148
+ }
149
+ } else {
150
+ log(YELLOW, '⚠', 'Could not find AGENTS.md in package — skipping');
151
+ }
152
+
153
+ // ─── 4. Summary ───────────────────────────────────────────────────────────────
154
+ console.log('');
155
+ console.log(`${BOLD}Setup complete!${RESET}`);
156
+ console.log('');
157
+
158
+ if (!theme) {
159
+ console.log(`${YELLOW}No theme specified. To apply a theme, run:${RESET}`);
160
+ console.log(` npx @qdesignsystems/design-system-core init --theme=myra`);
161
+ console.log(` npx @qdesignsystems/design-system-core init --theme=q`);
162
+ console.log('');
163
+ console.log('Then install the theme package:');
164
+ console.log(' npm install @qdesignsystems/theme-myra@latest');
165
+ console.log(' npm install @qdesignsystems/theme-q@latest');
166
+ } else {
167
+ console.log(`${GREEN}Theme applied: ${theme.toUpperCase()}${RESET}`);
168
+ console.log('');
169
+ console.log('Make sure the theme package is installed:');
170
+ console.log(` npm install @qdesignsystems/theme-${theme}@latest`);
171
+ }
172
+ console.log('');