Skip to content

Commit

Permalink
refactor: [BD-46] Component generator refactoring (#3076)
Browse files Browse the repository at this point in the history
  • Loading branch information
PKulkoRaccoonGang authored May 22, 2024
1 parent 7930c05 commit 05e9096
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
component-generator/**
example/**
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,7 @@ This will create a directory in `/src/` that will contain templates for all nece
MyComponent
├── index.jsx
├── README.md
├── MyComponent.scss
├── _variables.scss
├── index.scss
└── MyComponent.test.jsx
```
Expand Down Expand Up @@ -325,11 +324,10 @@ export default MyComponent;
##### 4. (Optional) Add styles to your component.

If your component requires additional styling (which most likely is the case), edit created SCSS style sheet in your
component's directory `/src/MyComponent/MyComponent.scss` which by default contains an empty class for your component.
component's directory `/src/MyComponent/index.scss` which by default contains an empty class for your component.

If you wish to use SASS variables (which is the preferred way of styling the components since values can be
easily overridden and customized by the consumers of Paragon), add them in `/src/MyComponent/_variables.scss` (this file should contain all variables specific to your component).
This way the variables will also get automatically picked up by documentation site and displayed on your component's page.
If you wish to use CSS variables (which is the preferred way of styling the components since values can be
easily overridden and customized by the consumers of Paragon), you can do so by utilizing [design tokens](/tokens).

**Please note that you need to follow [Paragon's CSS styling conventions](docs/decisions/0012-css-styling-conventions).**

Expand Down
4 changes: 0 additions & 4 deletions component-generator/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ exports.COMPONENT_FILES = [
targetPath: path.resolve(__dirname, '../src/componentName/index.jsx'),
templatePath: path.resolve(__dirname, './templates/index.jsx'),
},
{
targetPath: path.resolve(__dirname, '../src/componentName/_variables.scss'),
templatePath: path.resolve(__dirname, './templates/_variables.scss'),
},
{
targetPath: path.resolve(__dirname, '../src/componentName/README.md'),
templatePath: path.resolve(__dirname, './templates/README.md'),
Expand Down
2 changes: 0 additions & 2 deletions component-generator/templates/_variables.scss

This file was deleted.

5 changes: 2 additions & 3 deletions component-generator/templates/index.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Put styles related to your component here

@import "variables";
// Put design tokens in `tokens` directory if you need to create variables related to your component,
// you can safely delete this file if you do not intend to use any styles

.pgn__css-class {

Expand Down
3 changes: 1 addition & 2 deletions tokens/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Design Tokens

This module is responsible for handling design tokens in Paragon, for rationale behind design tokens see [Scaling Paragon's styles architecture with design tokens](https://openedx.atlassian.net/wiki/spaces/BPL/pages/3630923811/Scaling+Paragon+s+styles+architecture+with+design+tokens)
and relevant ADR(TODO: add link when we merge an ADR).
This module is responsible for handling design tokens in Paragon, for rationale behind design tokens see [Scaling Paragon's styles architecture with design tokens](https://openedx.atlassian.net/wiki/spaces/BPL/pages/3630923811/Scaling+Paragon+s+styles+architecture+with+design+tokens).

## Overview

Expand Down
10 changes: 4 additions & 6 deletions www/src/pages/tools/component-generator.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ This will create a directory in `/src/` that will contain templates for all nece
MyComponent
├── index.jsx
├── README.md
├── MyComponent.scss
├── _variables.scss
├── index.scss
└── MyComponent.test.jsx
```

Expand Down Expand Up @@ -70,11 +69,10 @@ export default MyComponent;
## 4. (Optional) Add styles to your component.

If your component requires additional styling (which most likely is the case), edit created SCSS style sheet in your
component's directory `/src/MyComponent/MyComponent.scss` which by default contains an empty class for your component.
component's directory `/src/MyComponent/index.scss` which by default contains an empty class for your component.

If you wish to use SASS variables (which is the preferred way of styling the components since values can be
easily overridden and customized by the consumers of Paragon), add them in `/src/MyComponent/_variables.scss` (this file should contain all variables specific to your component).
This way the variables will also get automatically picked up by documentation site and displayed on your component's page.
If you wish to use CSS variables (which is the preferred way of styling the components since values can be
easily overridden and customized by the consumers of Paragon), you can do so by utilizing [design tokens](/tokens).

**Please note that you need to follow [Paragon's CSS styling conventions](https://github.com/openedx/paragon/blob/master/docs/decisions/0012-css-styling-conventions).**

Expand Down

0 comments on commit 05e9096

Please sign in to comment.