kira-kit 0.2.0

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,246 @@
1
+ import { converter } from "culori";
2
+ import { STATIC_STYLES } from "./templates";
3
+
4
+ const oklch = converter("oklch");
5
+
6
+ function generatePalette(primaryColor: string) {
7
+ const p = oklch(primaryColor);
8
+ if (!p) throw new Error(`Invalid color: ${primaryColor}`);
9
+ const h = p.h || 0;
10
+ const c = p.c || 0.15;
11
+
12
+ const genVal = (lightness: number, chroma: number = c) =>
13
+ `${lightness} ${chroma} ${h}`;
14
+
15
+ return {
16
+ light: {
17
+ background: "1 0 0",
18
+ foreground: "0.145 0 0",
19
+ card: "1 0 0",
20
+ cardForeground: "0.145 0 0",
21
+ popover: "1 0 0",
22
+ popoverForeground: "0.145 0 0",
23
+ primary: genVal(0.59, c),
24
+ primaryForeground: "0.97 0.01 343",
25
+ secondary: genVal(0.75, c * 0.5),
26
+ secondaryForeground: "0.2 0.03 15",
27
+ muted: genVal(0.95, c * 0.1),
28
+ mutedForeground: genVal(0.5, c * 0.2),
29
+ accent: genVal(0.92, c * 0.2),
30
+ accentForeground: genVal(0.3, c * 0.2),
31
+ destructive: "0.6 0.22 20",
32
+ destructiveForeground: "0.98 0.01 20",
33
+ border: "0.9 0.01 20",
34
+ input: "0.9 0.01 20",
35
+ ring: genVal(0.7, c * 0.5),
36
+ chart1: genVal(0.75, c),
37
+ chart2: `oklch(0.75 ${c} ${h + 60})`
38
+ .replace("oklch(", "")
39
+ .replace(")", ""),
40
+ chart3: `oklch(0.75 ${c} ${h + 120})`
41
+ .replace("oklch(", "")
42
+ .replace(")", ""),
43
+ chart4: `oklch(0.75 ${c} ${h + 180})`
44
+ .replace("oklch(", "")
45
+ .replace(")", ""),
46
+ chart5: `oklch(0.75 ${c} ${h + 240})`
47
+ .replace("oklch(", "")
48
+ .replace(")", ""),
49
+ sidebar: "0.985 0 0",
50
+ sidebarForeground: "0.145 0 0",
51
+ sidebarPrimary: genVal(0.59, c),
52
+ sidebarPrimaryForeground: "0.97 0.01 343",
53
+ sidebarAccent: genVal(0.9, c * 0.2),
54
+ sidebarAccentForeground: genVal(0.25, c * 0.2),
55
+ sidebarBorder: "0.922 0 0",
56
+ sidebarRing: genVal(0.7, c * 0.5),
57
+ },
58
+ dark: {
59
+ background: "0.145 0 0",
60
+ foreground: "0.985 0 0",
61
+ card: "0.205 0 0",
62
+ cardForeground: "0.985 0 0",
63
+ popover: "0.205 0 0",
64
+ popoverForeground: "0.985 0 0",
65
+ primary: genVal(0.66, c),
66
+ primaryForeground: "0.97 0.01 343",
67
+ secondary: genVal(0.6, c * 0.4),
68
+ secondaryForeground: "0.985 0 0",
69
+ muted: genVal(0.25, c * 0.1),
70
+ mutedForeground: genVal(0.65, c * 0.2),
71
+ accent: genVal(0.4, c * 0.3),
72
+ accentForeground: "0.98 0.01 10",
73
+ destructive: "0.65 0.2 15",
74
+ destructiveForeground: "0.98 0.01 15",
75
+ border: "1 0 0 / 15%",
76
+ input: "1 0 0 / 20%",
77
+ ring: genVal(0.65, c * 0.5),
78
+ chart1: genVal(0.7, c),
79
+ chart2: `oklch(0.7 ${c} ${h + 60})`
80
+ .replace("oklch(", "")
81
+ .replace(")", ""),
82
+ chart3: `oklch(0.7 ${c} ${h + 120})`
83
+ .replace("oklch(", "")
84
+ .replace(")", ""),
85
+ chart4: `oklch(0.7 ${c} ${h + 180})`
86
+ .replace("oklch(", "")
87
+ .replace(")", ""),
88
+ chart5: `oklch(0.7 ${c} ${h + 240})`
89
+ .replace("oklch(", "")
90
+ .replace(")", ""),
91
+ sidebar: "0.205 0 0",
92
+ sidebarForeground: "0.985 0 0",
93
+ sidebarPrimary: genVal(0.73, c),
94
+ sidebarPrimaryForeground: "0.97 0.01 343",
95
+ sidebarAccent: genVal(0.45, c * 0.3),
96
+ sidebarAccentForeground: "0.98 0.01 10",
97
+ sidebarBorder: "1 0 0 / 10%",
98
+ sidebarRing: genVal(0.65, c * 0.5),
99
+ },
100
+ };
101
+ }
102
+
103
+ export function generateCss(primaryColor: string): string {
104
+ const palette = generatePalette(primaryColor);
105
+
106
+ return `@import "tailwindcss";
107
+ @import "tw-animate-css";
108
+ @import "shadcn/tailwind.css";
109
+ @import "@fontsource-variable/geist";
110
+
111
+ @custom-variant dark (&:is(.dark *));
112
+
113
+ :root {
114
+ --background: oklch(${palette.light.background});
115
+ --foreground: oklch(${palette.light.foreground});
116
+ --card: oklch(${palette.light.card});
117
+ --card-foreground: oklch(${palette.light.cardForeground});
118
+ --popover: oklch(${palette.light.popover});
119
+ --popover-foreground: oklch(${palette.light.popoverForeground});
120
+ --primary: oklch(${palette.light.primary});
121
+ --primary-foreground: oklch(${palette.light.primaryForeground});
122
+ --secondary: oklch(${palette.light.secondary});
123
+ --secondary-foreground: oklch(${palette.light.secondaryForeground});
124
+ --muted: oklch(${palette.light.muted});
125
+ --muted-foreground: oklch(${palette.light.mutedForeground});
126
+ --accent: oklch(${palette.light.accent});
127
+ --accent-foreground: oklch(${palette.light.accentForeground});
128
+ --destructive: oklch(${palette.light.destructive});
129
+ --destructive-foreground: oklch(${palette.light.destructiveForeground});
130
+ --border: oklch(${palette.light.border});
131
+ --input: oklch(${palette.light.input});
132
+ --ring: oklch(${palette.light.ring});
133
+ --radius: 0.45rem;
134
+
135
+ --chart-1: oklch(${palette.light.chart1});
136
+ --chart-2: oklch(${palette.light.chart2});
137
+ --chart-3: oklch(${palette.light.chart3});
138
+ --chart-4: oklch(${palette.light.chart4});
139
+ --chart-5: oklch(${palette.light.chart5});
140
+
141
+ --sidebar: oklch(${palette.light.sidebar});
142
+ --sidebar-foreground: oklch(${palette.light.sidebarForeground});
143
+ --sidebar-primary: oklch(${palette.light.sidebarPrimary});
144
+ --sidebar-primary-foreground: oklch(${palette.light.sidebarPrimaryForeground});
145
+ --sidebar-accent: oklch(${palette.light.sidebarAccent});
146
+ --sidebar-accent-foreground: oklch(${palette.light.sidebarAccentForeground});
147
+ --sidebar-border: oklch(${palette.light.sidebarBorder});
148
+ --sidebar-ring: oklch(${palette.light.sidebarRing});
149
+ }
150
+
151
+ .dark {
152
+ --background: oklch(${palette.dark.background});
153
+ --foreground: oklch(${palette.dark.foreground});
154
+ --card: oklch(${palette.dark.card});
155
+ --card-foreground: oklch(${palette.dark.cardForeground});
156
+ --popover: oklch(${palette.dark.popover});
157
+ --popover-foreground: oklch(${palette.dark.popoverForeground});
158
+ --primary: oklch(${palette.dark.primary});
159
+ --primary-foreground: oklch(${palette.dark.primaryForeground});
160
+ --secondary: oklch(${palette.dark.secondary});
161
+ --secondary-foreground: oklch(${palette.dark.secondaryForeground});
162
+ --muted: oklch(${palette.dark.muted});
163
+ --muted-foreground: oklch(${palette.dark.mutedForeground});
164
+ --accent: oklch(${palette.dark.accent});
165
+ --accent-foreground: oklch(${palette.dark.accentForeground});
166
+ --destructive: oklch(${palette.dark.destructive});
167
+ --destructive-foreground: oklch(${palette.dark.destructiveForeground});
168
+ --border: oklch(${palette.dark.border});
169
+ --input: oklch(${palette.dark.input});
170
+ --ring: oklch(${palette.dark.ring});
171
+
172
+ --chart-1: oklch(${palette.dark.chart1});
173
+ --chart-2: oklch(${palette.dark.chart2});
174
+ --chart-3: oklch(${palette.dark.chart3});
175
+ --chart-4: oklch(${palette.dark.chart4});
176
+ --chart-5: oklch(${palette.dark.chart5});
177
+
178
+ --sidebar: oklch(${palette.dark.sidebar});
179
+ --sidebar-foreground: oklch(${palette.dark.sidebarForeground});
180
+ --sidebar-primary: oklch(${palette.dark.sidebarPrimary});
181
+ --sidebar-primary-foreground: oklch(${palette.dark.sidebarPrimaryForeground});
182
+ --sidebar-accent: oklch(${palette.dark.sidebarAccent});
183
+ --sidebar-accent-foreground: oklch(${palette.dark.sidebarAccentForeground});
184
+ --sidebar-border: oklch(${palette.dark.sidebarBorder});
185
+ --sidebar-ring: oklch(${palette.dark.sidebarRing});
186
+ }
187
+
188
+ @theme inline {
189
+ --font-sans: "Geist Variable", sans-serif;
190
+
191
+ /* Animation tokens */
192
+ --animate-shimmer: shimmer 2s infinite;
193
+ --animate-skeleton-wave: skeleton-wave 2s ease-in-out infinite;
194
+
195
+ /* Colors */
196
+ --color-sidebar-ring: var(--sidebar-ring);
197
+ --color-sidebar-border: var(--sidebar-border);
198
+ --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
199
+ --color-sidebar-accent: var(--sidebar-accent);
200
+ --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
201
+ --color-sidebar-primary: var(--sidebar-primary);
202
+ --color-sidebar-foreground: var(--sidebar-foreground);
203
+ --color-sidebar: var(--sidebar);
204
+ --color-chart-5: var(--chart-5);
205
+ --color-chart-4: var(--chart-4);
206
+ --color-chart-3: var(--chart-3);
207
+ --color-chart-2: var(--chart-2);
208
+ --color-chart-1: var(--chart-1);
209
+ --color-ring: var(--ring);
210
+ --color-input: var(--input);
211
+ --color-border: var(--border);
212
+ --color-destructive: var(--destructive);
213
+ --color-destructive-foreground: var(--destructive-foreground);
214
+ --color-accent-foreground: var(--accent-foreground);
215
+ --color-accent: var(--accent);
216
+ --color-muted-foreground: var(--muted-foreground);
217
+ --color-muted: var(--muted);
218
+ --color-secondary-foreground: var(--secondary-foreground);
219
+ --color-secondary: var(--secondary);
220
+ --color-primary-foreground: var(--primary-foreground);
221
+ --color-primary: var(--primary);
222
+ --color-popover-foreground: var(--popover-foreground);
223
+ --color-popover: var(--popover);
224
+ --color-card-foreground: var(--card-foreground);
225
+ --color-card: var(--card);
226
+ --color-foreground: var(--foreground);
227
+ --color-background: var(--background);
228
+
229
+ --radius-sm: calc(var(--radius) - 4px);
230
+ --radius-md: calc(var(--radius) - 2px);
231
+ --radius-lg: var(--radius);
232
+ --radius-xl: calc(var(--radius) + 4px);
233
+ --radius-2xl: calc(var(--radius) + 8px);
234
+ --radius-3xl: calc(var(--radius) + 12px);
235
+ --radius-4xl: calc(var(--radius) + 16px);
236
+ }
237
+
238
+ @layer base {
239
+ * { @apply border-border outline-ring/50; }
240
+ body { @apply font-sans bg-background text-foreground; }
241
+ html { @apply font-sans; }
242
+ }
243
+
244
+ ${STATIC_STYLES}
245
+ `;
246
+ }
@@ -0,0 +1,20 @@
1
+ import inquirer from "inquirer";
2
+
3
+ export async function selectBaseColor(): Promise<string> {
4
+ const { baseColor } = await inquirer.prompt([
5
+ {
6
+ type: "list",
7
+ name: "baseColor",
8
+ message: "Choose base color:",
9
+ choices: [
10
+ { name: "Slate", value: "slate" },
11
+ { name: "Gray", value: "gray" },
12
+ { name: "Zinc", value: "zinc" },
13
+ { name: "Neutral", value: "neutral" },
14
+ { name: "Stone", value: "stone" },
15
+ ],
16
+ default: "neutral",
17
+ },
18
+ ]);
19
+ return baseColor;
20
+ }
@@ -0,0 +1,23 @@
1
+ import inquirer from "inquirer";
2
+
3
+ export async function selectPrimaryColor(): Promise<string> {
4
+ const { primaryColor } = await inquirer.prompt([
5
+ {
6
+ type: "list",
7
+ name: "primaryColor",
8
+ message: "Choose primary color:",
9
+ choices: [
10
+ { name: "Blue", value: "blue" },
11
+ { name: "Green", value: "green" },
12
+ { name: "Orange", value: "orange" },
13
+ { name: "Pink", value: "pink" },
14
+ { name: "Purple", value: "purple" },
15
+ { name: "Red", value: "red" },
16
+ { name: "Violet", value: "violet" },
17
+ { name: "Yellow", value: "yellow" },
18
+ ],
19
+ default: "blue",
20
+ },
21
+ ]);
22
+ return primaryColor;
23
+ }
@@ -0,0 +1,71 @@
1
+ import inquirer from "inquirer";
2
+ import { existsSync } from "fs";
3
+ import { join } from "path";
4
+
5
+ export type ProjectType = "nextjs" | "vite" | "remix" | "gatsby" | "other";
6
+
7
+ export async function detectProjectType(cwd: string): Promise<ProjectType> {
8
+ const files = ["next.config.js", "vite.config.ts", "remix.config.js", "gatsby-config.js"];
9
+
10
+ for (const file of files) {
11
+ if (existsSync(join(cwd, file))) {
12
+ if (file === "next.config.js") return "nextjs";
13
+ if (file === "vite.config.ts") return "vite";
14
+ if (file === "remix.config.js") return "remix";
15
+ if (file === "gatsby-config.js") return "gatsby";
16
+ }
17
+ }
18
+
19
+ return "other";
20
+ }
21
+
22
+ export async function selectProjectType(cwd: string): Promise<ProjectType> {
23
+ const detected = await detectProjectType(cwd);
24
+
25
+ const { projectType } = await inquirer.prompt([
26
+ {
27
+ type: "list",
28
+ name: "projectType",
29
+ message: `Detected: ${detected}. Choose project type:`,
30
+ choices: [
31
+ { name: "Next.js", value: "nextjs" },
32
+ { name: "Vite", value: "vite" },
33
+ { name: "Remix", value: "remix" },
34
+ { name: "Gatsby", value: "gatsby" },
35
+ { name: "Other", value: "other" },
36
+ ],
37
+ default: detected,
38
+ },
39
+ ]);
40
+
41
+ return projectType;
42
+ }
43
+
44
+ export async function confirmProjectType(
45
+ detected: ProjectType
46
+ ): Promise<boolean> {
47
+ const { confirm } = await inquirer.prompt([
48
+ {
49
+ type: "confirm",
50
+ name: "confirm",
51
+ message: `Detected project type: ${detected}. Is this correct?`,
52
+ default: true,
53
+ },
54
+ ]);
55
+ return confirm;
56
+ }
57
+
58
+ export async function inputAlias(
59
+ name: string,
60
+ defaultValue: string
61
+ ): Promise<string> {
62
+ const { alias } = await inquirer.prompt([
63
+ {
64
+ type: "input",
65
+ name: "alias",
66
+ message: `Enter ${name} alias:`,
67
+ default: defaultValue,
68
+ },
69
+ ]);
70
+ return alias;
71
+ }
package/src/types.ts ADDED
@@ -0,0 +1,61 @@
1
+ export interface RegistryItem {
2
+ name: string;
3
+ type: "registry:ui" | "registry:hook";
4
+ title: string;
5
+ description: string;
6
+ dependencies: string[];
7
+ registryDependencies: string[];
8
+ files: Array<{
9
+ path: string;
10
+ type: "registry:component" | "registry:hook";
11
+ content: string;
12
+ }>;
13
+ }
14
+
15
+ export interface Registry {
16
+ $schema: string;
17
+ name: string;
18
+ homepage: string;
19
+ items: RegistryItem[];
20
+ }
21
+
22
+ export interface ComponentsConfig {
23
+ $schema: string;
24
+ style: string;
25
+ rsc: boolean;
26
+ tsx: boolean;
27
+ registryUrl: string;
28
+ tailwind: {
29
+ config: string;
30
+ css: string;
31
+ baseColor: string;
32
+ cssVariables: boolean;
33
+ prefix?: string;
34
+ };
35
+ iconLibrary: string;
36
+ aliases: {
37
+ components: string;
38
+ utils: string;
39
+ ui: string;
40
+ lib: string;
41
+ hooks: string;
42
+ };
43
+ menuColor: string;
44
+ menuAccent: string;
45
+ registries: Record<string, string>;
46
+ }
47
+
48
+ export interface AddOptions {
49
+ components: string[];
50
+ cwd: string;
51
+ overwrite: boolean;
52
+ yes: boolean;
53
+ all: boolean;
54
+ }
55
+
56
+ export interface InitOptions {
57
+ cwd: string;
58
+ baseColor: string;
59
+ primaryColor: string;
60
+ yes: boolean;
61
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "lib": ["ES2022"],
7
+ "strict": true,
8
+ "skipLibCheck": true,
9
+ "esModuleInterop": true,
10
+ "allowSyntheticDefaultImports": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "noEmit": true,
15
+ "baseUrl": ".",
16
+ "paths": {
17
+ "@/*": ["./src/*"]
18
+ }
19
+ },
20
+ "include": ["src/**/*"],
21
+ "exclude": ["node_modules"]
22
+ }