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 all commits
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/**
10 changes: 4 additions & 6 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,11 +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).
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).
PKulkoRaccoonGang marked this conversation as resolved.
Show resolved Hide resolved

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