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
We have included a CLI tool that allows you to generate components from CSS files which confirm to a specific naming convention. This is highly experimental and is subject to change.
240
+
241
+
Consider this CSS file:
242
+
243
+
```css
244
+
nav.topBar {
245
+
background-color: #aaa;
246
+
padding: 32px;
247
+
}
248
+
249
+
nav.topBar_fixed_true {
250
+
position: fixed;
251
+
bottom: 0;
252
+
left: 0;
253
+
right: 0;
254
+
}
255
+
```
256
+
257
+
You can generate a component from this file with the following command:
This will output a file called `styles.ts` that looks like this:
267
+
268
+
```ts
269
+
import { styled } from"@phntms/css-components";
270
+
271
+
importcssfrom"./test.css";
272
+
273
+
exportconst TopBar =styled("nav", {
274
+
css: css.topBar,
275
+
variants: {
276
+
fixed: {
277
+
true: css.topBar_fixed_true,
278
+
},
279
+
},
280
+
});
281
+
```
282
+
283
+
### Possible CSS definitions:
284
+
285
+
-`a.link` Allowing you to define a base style for the component. This means it will be an anchor tag with the css class `link`.
286
+
-`a.link_big_true` Lets you set the styling for a variant called `big` with the value `true`.
287
+
-`a.link_theme_light_default` Same as above but also sets the variant as the default value.
288
+
-`a.link_big_true_theme_light` Gives you the ability to define compound variants styles.
289
+
290
+
### CLI Options
291
+
292
+
-`--css` The path to the CSS file you want to generate a component from. This can also be a recursive glob pattern allowing you to scan your entire components directory.
293
+
-`--output` The filename for the output file. Defaults to `styles.ts` which will be saved in the same directory as the CSS file.
294
+
295
+
Example to generate components from all CSS files in the components directory:
0 commit comments