ajoy-style-rules 1.0.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.
package/index.js ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+ import prompts from "prompts";
3
+ import fs from "fs-extra";
4
+ import path from "path";
5
+ import { fileURLToPath } from "url";
6
+
7
+ // Fix __dirname for ES modules
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = path.dirname(__filename);
10
+
11
+ async function setup() {
12
+ const response = await prompts({
13
+ type: "select",
14
+ name: "platform",
15
+ message: "Choose your platform",
16
+ choices: [
17
+ { title: "React (Web)", value: "react" },
18
+ { title: "React Native", value: "react-native" },
19
+ ],
20
+ });
21
+
22
+ let sourceFile;
23
+
24
+ if (response.platform === "react") {
25
+ sourceFile = path.join(__dirname, "templates", "react.js");
26
+ } else {
27
+ sourceFile = path.join(__dirname, "templates", "react-native.js");
28
+ }
29
+
30
+ // Destination (user project root)
31
+ const destFile = path.join(
32
+ process.cwd(),
33
+ `theme.${response.platform === "react" ? "web" : "native"}.js`,
34
+ );
35
+
36
+ try {
37
+ await fs.copy(sourceFile, destFile);
38
+ console.log("Theme file created successfully!");
39
+ } catch (err) {
40
+ console.error("Error copying file:", err);
41
+ }
42
+ }
43
+
44
+ setup();
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "ajoy-style-rules",
3
+ "version": "1.0.0",
4
+ "description": "CLI to generate style rules for React and React Native",
5
+ "main": "index.js",
6
+ "type": "module",
7
+ "files": [
8
+ "index.js",
9
+ "templates"
10
+ ],
11
+ "bin": {
12
+ "ajoy-style": "index.js"
13
+ },
14
+ "keywords": [
15
+ "design-system",
16
+ "react",
17
+ "react-native",
18
+ "cli"
19
+ ],
20
+ "author": "Ajoy Das",
21
+ "license": "MIT"
22
+ }
package/readme.md ADDED
@@ -0,0 +1,90 @@
1
+ # AJOY STYLE RULES
2
+
3
+ A simple CLI tool to generate a clean design system for **React** or **React Native**.
4
+
5
+ ---
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install ajoy-style-rules
11
+ ```
12
+
13
+ Or run directly:
14
+
15
+ ```bash
16
+ npx ajoy-style-rules
17
+ ```
18
+
19
+ ---
20
+
21
+ ## Usage
22
+
23
+ Run the CLI:
24
+
25
+ ```bash
26
+ npx ajoy-style-rules
27
+ ```
28
+
29
+ You will be prompted:
30
+
31
+ ```
32
+ Choose your platform
33
+ > React (Web)
34
+ React Native
35
+ ```
36
+
37
+ ---
38
+
39
+ ## Output
40
+
41
+ Based on your selection, a theme file will be created in your project:
42
+
43
+ ### React
44
+
45
+ ```
46
+ theme.web.js
47
+ ```
48
+
49
+ ### React Native
50
+
51
+ ```
52
+ theme.native.js
53
+ ```
54
+
55
+ ---
56
+
57
+ ## Example
58
+
59
+ ```js
60
+ import theme from "./theme";
61
+
62
+ const styles = {
63
+ container: {
64
+ backgroundColor: theme.bg.base,
65
+ padding: theme.spacing.lg,
66
+ },
67
+ };
68
+ ```
69
+
70
+ ---
71
+
72
+ ## Features
73
+
74
+ * Clean design system
75
+ * Light & Dark themes
76
+ * Ready for production
77
+ * Works with React & React Native
78
+
79
+ ---
80
+
81
+ ## Notes
82
+
83
+ * The file will be created in your current project folder
84
+ * Existing files will not be overwritten
85
+
86
+ ---
87
+
88
+ ## Author
89
+
90
+ Ajoy Das
@@ -0,0 +1,348 @@
1
+
2
+ /**
3
+ * LIGHT THEME
4
+ *
5
+ * PURPOSE:
6
+ * - Default theme for light mode UI
7
+ * - Use across all components (no raw values)
8
+ */
9
+ export const lightTheme = {
10
+ /**
11
+ * BRAND COLORS
12
+ *
13
+ * USE:
14
+ * - primary → main actions (buttons, links)
15
+ * - secondary → supporting UI
16
+ * - accent → highlights / special UI
17
+ */
18
+ brand: {
19
+ primary: "#2563EB",
20
+ secondary: "#64748B",
21
+ accent: "#7C3AED",
22
+ },
23
+
24
+ /**
25
+ * SEMANTIC COLORS
26
+ *
27
+ * USE:
28
+ * - success → success states
29
+ * - warning → warnings
30
+ * - danger → errors/destructive
31
+ * - info → informational UI
32
+ */
33
+ colors: {
34
+ success: "#16A34A",
35
+ warning: "#F59E0B",
36
+ danger: "#DC2626",
37
+ info: "#0EA5E9",
38
+ },
39
+
40
+ /**
41
+ * BACKGROUND SYSTEM
42
+ *
43
+ * USE:
44
+ * - base → app background
45
+ * - surface → cards / containers
46
+ * - elevated → modals / overlays
47
+ * - subtle → hover / press feedback
48
+ * - inverse → dark sections inside light UI
49
+ */
50
+ bg: {
51
+ base: "#FFFFFF",
52
+ surface: "#F8FAFC",
53
+ elevated: "#FFFFFF",
54
+ subtle: "#F1F5F9",
55
+ inverse: "#0F172A",
56
+ },
57
+
58
+ /**
59
+ * TEXT COLORS
60
+ *
61
+ * USE:
62
+ * - primary → main readable text
63
+ * - secondary → less important text
64
+ * - tertiary → hints / disabled
65
+ * - inverse → text on dark background
66
+ * - link → clickable text
67
+ */
68
+ text: {
69
+ primary: "#0F172A",
70
+ secondary: "#475569",
71
+ tertiary: "#94A3B8",
72
+ inverse: "#FFFFFF",
73
+ link: "#2563EB",
74
+ },
75
+
76
+ /**
77
+ * BORDER SYSTEM
78
+ *
79
+ * USE:
80
+ * - color → default border
81
+ * - subtle → low visibility borders
82
+ * - strong → emphasis borders
83
+ */
84
+ border: {
85
+ color: "#E2E8F0",
86
+ subtle: "#F1F5F9",
87
+ strong: "#CBD5F5",
88
+ },
89
+
90
+ /**
91
+ * BORDER RADIUS
92
+ *
93
+ * USE:
94
+ * - sm → small elements (inputs, chips)
95
+ * - md → default (buttons, cards)
96
+ * - lg/xl → containers, modals
97
+ * - full → rounded (avatars, pills)
98
+ */
99
+ radius: {
100
+ sm: 4,
101
+ md: 8,
102
+ lg: 12,
103
+ xl: 16,
104
+ full: 9999,
105
+ },
106
+
107
+ /**
108
+ * SHADOW (React Native)
109
+ *
110
+ * USE:
111
+ * - sm → subtle elevation
112
+ * - md → default card
113
+ * - lg → modal / high elevation
114
+ *
115
+ * NOTE:
116
+ * - Works for both iOS (shadow*) and Android (elevation)
117
+ */
118
+ shadow: {
119
+ sm: {
120
+ shadowColor: "#000",
121
+ shadowOpacity: 0.05,
122
+ shadowRadius: 2,
123
+ shadowOffset: { width: 0, height: 1 },
124
+ elevation: 1,
125
+ },
126
+ md: {
127
+ shadowColor: "#000",
128
+ shadowOpacity: 0.08,
129
+ shadowRadius: 6,
130
+ shadowOffset: { width: 0, height: 4 },
131
+ elevation: 3,
132
+ },
133
+ lg: {
134
+ shadowColor: "#000",
135
+ shadowOpacity: 0.12,
136
+ shadowRadius: 12,
137
+ shadowOffset: { width: 0, height: 10 },
138
+ elevation: 6,
139
+ },
140
+ },
141
+
142
+ /**
143
+ * TYPOGRAPHY
144
+ *
145
+ * USE:
146
+ * - fontFamily → base font
147
+ * - size → text sizes
148
+ * - weight → font weights
149
+ *
150
+ * NOTE:
151
+ * - Load custom fonts (e.g., Inter) using expo-font
152
+ */
153
+ typography: {
154
+ fontFamily: "System",
155
+ size: {
156
+ xs: 12,
157
+ sm: 14,
158
+ md: 16,
159
+ lg: 18,
160
+ xl: 20,
161
+ "2xl": 24,
162
+ "3xl": 30,
163
+ },
164
+ weight: {
165
+ regular: "400",
166
+ medium: "500",
167
+ semibold: "600",
168
+ bold: "700",
169
+ },
170
+ },
171
+
172
+ /**
173
+ * SPACING SYSTEM
174
+ *
175
+ * USE:
176
+ * - Consistent padding/margin
177
+ *
178
+ * RULE:
179
+ * - Never use random numbers (like 13, 22)
180
+ */
181
+ spacing: {
182
+ xs: 4,
183
+ sm: 8,
184
+ md: 12,
185
+ lg: 16,
186
+ xl: 24,
187
+ "2xl": 32,
188
+ },
189
+
190
+ /**
191
+ * STATE TOKENS
192
+ *
193
+ * USE:
194
+ * - hover → press/hover feedback
195
+ * - active → pressed state
196
+ * - focus → focus ring / highlight
197
+ * - disabled → disabled UI
198
+ */
199
+ state: {
200
+ hover: "rgba(0,0,0,0.04)",
201
+ active: "rgba(0,0,0,0.08)",
202
+ focus: "#2563EB",
203
+ disabled: "rgba(0,0,0,0.3)",
204
+ },
205
+ };
206
+
207
+ /**
208
+ * DARK THEME
209
+ *
210
+ * PURPOSE:
211
+ * - Used when dark mode is enabled
212
+ *
213
+ * RULE:
214
+ * - Same structure as lightTheme (never change structure)
215
+ */
216
+ export const darkTheme = {
217
+ /**
218
+ * BRAND COLORS (slightly brighter for contrast)
219
+ */
220
+ brand: {
221
+ primary: "#3B82F6",
222
+ secondary: "#94A3B8",
223
+ accent: "#8B5CF6",
224
+ },
225
+
226
+ /**
227
+ * SEMANTIC COLORS (adjusted for dark visibility)
228
+ */
229
+ colors: {
230
+ success: "#22C55E",
231
+ warning: "#FBBF24",
232
+ danger: "#EF4444",
233
+ info: "#38BDF8",
234
+ },
235
+
236
+ /**
237
+ * BACKGROUND SYSTEM (dark hierarchy)
238
+ */
239
+ bg: {
240
+ base: "#0F172A",
241
+ surface: "#1E293B",
242
+ elevated: "#334155",
243
+ subtle: "#1E293B",
244
+ inverse: "#FFFFFF",
245
+ },
246
+
247
+ /**
248
+ * TEXT SYSTEM (high contrast)
249
+ */
250
+ text: {
251
+ primary: "#F8FAFC",
252
+ secondary: "#CBD5F5",
253
+ tertiary: "#64748B",
254
+ inverse: "#0F172A",
255
+ link: "#3B82F6",
256
+ },
257
+
258
+ /**
259
+ * BORDER SYSTEM (darker tones)
260
+ */
261
+ border: {
262
+ color: "#334155",
263
+ subtle: "#1E293B",
264
+ strong: "#475569",
265
+ },
266
+
267
+ /**
268
+ * RADIUS (same as light — consistency)
269
+ */
270
+ radius: {
271
+ sm: 4,
272
+ md: 8,
273
+ lg: 12,
274
+ xl: 16,
275
+ full: 9999,
276
+ },
277
+
278
+ /**
279
+ * SHADOW (stronger for dark backgrounds)
280
+ */
281
+ shadow: {
282
+ sm: {
283
+ shadowColor: "#000",
284
+ shadowOpacity: 0.4,
285
+ shadowRadius: 2,
286
+ shadowOffset: { width: 0, height: 1 },
287
+ elevation: 1,
288
+ },
289
+ md: {
290
+ shadowColor: "#000",
291
+ shadowOpacity: 0.5,
292
+ shadowRadius: 6,
293
+ shadowOffset: { width: 0, height: 4 },
294
+ elevation: 3,
295
+ },
296
+ lg: {
297
+ shadowColor: "#000",
298
+ shadowOpacity: 0.6,
299
+ shadowRadius: 12,
300
+ shadowOffset: { width: 0, height: 10 },
301
+ elevation: 6,
302
+ },
303
+ },
304
+
305
+ /**
306
+ * TYPOGRAPHY (same as light)
307
+ */
308
+ typography: {
309
+ fontFamily: "System",
310
+ size: {
311
+ xs: 12,
312
+ sm: 14,
313
+ md: 16,
314
+ lg: 18,
315
+ xl: 20,
316
+ "2xl": 24,
317
+ "3xl": 30,
318
+ },
319
+ weight: {
320
+ regular: "400",
321
+ medium: "500",
322
+ semibold: "600",
323
+ bold: "700",
324
+ },
325
+ },
326
+
327
+ /**
328
+ * SPACING (same as light)
329
+ */
330
+ spacing: {
331
+ xs: 4,
332
+ sm: 8,
333
+ md: 12,
334
+ lg: 16,
335
+ xl: 24,
336
+ "2xl": 32,
337
+ },
338
+
339
+ /**
340
+ * STATE TOKENS (adapted for dark)
341
+ */
342
+ state: {
343
+ hover: "rgba(255,255,255,0.06)",
344
+ active: "rgba(255,255,255,0.12)",
345
+ focus: "#3B82F6",
346
+ disabled: "rgba(255,255,255,0.3)",
347
+ },
348
+ };
@@ -0,0 +1,228 @@
1
+ export const lightTheme = {
2
+ brand: {
3
+ primary: "#2563EB", // modern blue (trust, tech)
4
+ secondary: "#64748B", // neutral slate
5
+ accent: "#7C3AED", // subtle personality (purple)
6
+ },
7
+
8
+ /**
9
+ * SEMANTIC COLORS (REAL USAGE)
10
+ */
11
+ colors: {
12
+ success: "#16A34A",
13
+ warning: "#F59E0B",
14
+ danger: "#DC2626",
15
+ info: "#0EA5E9",
16
+ },
17
+
18
+ /**
19
+ * BACKGROUND SYSTEM (STRICT HIERARCHY)
20
+ */
21
+ background: {
22
+ base: "#FFFFFF", // app background
23
+ surface: "#F8FAFC", // cards
24
+ elevated: "#FFFFFF", // modals
25
+ subtle: "#F1F5F9", // hover
26
+ inverse: "#0F172A", // dark sections
27
+ },
28
+
29
+ /**
30
+ * TEXT SYSTEM (PROPER CONTRAST)
31
+ */
32
+ text: {
33
+ primary: "#0F172A",
34
+ secondary: "#475569",
35
+ tertiary: "#94A3B8",
36
+ inverse: "#FFFFFF",
37
+ link: "#2563EB",
38
+ },
39
+
40
+ /**
41
+ * BORDER SYSTEM (CLEAN)
42
+ */
43
+ border: {
44
+ color: "#E2E8F0",
45
+ subtle: "#F1F5F9",
46
+ strong: "#CBD5F5",
47
+ },
48
+
49
+ /**
50
+ * RADIUS (CONSISTENT SCALE)
51
+ */
52
+ radius: {
53
+ sm: "4px",
54
+ md: "8px",
55
+ lg: "12px",
56
+ xl: "16px",
57
+ full: "9999px",
58
+ },
59
+
60
+ /**
61
+ * SHADOW (MODERN, SOFT)
62
+ */
63
+ shadow: {
64
+ sm: "0 1px 2px rgba(0,0,0,0.05)",
65
+ md: "0 4px 12px rgba(0,0,0,0.08)",
66
+ lg: "0 10px 25px rgba(0,0,0,0.12)",
67
+ },
68
+
69
+ /**
70
+ * TYPOGRAPHY (REALISTIC DEFAULT)
71
+ */
72
+ typography: {
73
+ fontFamily: `"Inter", system-ui, sans-serif`,
74
+ size: {
75
+ xs: "12px",
76
+ sm: "14px",
77
+ md: "16px",
78
+ lg: "18px",
79
+ xl: "20px",
80
+ "2xl": "24px",
81
+ "3xl": "30px",
82
+ },
83
+ weight: {
84
+ regular: 400,
85
+ medium: 500,
86
+ semibold: 600,
87
+ bold: 700,
88
+ },
89
+ },
90
+
91
+ /**
92
+ * SPACING (SYSTEMATIC)
93
+ */
94
+ spacing: {
95
+ xs: "4px",
96
+ sm: "8px",
97
+ md: "12px",
98
+ lg: "16px",
99
+ xl: "24px",
100
+ "2xl": "32px",
101
+ },
102
+
103
+ /**
104
+ * STATE (INTERACTION READY)
105
+ */
106
+ state: {
107
+ hover: "rgba(0,0,0,0.04)",
108
+ active: "rgba(0,0,0,0.08)",
109
+ focus: "#2563EB",
110
+ disabled: "rgba(0,0,0,0.3)",
111
+ },
112
+ };
113
+
114
+ export const darkTheme = {
115
+ /**
116
+ * BRAND CORE (same identity, slightly adjusted brightness)
117
+ */
118
+ brand: {
119
+ primary: "#3B82F6", // brighter for dark bg
120
+ secondary: "#94A3B8",
121
+ accent: "#8B5CF6",
122
+ },
123
+
124
+ /**
125
+ * SEMANTIC COLORS
126
+ */
127
+ colors: {
128
+ success: "#22C55E",
129
+ warning: "#FBBF24",
130
+ danger: "#EF4444",
131
+ info: "#38BDF8",
132
+ },
133
+
134
+ /**
135
+ * BACKGROUND SYSTEM (dark hierarchy)
136
+ */
137
+ background: {
138
+ base: "#0F172A", // main app bg
139
+ surface: "#1E293B", // cards
140
+ elevated: "#334155", // modals
141
+ subtle: "#1E293B", // hover layers
142
+ inverse: "#FFFFFF", // rare light section
143
+ },
144
+
145
+ /**
146
+ * TEXT SYSTEM (high contrast)
147
+ */
148
+ text: {
149
+ primary: "#F8FAFC",
150
+ secondary: "#CBD5F5",
151
+ tertiary: "#64748B",
152
+ inverse: "#0F172A",
153
+ link: "#3B82F6",
154
+ },
155
+
156
+ /**
157
+ * BORDER SYSTEM
158
+ */
159
+ border: {
160
+ color: "#334155",
161
+ subtle: "#1E293B",
162
+ strong: "#475569",
163
+ },
164
+
165
+ /**
166
+ * RADIUS (same as light — NEVER change)
167
+ */
168
+ radius: {
169
+ sm: "4px",
170
+ md: "8px",
171
+ lg: "12px",
172
+ xl: "16px",
173
+ full: "9999px",
174
+ },
175
+
176
+ /**
177
+ * SHADOW (lighter because dark bg already heavy)
178
+ */
179
+ shadow: {
180
+ sm: "0 1px 2px rgba(0,0,0,0.4)",
181
+ md: "0 4px 12px rgba(0,0,0,0.5)",
182
+ lg: "0 10px 25px rgba(0,0,0,0.6)",
183
+ },
184
+
185
+ /**
186
+ * TYPOGRAPHY (same — consistency)
187
+ */
188
+ typography: {
189
+ fontFamily: `"Inter", system-ui, sans-serif`,
190
+ size: {
191
+ xs: "12px",
192
+ sm: "14px",
193
+ md: "16px",
194
+ lg: "18px",
195
+ xl: "20px",
196
+ "2xl": "24px",
197
+ "3xl": "30px",
198
+ },
199
+ weight: {
200
+ regular: 400,
201
+ medium: 500,
202
+ semibold: 600,
203
+ bold: 700,
204
+ },
205
+ },
206
+
207
+ /**
208
+ * SPACING (same — NEVER change)
209
+ */
210
+ spacing: {
211
+ xs: "4px",
212
+ sm: "8px",
213
+ md: "12px",
214
+ lg: "16px",
215
+ xl: "24px",
216
+ "2xl": "32px",
217
+ },
218
+
219
+ /**
220
+ * STATE SYSTEM
221
+ */
222
+ state: {
223
+ hover: "rgba(255,255,255,0.06)",
224
+ active: "rgba(255,255,255,0.12)",
225
+ focus: "#3B82F6",
226
+ disabled: "rgba(255,255,255,0.3)",
227
+ },
228
+ };