@akanjs/cli 0.0.145 → 0.0.147

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.
Files changed (34) hide show
  1. package/README.md +7 -26
  2. package/cjs/index.js +191 -28
  3. package/cjs/src/guidelines/componentRule/componentRule.instruction.md +3 -81
  4. package/cjs/src/guidelines/cssRule/cssRule.instruction.md +435 -0
  5. package/cjs/src/guidelines/docPageRule/docPageRule.instruction.md +389 -0
  6. package/cjs/src/guidelines/modelConstant/modelConstant.instruction.md +335 -752
  7. package/cjs/src/guidelines/modelStore/modelStore.instruction.md +2 -1
  8. package/cjs/src/guidelines/modelTemplate/modelTemplate.instruction.md +418 -391
  9. package/cjs/src/guidelines/modelUnit/modelUnit.instruction.md +0 -292
  10. package/cjs/src/guidelines/scalarModule/scalarModule.instruction.md +84 -0
  11. package/cjs/src/templates/app/main.js +1 -2
  12. package/esm/index.js +199 -36
  13. package/esm/src/guidelines/componentRule/componentRule.instruction.md +3 -81
  14. package/esm/src/guidelines/cssRule/cssRule.instruction.md +435 -0
  15. package/esm/src/guidelines/docPageRule/docPageRule.instruction.md +389 -0
  16. package/esm/src/guidelines/modelConstant/modelConstant.instruction.md +335 -752
  17. package/esm/src/guidelines/modelStore/modelStore.instruction.md +2 -1
  18. package/esm/src/guidelines/modelTemplate/modelTemplate.instruction.md +418 -391
  19. package/esm/src/guidelines/modelUnit/modelUnit.instruction.md +0 -292
  20. package/esm/src/guidelines/scalarModule/scalarModule.instruction.md +84 -0
  21. package/esm/src/templates/app/main.js +1 -2
  22. package/package.json +1 -1
  23. package/src/guideline/guideline.command.d.ts +3 -1
  24. package/src/guideline/guideline.prompt.d.ts +15 -1
  25. package/src/guideline/guideline.runner.d.ts +17 -3
  26. package/src/guideline/guideline.script.d.ts +8 -2
  27. package/src/guidelines/componentRule/componentRule.instruction.md +3 -81
  28. package/src/guidelines/cssRule/cssRule.instruction.md +435 -0
  29. package/src/guidelines/docPageRule/docPageRule.instruction.md +389 -0
  30. package/src/guidelines/modelConstant/modelConstant.instruction.md +335 -752
  31. package/src/guidelines/modelStore/modelStore.instruction.md +2 -1
  32. package/src/guidelines/modelTemplate/modelTemplate.instruction.md +418 -391
  33. package/src/guidelines/modelUnit/modelUnit.instruction.md +0 -292
  34. package/src/guidelines/scalarModule/scalarModule.instruction.md +84 -0
