You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -118,7 +120,7 @@ Otherwise, if you don't pass any options, it will just use the default values th
118
120
<tr>
119
121
<td width="20%"><b>--withLazy</b></td>
120
122
<td width="60%">
121
-
Creates a corresponding lazy file (a file that lazy-loads your component out of the box and enables <a href="https://reactjs.org/docs/code-splitting.html#code-splitting">code splitting</a>) with this component.
123
+
Creates a corresponding lazy file (a file that lazy-loads your component out of the box and enables <a href="https://reactjs.org/docs/code-splitting.html#code-splitting">code splitting</a>) with this component.
@@ -158,15 +161,27 @@ Otherwise, if you don't pass any options, it will just use the default values th
158
161
<td width="20%">Boolean</td>
159
162
<td width="20%"><code>false<code></td>
160
163
</tr>
164
+
161
165
<tr>
162
166
<td width="20%"><b>--flat</b></td>
163
167
<td width="60%">
164
-
Generate the files in the mentioned path insted of creating new folder for it
168
+
Generate the files in the mentioned path instead of creating new folder for it
165
169
</td>
166
170
<td width="20%">Boolean</td>
167
171
<td width="20%"><code>false<code></td>
168
172
</tr>
169
-
<tr>
173
+
174
+
<tr>
175
+
<td width="20%"><b>--customDirectory</b></td>
176
+
<td width="60%">
177
+
Template value that overrides the name of the directory of the component to be generated in.<br />
178
+
See more under <a href="#custom-component-directory">custom component directory</a>.
179
+
</td>
180
+
<td width="20%">String</td>
181
+
<td width="20%"><code>null</code></td>
182
+
</tr>
183
+
184
+
<tr>
170
185
<td width="20%"><b>--describe</b></td>
171
186
<td width="60%">
172
187
Describe the component you're trying to generate, and OpenAI will do its best to render it following your instructions.
@@ -176,7 +191,7 @@ Otherwise, if you don't pass any options, it will just use the default values th
176
191
</tr>
177
192
</table>
178
193
179
-
### Custom component types:
194
+
### Custom component types
180
195
181
196
By default, GRC will use the `component.default` configuration rules when running the component command out of the box.
182
197
@@ -329,6 +344,93 @@ it('It should mount', () => {
329
344
});
330
345
```
331
346
347
+
### Custom component directory
348
+
349
+
Using the `customDirectory` you can easily override the directory name for the component generated. For instance, if prefixes are required for particular components or if template names will be mixed, the `customDirectory` option will allow you to override the way that GRC generates the name of the directory where the component files will live.
350
+
351
+
The `customDirectory` directive allows all supported casings (see previous section) and can be overridden at the following levels in ascending specific of priority:
352
+
353
+
- top
354
+
- component.default
355
+
- component._type_
356
+
- CLI
357
+
358
+
#### Example:
359
+
360
+
For React Context Providers in a project, the decision has been made to separate Context generation from the visual components.
361
+
362
+
In a typical configuration the configuration would look as following:
With the configuration above, the component would be required to either follow a full or a minimalistic naming convention.
386
+
I.e. the component would either need to be generated as `ThemeProvider` and consequently the context name would be generated as `ThemeProviderContext`, or by renaming the files and templates as `TemplateNameProvider` but with the downside of the component path being generated as `src/components/providers/Theme`. This creates inconsistent naming in the directory containg the component files.
387
+
388
+
To work around this, the `customDirectory` option can be used to enforce a particular style.
Similarly, this construct could be used as a shortcut for generating other named components, like the `BoxLayout` example above, depending on that could be shortened to:
Or it could be used to generate files with a naming convention with `Test`, `Lazy`, `Context`, `Theme`, or `Provider` suffixes. Or even combined with skeleton CSS
433
+
332
434
### Custom component files
333
435
334
436
GRC comes with corresponding built-in files for a given component if you need them (i.e., `withStyle`, `withTest`, `withStory`, and `withLazy`).
0 commit comments