Skip to content

Commit af42857

Browse files
thewebartisan7John Richard Chipps-Harding
andauthored
Add support for scss files in cli (#29)
* Add support for scss files in cli * Updated readme for SCSS files * Fix format for readme --------- Co-authored-by: John Richard Chipps-Harding <[email protected]>
1 parent 1d40022 commit af42857

File tree

6 files changed

+264
-31
lines changed

6 files changed

+264
-31
lines changed

README.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,12 @@ type PrimaryType = ButtonVariants["primary"];
258258

259259
## CLI Tool (Experimental)
260260

261-
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.
261+
We have included a CLI tool that allows you to generate components from CSS and SCSS files which confirm to a specific naming convention. This is highly experimental and is subject to change.
262262

263263
Consider this CSS file:
264264

265265
```css
266+
/* styles.module.css */
266267
nav.topBar {
267268
background-color: #aaa;
268269
padding: 32px;
@@ -276,13 +277,35 @@ nav.topBar_fixed_true {
276277
}
277278
```
278279

279-
You can generate a component from this file with the following command:
280+
Or using SCSS (Sassy CSS):
281+
282+
```scss
283+
// styles.module.scss
284+
nav.topBar {
285+
background-color: #aaa;
286+
padding: 32px;
287+
288+
&_fixed_true {
289+
position: fixed;
290+
bottom: 0;
291+
left: 0;
292+
right: 0;
293+
}
294+
}
295+
```
296+
297+
You can generate a component from this files with the following command:
280298

281299
```bash
300+
# For CSS
282301
npx @phntms/css-components --css styles.module.css
283302

303+
# For SCSS
304+
npx @phntms/css-components --css styles.module.scss
305+
284306
# or if you have the package installed
285307
npx css-components --css styles.module.css
308+
npx css-components --css styles.module.scss
286309
```
287310

288311
This will output a file called `styles.ts` that looks like this:
@@ -311,14 +334,21 @@ export const TopBar = styled("nav", {
311334

312335
### CLI Options
313336

314-
- `--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.
337+
- `--css` The path to the CSS or SCSS file you want to generate a component from. This can also be a recursive glob pattern allowing you to scan your entire components directory.
315338
- `--output` The filename for the output file. Defaults to `styles.ts` which will be saved in the same directory as the CSS file.
316339
- `--overwrite` If the output file already exists, this will overwrite it. Defaults to `false`.
317340

318-
Example to generate components from all CSS files in the components directory:
341+
Example to generate components from all CSS and SCSS files in the components directory:
319342

320343
```bash
344+
# From CSS
321345
npx @phntms/css-components --css ./src/components/**/*.css --output styles.ts
346+
347+
# Or from SCSS
348+
npx @phntms/css-components --css ./src/components/**/*.scss --output styles.ts
349+
350+
# Or from both CSS and SCSS
351+
npx @phntms/css-components --css ./src/components/**/*.{css,scss} --output styles.ts
322352
```
323353

324354
[npm-image]: https://img.shields.io/npm/v/@phntms/css-components.svg?style=flat-square&logo=react

0 commit comments

Comments
 (0)