@donotdev/cli 0.0.4 → 0.0.5

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.
@@ -25,7 +25,7 @@ These are the only ways one should handle layout to get to quick results functio
25
25
  - **DualCard** - Side-by-side card layout for comparison or feature showcases.
26
26
  - **Text** - Typography component with semantic text variants.
27
27
  - **Blockquote** - Styled blockquote for citations and testimonials.
28
- - **List** - Bullet points, numbered lists, and feature lists with zero CSS.
28
+ - **List** - Bullet points, numbered lists, and feature lists with zero CSS. Use `icon` prop for custom icons, `icon={null}` for plain bullets.
29
29
  - **DescriptionList** - Key-value pairs and metadata using semantic HTML (dl, dt, dd).
30
30
  - **Separator** - Visual separator with semantic styling variants.
31
31
 
@@ -39,6 +39,12 @@
39
39
 
40
40
  ---
41
41
 
42
+ ## Helpers
43
+
44
+ - **tList(t, key, count, icon?, size?)** - Translated array as List. Default: CheckCircle icon. Pass `null` for no icon (use with emoji labels).
45
+
46
+ ---
47
+
42
48
  ## Common Components
43
49
 
44
50
  - **AppLoading** - App-level loading component.
@@ -4,15 +4,81 @@
4
4
 
5
5
  ---
6
6
 
7
+ ## Translation File Locations (CRITICAL)
8
+
9
+ **Two paths - choose based on when translations are needed:**
10
+
11
+ 1. **Eager (`src/locales/`)**: Always loaded - use for common UI, navigation, app-wide content
12
+ 2. **Lazy (`src/pages/locales/`)**: Loaded when page loads - use for page-specific content
13
+
14
+ **✅ RULE OF THUMB:**
15
+ - **Eager**: Navigation, buttons, common messages (used everywhere)
16
+ - **Lazy**: Page content, feature content, large text blocks (used on specific pages)
17
+
18
+ **Framework auto-discovers both paths. No configuration needed.**
19
+
20
+ ---
21
+
7
22
  ## Standard Use
8
23
 
9
- **Files:** `src/locales/<namespace>_<2-char-ISO>.json` (eager) | `src/pages/locales/<namespace>_<2-char-ISO>.json` (lazy)
24
+ **CRITICAL: Two Translation Paths - Choose Based on When Translations Are Needed**
25
+
26
+ ### Eager Translations (Always Loaded)
27
+ **Path:** `src/locales/<namespace>_<2-char-ISO>.json`
28
+
29
+ **Use for:**
30
+ - Common UI elements (buttons, labels, navigation)
31
+ - Critical app-wide translations (app name, common messages)
32
+ - Translations needed on every page
33
+
34
+ **Example:**
35
+ ```
36
+ src/
37
+ locales/
38
+ common_en.json # ✅ Eager - always available
39
+ common_fr.json
40
+ navigation_en.json # ✅ Eager - used in header/sidebar
41
+ navigation_fr.json
42
+ ```
10
43
 
44
+ ### Lazy Translations (Loaded When Page Loads)
45
+ **Path:** `src/pages/locales/<namespace>_<2-char-ISO>.json`
46
+
47
+ **Use for:**
48
+ - Page-specific content (page titles, descriptions, page content)
49
+ - Feature-specific translations (dashboard, blog, admin)
50
+ - Translations only needed when that page/feature is accessed
51
+
52
+ **Example:**
53
+ ```
54
+ src/
55
+ pages/
56
+ HomePage.tsx
57
+ locales/
58
+ home_en.json # ✅ Lazy - loaded when HomePage loads
59
+ home_fr.json
60
+ dashboard/
61
+ DashboardPage.tsx
62
+ locales/
63
+ dashboard_en.json # ✅ Lazy - loaded when DashboardPage loads
64
+ dashboard_fr.json
65
+ ```
66
+
67
+ **✅ DECISION GUIDE:**
68
+ - **Eager (`src/locales/`)**: Navigation, common buttons, app-wide messages
69
+ - **Lazy (`src/pages/locales/`)**: Page content, feature-specific content, large text blocks
70
+
71
+ **Usage:**
11
72
  ```tsx
12
73
  import { useTranslation } from '@donotdev/core';
13
74
 
14
- const { t } = useTranslation(NAMESPACE);
15
- t('title');
75
+ // Eager namespace (common, navigation, etc.)
76
+ const { t } = useTranslation('common');
77
+ t('app.title');
78
+
79
+ // Lazy namespace (page-specific)
80
+ const { t } = useTranslation('home');
81
+ t('hero.title');
16
82
  ```
17
83
 
18
84
  **LanguageSelector:** Included in layout presets. Import from `@donotdev/core` if needed elsewhere.
@@ -21,14 +87,87 @@ t('title');
21
87
 
22
88
  ## Advanced: Array Translations
23
89
 