@@ -0,0 +1,435 @@
1
+ # CSS Styling Guidelines with TailwindCSS and DaisyUI in Akan.js
2
+
3
+ ## Introduction
4
+
5
+ This document provides comprehensive styling guidelines for Akan.js components using TailwindCSS and DaisyUI. Following these standards ensures consistency, maintainability, and proper theming across all applications in the Akan.js ecosystem.
6
+
7
+ ## Core Principles
8
+
9
+ 1. **Utility-First Approach**: Use Tailwind's utility classes for styling instead of custom CSS
10
+ 2. **Component Composition**: Design with composition in mind, allowing styling overrides via `className` prop
11
+ 3. **Theme Consistency**: Use DaisyUI's theme variables for colors and maintain consistent spacing
12
+ 4. **Responsive Design**: Implement mobile-first responsive layouts using Tailwind's breakpoint prefixes
13
+ 5. **Accessibility**: Ensure proper contrast, focus states, and semantic markup
14
+
15
+ ## Class Management with `clsx`
16
+
17
+ ### Importing `clsx`
18
+
19
+ Always import the `clsx` utility from the client package:
20
+
21
+ ```tsx
22
+ import { clsx } from "@akanjs/client";
23
+ ```
24
+
25
+ ### Basic Usage
26
+
27
+ Use `clsx` to combine class names conditionally:
28
+
29
+ ```tsx
30
+ <div
31
+ className={clsx(
32
+ "base-classes", // Always applied
33
+ condition && "conditional-classes", // Applied when condition is true
34
+ className // Forward className from props
35
+ )}
36
+ >
37
+ {/* Content */}
38
+ </div>
39
+ ```
40
+
41
+ ### Object Syntax for Multiple Conditions
42
+
43
+ ```tsx
44
+ <div
45
+ className={clsx(
46
+ "base-styles",
47
+ {
48
+ "bg-primary": isPrimary,
49
+ "bg-secondary": isSecondary,
50
+ "bg-success": isSuccess,
51
+ "bg-error": isError,
52
+ },
53
+ className
54
+ )}
55
+ >
56
+ {/* Content */}
57
+ </div>
58
+ ```
59
+
60
+ ## Component Structure Best Practices
61
+
62
+ ### 1. Accept and Forward `className` Prop
63
+
64
+ Every component should accept a `className` prop to enable style composition:
65
+
66
+ ```tsx
67
+ interface CardProps {
68
+ className?: string;
69
+ // Other props...
70
+ }
71
+
72
+ export const Card = ({ className, ...props }: CardProps) => {
73
+ return (
74
+ <div
75
+ className={clsx(
76
+ "card bg-base-100 shadow-md",
77
+ className // Always include at the end to allow overrides
78
+ )}
79
+ >
80
+ {/* Card content */}
81
+ </div>
82
+ );
83
+ };
84
+ ```
85
+
86
+ ### 2. Use DaisyUI's Semantic Color System
87
+
88
+ Avoid hardcoded color values. Use DaisyUI's theme variables instead for better theming support:
89
+
90
+ ✅ **Recommended:**
91
+
92
+ ```tsx
93
+ <div className="bg-primary text-primary-content hover:bg-primary-focus">Themeable content</div>
94
+ ```
95
+
96
+ ❌ **Avoid:**
97
+
98
+ ```tsx
99
+ <div className="bg-[#3b82f6] text-white hover:bg-[#2563eb]">Hardcoded colors</div>
100
+ ```
101
+
102
+ **DaisyUI Color System:**
103
+
104
+ | Base Color | Text Color | Focus/Hover Variant |
105
+ | ---------- | ----------------- | ------------------- |
106
+ | primary | primary-content | primary-focus |
107
+ | secondary | secondary-content | secondary-focus |
108
+ | accent | accent-content | accent-focus |
109
+ | neutral | neutral-content | neutral-focus |
110
+ | base-100 | base-content | base-200/base-300 |
111
+ | info | info-content | info-focus |
112
+ | success | success-content | success-focus |
113
+ | warning | warning-content | warning-focus |
114
+ | error | error-content | error-focus |
115
+
116
+ ### 3. Implement Responsive Design
117
+
118
+ Use Tailwind's responsive prefixes for mobile-first development:
119
+
120
+ ```tsx
121
+ <div className="flex flex-col gap-4 md:flex-row">
122
+ <div className="w-full md:w-1/3">Sidebar</div>
123
+ <div className="w-full md:w-2/3">Main Content</div>
124
+ </div>
125
+ ```
126
+
127
+ **Breakpoint prefixes:**
128
+
129
+ - `sm:` - 640px and above
130
+ - `md:` - 768px and above
131
+ - `lg:` - 1024px and above
132
+ - `xl:` - 1280px and above
133
+ - `2xl:` - 1536px and above
134
+
135
+ ### 4. Implement State and Interaction Variants
136
+
137
+ Use Tailwind's state variants for interactive elements:
138
+
139
+ ```tsx
140
+ <button className="bg-primary text-primary-content hover:bg-primary-focus focus:ring-primary focus:ring-2 focus:ring-offset-2 active:scale-95 disabled:pointer-events-none disabled:opacity-50">
141
+ Interactive Button
142
+ </button>
143
+ ```
144
+
145
+ **Common state variants:**
146
+
147
+ - `hover:` - Mouse hover state
148
+ - `focus:` - Focus state
149
+ - `active:` - Active/pressed state
150
+ - `disabled:` - Disabled state
151
+ - `group-hover:` - Parent hover targeting child elements
152
+ - `dark:` - Dark mode variant
153
+
154
+ ### 5. Use Consistent Spacing
155
+
156
+ Maintain consistent spacing using Tailwind's scale:
157
+
158
+ ```tsx
159
+ <div className="space-y-4">
160
+ <div className="p-4">Section 1</div>
161
+ <div className="p-4">Section 2</div>
162
+ <div className="p-4">Section 3</div>
163
+ </div>
164
+ ```
165
+
166
+ ## Component Types in Akan.js
167
+
168
+ Akan.js follows specific component naming conventions with distinct styling approaches:
169
+
170
+ ### 1. Unit Components (\*.Unit.tsx)
171
+
172
+ List items or cards that display summarized data:
173
+
174
+ ```tsx
175
+ // Example: Project.Unit.tsx
176
+ export const Card = ({ className, project, href }: ModelProps<"project", cnst.LightProject>) => {
177
+ return (
178
+ <Link
179
+ href={href}
180
+ className={clsx(
181
+ "border-base-300 bg-base-100 flex flex-col gap-3 rounded-lg border-2 p-4",
182
+ "hover:border-primary transition-all hover:shadow-md",
183
+ "focus:ring-primary focus:ring-2 focus:outline-hidden",
184
+ className
185
+ )}
186
+ >
187
+ <h3 className="text-base-content text-lg font-semibold">{project.name}</h3>
188
+ {/* Additional content */}
189
+ </Link>
190
+ );
191
+ };
192
+ ```
193
+
194
+ ### 2. View Components (\*.View.tsx)
195
+
196
+ Detailed displays of full data models:
197
+
198
+ ```tsx
199
+ // Example: Project.View.tsx
200
+ export const Detail = ({ className, project }: ModelProps<"project", cnst.FullProject>) => {
201
+ return (
202
+ <div className={clsx("bg-base-100 rounded-lg p-6 shadow-lg", className)}>
203
+ <div className="border-primary mb-6 border-l-4 pl-4">
204
+ <h1 className="text-primary text-2xl font-bold">{project.name}</h1>
205
+ </div>
206
+
207
+ <div className="grid grid-cols-1 gap-6 md:grid-cols-2">{/* Project details */}</div>
208
+ </div>
209
+ );
210
+ };
211
+ ```
212
+
213
+ ### 3. Edit Components (\*.Edit.tsx)
214
+
215
+ Form components for creating or editing data:
216
+
217
+ ```tsx
218
+ // Example: Project.Edit.tsx
219
+ export const Form = ({ className }: { className?: string }) => {
220
+ const { project, setProject } = useProjectStore();
221
+
222
+ return (
223
+ <div className={clsx("card bg-base-100 p-6 shadow-lg", className)}>
224
+ <h2 className="card-title mb-4">Project Details</h2>
225
+
226
+ <div className="form-control w-full">
227
+ <label className="label">
228
+ <span className="label-text">Project Name</span>
229
+ </label>
230
+ <input
231
+ type="text"
232
+ className="input input-bordered w-full"
233
+ value={project.name}
234
+ onChange={(e) => setProject({ ...project, name: e.target.value })}
235
+ />
236
+ </div>
237
+
238
+ {/* Additional form fields */}
239
+ </div>
240
+ );
241
+ };
242
+ ```
243
+
244
+ ### 4. Util Components (\*.Util.tsx)
245
+
246
+ Special function components like buttons, toggles, and actions:
247
+
248
+ ```tsx
249
+ // Example: Project.Util.tsx
250
+ export const StatusBadge = ({ className, status }: { className?: string; status: ProjectStatus }) => {
251
+ return (
252
+ <span
253
+ className={clsx(
254
+ "badge font-medium",
255
+ status === "active" && "badge-success",
256
+ status === "pending" && "badge-warning",
257
+ status === "canceled" && "badge-error",
258
+ status === "completed" && "badge-info",
259
+ className
260
+ )}
261
+ >
262
+ {status}
263
+ </span>
264
+ );
265
+ };
266
+ ```
267
+
268
+ ### 5. Zone Components (\*.Zone.tsx)
269
+
270
+ Container components that combine multiple components:
271
+
272
+ ```tsx
273
+ // Example: Project.Zone.tsx
274
+ export const ProjectDashboard = ({ className }: { className?: string }) => {
275
+ return (
276
+ <div className={clsx("grid grid-cols-1 gap-6 lg:grid-cols-3", className)}>
277
+ <div className="lg:col-span-2">
278
+ <ProjectSummary />
279
+ </div>
280
+ <div>
281
+ <ProjectStats />
282
+ </div>
283
+ <div className="lg:col-span-3">
284
+ <ProjectTimeline />
285
+ </div>
286
+ </div>
287
+ );
288
+ };
289
+ ```
290
+
291
+ ## Common UI Patterns
292
+
293
+ ### 1. Card Pattern
294
+
295
+ ```tsx
296
+ <div className="card bg-base-100 shadow-md transition-shadow hover:shadow-lg">
297
+ <figure className="px-4 pt-4">
298
+ <img src={image.url} alt={title} className="h-48 w-full rounded-lg object-cover" />
299
+ </figure>
300
+ <div className="card-body">
301
+ <h2 className="card-title">{title}</h2>
302
+ <p className="text-base-content/70">{description}</p>
303
+ <div className="card-actions mt-4 justify-end">
304
+ <button className="btn btn-primary btn-sm">View Details</button>
305
+ </div>
306
+ </div>
307
+ </div>
308
+ ```
309
+
310
+ ### 2. Form Pattern
311
+
312
+ ```tsx
313
+ <div className="form-control w-full max-w-md">
314
+ <label className="label">
315
+ <span className="label-text">Email</span>
316
+ </label>
317
+ <input
318
+ type="email"
319
+ className="input input-bordered w-full"
320
+ value={email}
321
+ onChange={(e) => setEmail(e.target.value)}
322
+ />
323
+ <label className="label">
324
+ <span className="label-text-alt text-error">{error}</span>
325
+ </label>
326
+ </div>
327
+ ```
328
+
329
+ ### 3. List Pattern
330
+
331
+ ```tsx
332
+ <div className="bg-base-100 rounded-lg shadow">
333
+ <div className="border-base-200 border-b p-4 font-medium">Items List</div>
334
+ <ul>
335
+ {items.map((item) => (
336
+ <li key={item.id} className="border-base-200 border-b last:border-none">
337
+ <div className="hover:bg-base-200 p-4 transition-colors">
338
+ <div className="flex items-center justify-between">
339
+ <span>{item.name}</span>
340
+ <span className="badge badge-outline">{item.category}</span>
341
+ </div>
342
+ </div>
343
+ </li>
344
+ ))}
345
+ </ul>
346
+ </div>
347
+ ```
348
+
349
+ ### 4. Dashboard Pattern
350
+
351
+ ```tsx
352
+ <div className="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-4">
353
+ <div className="stats bg-base-100 shadow">
354
+ <div className="stat">
355
+ <div className="stat-title">Total Users</div>
356
+ <div className="stat-value">{totalUsers}</div>
357
+ <div className="stat-desc">↗︎ 14% from last month</div>
358
+ </div>
359
+ </div>
360
+
361
+ {/* Additional stat cards */}
362
+ </div>
363
+ ```
364
+
365
+ ## Best Practices
366
+
367
+ ### 1. Component Composition
368
+
369
+ - Create small, focused components
370
+ - Combine them to build complex UIs
371
+ - Use props for variations
372
+ - Accept and forward `className` for style overrides
373
+
374
+ ### 2. Consistent Layout
375
+
376
+ - Use Flexbox and Grid for layouts
377
+ - Maintain consistent spacing
378
+ - Implement proper padding and margins
379
+ - Design for all screen sizes
380
+
381
+ ### 3. Color Usage
382
+
383
+ - Use DaisyUI theme colors
384
+ - Maintain proper contrast ratios
385
+ - Use opacity modifiers for variants (`bg-primary/80`)
386
+ - Avoid hardcoded colors
387
+
388
+ ### 4. Performance Optimization
389
+
390
+ - Group related classes
391
+ - Use Tailwind's JIT mode
392
+ - Purge unused styles in production
393
+ - Prefer Tailwind classes over custom CSS
394
+
395
+ ### 5. Dark Mode Support
396
+
397
+ ```tsx
398
+ <div className="bg-base-100 text-base-content">{/* Content automatically adapts to dark mode via DaisyUI */}</div>
399
+ ```
400
+
401
+ ## Common Mistakes to Avoid
402
+
403
+ 1. **Inconsistent Spacing**: Mixing arbitrary values instead of using Tailwind's scale
404
+ 2. **Hardcoded Colors**: Using hex codes or RGB values instead of theme variables
405
+ 3. **Missing `className` Prop**: Not forwarding the prop for composition
406
+ 4. **Direct Style Imports**: Importing component styles directly instead of using utility classes
407
+ 5. **Overriding Base Styles**: Applying too many custom styles that break theme consistency
408
+
409
+ ## Troubleshooting
410
+
411
+ ### 1. Styles Not Applying
412
+
413
+ - Check for typos in class names
414
+ - Ensure proper precedence (later classes override earlier ones)
415
+ - Verify the correct Tailwind configuration
416
+
417
+ ### 2. DaisyUI Components Not Working
418
+
419
+ - Check DaisyUI installation
420
+ - Verify theme configuration
421
+ - Ensure component classes are applied correctly
422
+
423
+ ### 3. Responsive Design Issues
424
+
425
+ - Test at various breakpoints
426
+ - Use the correct breakpoint prefixes
427
+ - Implement mobile-first approach
428
+
429
+ ## Additional Resources
430
+
431
+ 1. [TailwindCSS Documentation](https://tailwindcss.com/docs)
432
+ 2. [DaisyUI Documentation](https://daisyui.com/)
433
+ 3. [Tailwind CSS Cheat Sheet](https://nerdcave.com/tailwind-cheat-sheet)
434
+
435
+ By following these guidelines, you'll create consistent, maintainable, and themeable components that align with the Akan.js design system. Always prioritize composition over customization and leverage the power of TailwindCSS and DaisyUI utilities.