Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: [BD-46] Component generator refactoring #3076

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
component-generator/**
example/**
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,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 @@ -314,10 +313,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).
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), create specific design tokens in `tokens` directory (in the `core` and `themes` directories) and then generate (`npm run build-tokens`) CSS variables for your component.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be nice to keep the design token documentation in the tokens directory and link to it instead.

Suggested change
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), create specific design tokens in `tokens` directory (in the `core` and `themes` directories) and then generate (`npm run build-tokens`) CSS variables for your component.
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).

this way we can keep the documentation in one place and we don't need to remember all the places it needs to be updated if it is changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I edited it, thanks! Your proposal looks more concise 💯

This way the variables will also get automatically picked up by documentation site and displayed on your component's page.

**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
9 changes: 4 additions & 5 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,10 +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).
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), create specific design tokens in `tokens` directory (in the `core` and `themes` directories) and then generate (`npm run build-tokens`) CSS variables for your component.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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), create specific design tokens in `tokens` directory (in the `core` and `themes` directories) and then generate (`npm run build-tokens`) CSS variables for your component.
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).

same suggestion as before

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, thanks

This way the variables will also get automatically picked up by documentation site and displayed on your component's page.

**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
Loading