90
+ ### Low-level: translateArray
91
+
24
92
  ```tsx
25
93
  import { translateArray, translateObjectArray, maybeTranslate } from '@donotdev/core';
26
94
 
27
- translateArray(t, 'benefits', 10); // Up to 10 items (benefits.0-9), safe if only 4 exist
28
- translateObjectArray(t, 'cases', 10, ['useCase', 'bestFit']); // Up to 10 objects
29
- maybeTranslate(t, 'products.earlyBird.name'); // Auto-detects key vs string
95
+ // Get array of strings (filters missing translations automatically)
96
+ const benefits = translateArray(t, 'benefits', 10); // Up to 10 items (benefits.0-9), safe if only 4 exist
97
+ const features = translateArray(t, 'features.list', 5); // Nested keys work
98
+
99
+ // Get array of objects
100
+ const cases = translateObjectArray(t, 'cases', 10, ['useCase', 'bestFit']);
101
+
102
+ // Auto-detect if value is a translation key or literal string
103
+ maybeTranslate(t, 'products.earlyBird.name');
30
104
  ```
31
105
 
106
+ ### High-level: tList (Recommended for Cards)
107
+
108
+ `tList` wraps `translateArray` and returns a `List` component ready for `Card` content:
109
+
110
+ ```tsx
111
+ import { tList } from '@donotdev/ui';
112
+
113
+ // With default icon (CheckCircle)
114
+ <Card content={tList(t, 'features.items', 4)} />
115
+
116
+ // With custom icon
117
+ <Card content={tList(t, 'features.items', 4, Star)} />
118
+
119
+ // Without icon (for emoji-prefixed labels like "🚀 Kick-off")
120
+ <Card content={tList(t, 'features.items', 4, null)} />
121
+ ```
122
+
123
+ **JSON structure:**
124
+ ```json
125
+ {
126
+ "features": {
127
+ "items": [
128
+ "Feature 1",
129
+ "Feature 2",
130
+ "Feature 3"
131
+ ]
132
+ }
133
+ }
134
+ ```
135
+
136
+ ---
137
+
138
+ ## Advanced: Rich Text (Trans)
139
+
140
+ For inline styling in translations, use `Trans` instead of `t()`. Use when translations contain HTML-like tags for styling.
141
+
142
+ ```tsx
143
+ import { Trans } from '@donotdev/core';
144
+
145
+ // Translation: "<accent>MVP</accent> in 2 weeks"
146
+ <HeroSection title={<Trans ns={NAMESPACE} i18nKey="hero.title" />} />
147
+
148
+ // Translation: "I need <accent>Clarity</accent>"
149
+ <Card title={<Trans ns={NAMESPACE} i18nKey="products.transformation.title" />} />
150
+ ```
151
+
152
+ **JSON with tags:**
153
+ ```json
154
+ {
155
+ "hero": {
156
+ "title": "Idea to <accent>MVP</accent> in 2 weeks"
157
+ },
158
+ "products": {
159
+ "transformation": {
160
+ "title": "I need <accent>Clarity</accent>",
161
+ "subtitle": "...for a <accent>critical</accent> application"
162
+ }
163
+ }
164
+ }
165
+ ```
166
+
167
+ **Supported tags:** `<accent>` `<primary>` `<muted>` `<success>` `<warning>` `<error>` `<bold>` `<code>`
168
+
169
+ **Note:** `Trans` accepts `ns` prop (string) for namespace. Use `t()` for plain strings, `Trans` for rich text with styling tags.
170
+
32
171
  ---
33
172
 
34
173
  ## Advanced: I18N Components
@@ -18,6 +18,24 @@ export const appConfig: AppConfig = {
18
18
 
19
19
  ---
20
20
 
21
+ ## Preset Capabilities
22
+
23
+ **The `docs` preset AUTOMATICALLY generates sidebar navigation from your `src/pages` files. You do not need to configure a sidebar manually.**
24
+
25
+ All presets automatically include these components when applicable:
26
+
27
+ * **LanguageSelector** - Automatically shown if more than 1 language is configured
28
+ * **ThemeToggle** - Automatically shown if more than 1 theme is available
29
+ * **AuthMenu** - Automatically shown if auth is configured in `.env` (Firebase keys present)
30
+ * **Navigation Menu** - Automatically generated from `src/pages/*Page.tsx` files for sidebars
31
+ * **GoTo Component** - Command palette (Cmd+K) for quick navigation - always available
32
+ * **Footer** - Automatic footer with copyright and legal links
33
+ * **LegalLinks + Copyright** - Automatically included in footer from `config/legal.ts`
34
+
35
+ **You don't need to add these manually - the framework handles them based on your configuration.**
36
+
37
+ ---
38
+
21
39
  ## Advanced: Slot Overrides
22
40
 
23
41
  **Customize zones:**
@@ -4,6 +4,14 @@
4
4
 
5
5
  ---
6
6
 
7
+ ## File Routing Rule
8
+
9
+ **CRITICAL: Only files ending in `Page.tsx` inside `src/pages` become routes.**
10
+
11
+ Files must be named `*Page.tsx` (e.g., `HomePage.tsx`, `AboutPage.tsx`, `BlogPostPage.tsx`). Files without the `Page.tsx` suffix are ignored by the routing system.
12
+
13
+ ---
14
+
7
15
  ## Standard Use
8
16
 
9
17
  **Pattern:** `src/pages/**/*Page.tsx` → routes