@gilav21/shadcn-angular 0.0.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.
@@ -0,0 +1,322 @@
1
+ type BaseColor = 'neutral' | 'slate' | 'stone' | 'gray' | 'zinc';
2
+
3
+ const baseColors: Record<BaseColor, { light: Record<string, string>; dark: Record<string, string> }> = {
4
+ neutral: {
5
+ light: {
6
+ '--background': 'oklch(1 0 0)',
7
+ '--foreground': 'oklch(0.145 0 0)',
8
+ '--card': 'oklch(1 0 0)',
9
+ '--card-foreground': 'oklch(0.145 0 0)',
10
+ '--popover': 'oklch(1 0 0)',
11
+ '--popover-foreground': 'oklch(0.145 0 0)',
12
+ '--primary': 'oklch(0.205 0 0)',
13
+ '--primary-foreground': 'oklch(0.985 0 0)',
14
+ '--secondary': 'oklch(0.97 0 0)',
15
+ '--secondary-foreground': 'oklch(0.205 0 0)',
16
+ '--muted': 'oklch(0.97 0 0)',
17
+ '--muted-foreground': 'oklch(0.556 0 0)',
18
+ '--accent': 'oklch(0.97 0 0)',
19
+ '--accent-foreground': 'oklch(0.205 0 0)',
20
+ '--destructive': 'oklch(0.577 0.245 27.325)',
21
+ '--border': 'oklch(0.922 0 0)',
22
+ '--input': 'oklch(0.922 0 0)',
23
+ '--ring': 'oklch(0.708 0 0)',
24
+ },
25
+ dark: {
26
+ '--background': 'oklch(0.145 0 0)',
27
+ '--foreground': 'oklch(0.985 0 0)',
28
+ '--card': 'oklch(0.205 0 0)',
29
+ '--card-foreground': 'oklch(0.985 0 0)',
30
+ '--popover': 'oklch(0.269 0 0)',
31
+ '--popover-foreground': 'oklch(0.985 0 0)',
32
+ '--primary': 'oklch(0.922 0 0)',
33
+ '--primary-foreground': 'oklch(0.205 0 0)',
34
+ '--secondary': 'oklch(0.269 0 0)',
35
+ '--secondary-foreground': 'oklch(0.985 0 0)',
36
+ '--muted': 'oklch(0.269 0 0)',
37
+ '--muted-foreground': 'oklch(0.708 0 0)',
38
+ '--accent': 'oklch(0.371 0 0)',
39
+ '--accent-foreground': 'oklch(0.985 0 0)',
40
+ '--destructive': 'oklch(0.704 0.191 22.216)',
41
+ '--border': 'oklch(1 0 0 / 10%)',
42
+ '--input': 'oklch(1 0 0 / 15%)',
43
+ '--ring': 'oklch(0.556 0 0)',
44
+ },
45
+ },
46
+ slate: {
47
+ light: {
48
+ '--background': 'oklch(1 0 0)',
49
+ '--foreground': 'oklch(0.129 0.042 264.695)',
50
+ '--card': 'oklch(1 0 0)',
51
+ '--card-foreground': 'oklch(0.129 0.042 264.695)',
52
+ '--popover': 'oklch(1 0 0)',
53
+ '--popover-foreground': 'oklch(0.129 0.042 264.695)',
54
+ '--primary': 'oklch(0.208 0.042 265.755)',
55
+ '--primary-foreground': 'oklch(0.984 0.003 247.858)',
56
+ '--secondary': 'oklch(0.968 0.007 247.896)',
57
+ '--secondary-foreground': 'oklch(0.208 0.042 265.755)',
58
+ '--muted': 'oklch(0.968 0.007 247.896)',
59
+ '--muted-foreground': 'oklch(0.554 0.046 257.417)',
60
+ '--accent': 'oklch(0.968 0.007 247.896)',
61
+ '--accent-foreground': 'oklch(0.208 0.042 265.755)',
62
+ '--destructive': 'oklch(0.577 0.245 27.325)',
63
+ '--border': 'oklch(0.929 0.013 255.508)',
64
+ '--input': 'oklch(0.929 0.013 255.508)',
65
+ '--ring': 'oklch(0.704 0.04 256.788)',
66
+ },
67
+ dark: {
68
+ '--background': 'oklch(0.129 0.042 264.695)',
69
+ '--foreground': 'oklch(0.984 0.003 247.858)',
70
+ '--card': 'oklch(0.208 0.042 265.755)',
71
+ '--card-foreground': 'oklch(0.984 0.003 247.858)',
72
+ '--popover': 'oklch(0.269 0.04 260.031)',
73
+ '--popover-foreground': 'oklch(0.984 0.003 247.858)',
74
+ '--primary': 'oklch(0.929 0.013 255.508)',
75
+ '--primary-foreground': 'oklch(0.208 0.042 265.755)',
76
+ '--secondary': 'oklch(0.269 0.04 260.031)',
77
+ '--secondary-foreground': 'oklch(0.984 0.003 247.858)',
78
+ '--muted': 'oklch(0.269 0.04 260.031)',
79
+ '--muted-foreground': 'oklch(0.704 0.04 256.788)',
80
+ '--accent': 'oklch(0.372 0.044 257.287)',
81
+ '--accent-foreground': 'oklch(0.984 0.003 247.858)',
82
+ '--destructive': 'oklch(0.704 0.191 22.216)',
83
+ '--border': 'oklch(1 0 0 / 10%)',
84
+ '--input': 'oklch(1 0 0 / 15%)',
85
+ '--ring': 'oklch(0.554 0.046 257.417)',
86
+ },
87
+ },
88
+ stone: {
89
+ light: {
90
+ '--background': 'oklch(1 0 0)',
91
+ '--foreground': 'oklch(0.147 0.004 49.25)',
92
+ '--card': 'oklch(1 0 0)',
93
+ '--card-foreground': 'oklch(0.147 0.004 49.25)',
94
+ '--popover': 'oklch(1 0 0)',
95
+ '--popover-foreground': 'oklch(0.147 0.004 49.25)',
96
+ '--primary': 'oklch(0.216 0.006 56.043)',
97
+ '--primary-foreground': 'oklch(0.985 0.001 106.423)',
98
+ '--secondary': 'oklch(0.97 0.001 106.424)',
99
+ '--secondary-foreground': 'oklch(0.216 0.006 56.043)',
100
+ '--muted': 'oklch(0.97 0.001 106.424)',
101
+ '--muted-foreground': 'oklch(0.553 0.013 58.071)',
102
+ '--accent': 'oklch(0.97 0.001 106.424)',
103
+ '--accent-foreground': 'oklch(0.216 0.006 56.043)',
104
+ '--destructive': 'oklch(0.577 0.245 27.325)',
105
+ '--border': 'oklch(0.923 0.003 48.717)',
106
+ '--input': 'oklch(0.923 0.003 48.717)',
107
+ '--ring': 'oklch(0.709 0.01 56.259)',
108
+ },
109
+ dark: {
110
+ '--background': 'oklch(0.147 0.004 49.25)',
111
+ '--foreground': 'oklch(0.985 0.001 106.423)',
112
+ '--card': 'oklch(0.216 0.006 56.043)',
113
+ '--card-foreground': 'oklch(0.985 0.001 106.423)',
114
+ '--popover': 'oklch(0.268 0.007 34.298)',
115
+ '--popover-foreground': 'oklch(0.985 0.001 106.423)',
116
+ '--primary': 'oklch(0.923 0.003 48.717)',
117
+ '--primary-foreground': 'oklch(0.216 0.006 56.043)',
118
+ '--secondary': 'oklch(0.268 0.007 34.298)',
119
+ '--secondary-foreground': 'oklch(0.985 0.001 106.423)',
120
+ '--muted': 'oklch(0.268 0.007 34.298)',
121
+ '--muted-foreground': 'oklch(0.709 0.01 56.259)',
122
+ '--accent': 'oklch(0.374 0.01 67.558)',
123
+ '--accent-foreground': 'oklch(0.985 0.001 106.423)',
124
+ '--destructive': 'oklch(0.704 0.191 22.216)',
125
+ '--border': 'oklch(1 0 0 / 10%)',
126
+ '--input': 'oklch(1 0 0 / 15%)',
127
+ '--ring': 'oklch(0.553 0.013 58.071)',
128
+ },
129
+ },
130
+ gray: {
131
+ light: {
132
+ '--background': 'oklch(1 0 0)',
133
+ '--foreground': 'oklch(0.13 0.028 261.692)',
134
+ '--card': 'oklch(1 0 0)',
135
+ '--card-foreground': 'oklch(0.13 0.028 261.692)',
136
+ '--popover': 'oklch(1 0 0)',
137
+ '--popover-foreground': 'oklch(0.13 0.028 261.692)',
138
+ '--primary': 'oklch(0.21 0.028 264.532)',
139
+ '--primary-foreground': 'oklch(0.985 0.002 247.839)',
140
+ '--secondary': 'oklch(0.967 0.003 264.542)',
141
+ '--secondary-foreground': 'oklch(0.21 0.028 264.532)',
142
+ '--muted': 'oklch(0.967 0.003 264.542)',
143
+ '--muted-foreground': 'oklch(0.551 0.027 264.364)',
144
+ '--accent': 'oklch(0.967 0.003 264.542)',
145
+ '--accent-foreground': 'oklch(0.21 0.028 264.532)',
146
+ '--destructive': 'oklch(0.577 0.245 27.325)',
147
+ '--border': 'oklch(0.928 0.006 264.531)',
148
+ '--input': 'oklch(0.928 0.006 264.531)',
149
+ '--ring': 'oklch(0.707 0.022 264.436)',
150
+ },
151
+ dark: {
152
+ '--background': 'oklch(0.13 0.028 261.692)',
153
+ '--foreground': 'oklch(0.985 0.002 247.839)',
154
+ '--card': 'oklch(0.21 0.028 264.532)',
155
+ '--card-foreground': 'oklch(0.985 0.002 247.839)',
156
+ '--popover': 'oklch(0.274 0.029 256.848)',
157
+ '--popover-foreground': 'oklch(0.985 0.002 247.839)',
158
+ '--primary': 'oklch(0.928 0.006 264.531)',
159
+ '--primary-foreground': 'oklch(0.21 0.028 264.532)',
160
+ '--secondary': 'oklch(0.274 0.029 256.848)',
161
+ '--secondary-foreground': 'oklch(0.985 0.002 247.839)',
162
+ '--muted': 'oklch(0.274 0.029 256.848)',
163
+ '--muted-foreground': 'oklch(0.707 0.022 264.436)',
164
+ '--accent': 'oklch(0.37 0.029 259.733)',
165
+ '--accent-foreground': 'oklch(0.985 0.002 247.839)',
166
+ '--destructive': 'oklch(0.704 0.191 22.216)',
167
+ '--border': 'oklch(1 0 0 / 10%)',
168
+ '--input': 'oklch(1 0 0 / 15%)',
169
+ '--ring': 'oklch(0.551 0.027 264.364)',
170
+ },
171
+ },
172
+ zinc: {
173
+ light: {
174
+ '--background': 'oklch(1 0 0)',
175
+ '--foreground': 'oklch(0.141 0.005 285.823)',
176
+ '--card': 'oklch(1 0 0)',
177
+ '--card-foreground': 'oklch(0.141 0.005 285.823)',
178
+ '--popover': 'oklch(1 0 0)',
179
+ '--popover-foreground': 'oklch(0.141 0.005 285.823)',
180
+ '--primary': 'oklch(0.21 0.006 285.885)',
181
+ '--primary-foreground': 'oklch(0.985 0 0)',
182
+ '--secondary': 'oklch(0.967 0.001 286.375)',
183
+ '--secondary-foreground': 'oklch(0.21 0.006 285.885)',
184
+ '--muted': 'oklch(0.967 0.001 286.375)',
185
+ '--muted-foreground': 'oklch(0.552 0.016 285.938)',
186
+ '--accent': 'oklch(0.967 0.001 286.375)',
187
+ '--accent-foreground': 'oklch(0.21 0.006 285.885)',
188
+ '--destructive': 'oklch(0.577 0.245 27.325)',
189
+ '--border': 'oklch(0.92 0.004 286.32)',
190
+ '--input': 'oklch(0.92 0.004 286.32)',
191
+ '--ring': 'oklch(0.705 0.015 286.067)',
192
+ },
193
+ dark: {
194
+ '--background': 'oklch(0.141 0.005 285.823)',
195
+ '--foreground': 'oklch(0.985 0 0)',
196
+ '--card': 'oklch(0.21 0.006 285.885)',
197
+ '--card-foreground': 'oklch(0.985 0 0)',
198
+ '--popover': 'oklch(0.274 0.006 286.033)',
199
+ '--popover-foreground': 'oklch(0.985 0 0)',
200
+ '--primary': 'oklch(0.92 0.004 286.32)',
201
+ '--primary-foreground': 'oklch(0.21 0.006 285.885)',
202
+ '--secondary': 'oklch(0.274 0.006 286.033)',
203
+ '--secondary-foreground': 'oklch(0.985 0 0)',
204
+ '--muted': 'oklch(0.274 0.006 286.033)',
205
+ '--muted-foreground': 'oklch(0.705 0.015 286.067)',
206
+ '--accent': 'oklch(0.37 0.013 285.805)',
207
+ '--accent-foreground': 'oklch(0.985 0 0)',
208
+ '--destructive': 'oklch(0.704 0.191 22.216)',
209
+ '--border': 'oklch(1 0 0 / 10%)',
210
+ '--input': 'oklch(1 0 0 / 15%)',
211
+ '--ring': 'oklch(0.552 0.016 285.938)',
212
+ },
213
+ },
214
+ };
215
+
216
+ function generateCssVars(vars: Record<string, string>, indent: string = ' '): string {
217
+ return Object.entries(vars)
218
+ .map(([key, value]) => `${indent}${key}: ${value};`)
219
+ .join('\n');
220
+ }
221
+
222
+ export function getStylesTemplate(baseColor: BaseColor = 'neutral'): string {
223
+ const colors = baseColors[baseColor];
224
+
225
+ return `@import "tailwindcss";
226
+
227
+ @custom-variant dark (&:is(.dark *));
228
+
229
+ :root {
230
+ --radius: 0.625rem;
231
+ ${generateCssVars(colors.light)}
232
+ --chart-1: oklch(0.646 0.222 41.116);
233
+ --chart-2: oklch(0.6 0.118 184.704);
234
+ --chart-3: oklch(0.398 0.07 227.392);
235
+ --chart-4: oklch(0.828 0.189 84.429);
236
+ --chart-5: oklch(0.769 0.188 70.08);
237
+ --sidebar: oklch(0.985 0 0);
238
+ --sidebar-foreground: oklch(0.145 0 0);
239
+ --sidebar-primary: oklch(0.205 0 0);
240
+ --sidebar-primary-foreground: oklch(0.985 0 0);
241
+ --sidebar-accent: oklch(0.97 0 0);
242
+ --sidebar-accent-foreground: oklch(0.205 0 0);
243
+ --sidebar-border: oklch(0.922 0 0);
244
+ --sidebar-ring: oklch(0.708 0 0);
245
+ }
246
+
247
+ .dark {
248
+ ${generateCssVars(colors.dark)}
249
+ --chart-1: oklch(0.488 0.243 264.376);
250
+ --chart-2: oklch(0.696 0.17 162.48);
251
+ --chart-3: oklch(0.769 0.188 70.08);
252
+ --chart-4: oklch(0.627 0.265 303.9);
253
+ --chart-5: oklch(0.645 0.246 16.439);
254
+ --sidebar: oklch(0.205 0 0);
255
+ --sidebar-foreground: oklch(0.985 0 0);
256
+ --sidebar-primary: oklch(0.488 0.243 264.376);
257
+ --sidebar-primary-foreground: oklch(0.985 0 0);
258
+ --sidebar-accent: oklch(0.269 0 0);
259
+ --sidebar-accent-foreground: oklch(0.985 0 0);
260
+ --sidebar-border: oklch(1 0 0 / 10%);
261
+ --sidebar-ring: oklch(0.439 0 0);
262
+ }
263
+
264
+ @theme inline {
265
+ --font-sans: system-ui, sans-serif;
266
+ --color-background: var(--background);
267
+ --color-foreground: var(--foreground);
268
+ --color-card: var(--card);
269
+ --color-card-foreground: var(--card-foreground);
270
+ --color-popover: var(--popover);
271
+ --color-popover-foreground: var(--popover-foreground);
272
+ --color-primary: var(--primary);
273
+ --color-primary-foreground: var(--primary-foreground);
274
+ --color-secondary: var(--secondary);
275
+ --color-secondary-foreground: var(--secondary-foreground);
276
+ --color-muted: var(--muted);
277
+ --color-muted-foreground: var(--muted-foreground);
278
+ --color-accent: var(--accent);
279
+ --color-accent-foreground: var(--accent-foreground);
280
+ --color-destructive: var(--destructive);
281
+ --color-border: var(--border);
282
+ --color-input: var(--input);
283
+ --color-ring: var(--ring);
284
+ --color-chart-1: var(--chart-1);
285
+ --color-chart-2: var(--chart-2);
286
+ --color-chart-3: var(--chart-3);
287
+ --color-chart-4: var(--chart-4);
288
+ --color-chart-5: var(--chart-5);
289
+ --color-sidebar: var(--sidebar);
290
+ --color-sidebar-foreground: var(--sidebar-foreground);
291
+ --color-sidebar-primary: var(--sidebar-primary);
292
+ --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
293
+ --color-sidebar-accent: var(--sidebar-accent);
294
+ --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
295
+ --color-sidebar-border: var(--sidebar-border);
296
+ --color-sidebar-ring: var(--sidebar-ring);
297
+ --radius-sm: calc(var(--radius) - 4px);
298
+ --radius-md: calc(var(--radius) - 2px);
299
+ --radius-lg: var(--radius);
300
+ --radius-xl: calc(var(--radius) + 4px);
301
+ --radius-2xl: calc(var(--radius) + 8px);
302
+ --radius-3xl: calc(var(--radius) + 12px);
303
+ --radius-4xl: calc(var(--radius) + 16px);
304
+ }
305
+
306
+ @layer base {
307
+ * {
308
+ @apply border-border outline-ring/50;
309
+ }
310
+ body {
311
+ @apply font-sans bg-background text-foreground;
312
+ }
313
+ html {
314
+ @apply font-sans;
315
+ }
316
+ button:not(:disabled),
317
+ [role="button"]:not(:disabled) {
318
+ cursor: pointer;
319
+ }
320
+ }
321
+ `;
322
+ }
@@ -0,0 +1,12 @@
1
+ export function getUtilsTemplate(): string {
2
+ return `import { clsx, type ClassValue } from 'clsx';
3
+ import { twMerge } from 'tailwind-merge';
4
+
5
+ /**
6
+ * Utility function for merging Tailwind CSS classes with proper precedence
7
+ */
8
+ export function cn(...inputs: ClassValue[]): string {
9
+ return twMerge(clsx(inputs));
10
+ }
11
+ `;
12
+ }
@@ -0,0 +1,55 @@
1
+ import fs from 'fs-extra';
2
+ import path from 'path';
3
+
4
+ export interface Config {
5
+ $schema: string;
6
+ style: 'default' | 'new-york';
7
+ tailwind: {
8
+ css: string;
9
+ baseColor: 'neutral' | 'slate' | 'stone' | 'gray' | 'zinc';
10
+ cssVariables: boolean;
11
+ };
12
+ aliases: {
13
+ components: string;
14
+ utils: string;
15
+ ui: string;
16
+ };
17
+ iconLibrary: string;
18
+ }
19
+
20
+ export function getDefaultConfig(): Config {
21
+ return {
22
+ $schema: 'https://shadcn-angular.dev/schema.json',
23
+ style: 'default',
24
+ tailwind: {
25
+ css: 'src/styles.scss',
26
+ baseColor: 'neutral',
27
+ cssVariables: true,
28
+ },
29
+ aliases: {
30
+ components: '@/components',
31
+ utils: '@/components/lib/utils',
32
+ ui: '@/components/ui',
33
+ },
34
+ iconLibrary: 'lucide-angular',
35
+ };
36
+ }
37
+
38
+ export async function getConfig(cwd: string): Promise<Config | null> {
39
+ const configPath = path.join(cwd, 'components.json');
40
+
41
+ if (!await fs.pathExists(configPath)) {
42
+ return null;
43
+ }
44
+
45
+ try {
46
+ return await fs.readJson(configPath);
47
+ } catch {
48
+ return null;
49
+ }
50
+ }
51
+
52
+ export async function writeConfig(cwd: string, config: Config): Promise<void> {
53
+ const configPath = path.join(cwd, 'components.json');
54
+ await fs.writeJson(configPath, config, { spaces: 2 });
55
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "lib": [
7
+ "ES2022"
8
+ ],
9
+ "outDir": "./dist",
10
+ "rootDir": "./src",
11
+ "strict": true,
12
+ "esModuleInterop": true,
13
+ "skipLibCheck": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "resolveJsonModule": true,
16
+ "declaration": true
17
+ },
18
+ "include": [
19
+ "src/**/*"
20
+ ],
21
+ "exclude": [
22
+ "node_modules",
23
+ "dist"
24
+ ]
25
+ }