-
Notifications
You must be signed in to change notification settings - Fork 38
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: remove global carbon components from search component sass files #146
refactor: remove global carbon components from search component sass files #146
Conversation
Dave Beshero seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
|
||
// Search Input | ||
@import '~carbon-components/scss/components/search/search'; | ||
@import '~carbon-components/scss/components/list-box/list-box'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole file is completely optional for consumer apps. They can choose to import this file along with the base discovery components scss file if they don't plan on mixing in any additional carbon components. I imagine this would be more likely used by users who are quickly building a sample search app. Perhaps as their project grows, they would abandon importing this file in favor of importing from carbon directly. Bottom line is that this allows us to provide a decent developer experience for those who want a quick path to get something going while also saying "hey, you don't need to use this file if you have a more complex setup to manage."
@@ -0,0 +1,14 @@ | |||
// You only need to import this file if your app is not already directly importing these carbon files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we like this approach, I'd write up a better statement here that links to docs including this: https://github.com/carbon-design-system/carbon/blob/master/docs/guides/sass.md#optimizing-your-sass-builds
@@ -1,7 +1,3 @@ | |||
// Component styles | |||
@import '~carbon-components/scss/components/search/search'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does @use
work here? https://css-tricks.com/introducing-sass-modules/#:~:text=The%20new%20%40use%20is%20similar,considered%20private%2C%20and%20not%20imported.
or can we at least leave a comment indicating which carbon styles this file depends on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like it would work, but we would have to use dart-sass
instead of node-sass
which then requires anyone consuming this package to also use dart-sass
.
At this point in time, it doesn't appear that @use
is on the node-sass
roadmap: sass/node-sass#2886 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maniax89 would you prefer comments per file or references within this file:
// Search Input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either or - i don't have a preference. just as long as it is consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like many components import the same base styles. For example
and
Thinking that I'll go the route of putting all of the comments in the global file and include a section of shared base carbon styles across components.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8cae616
to
5ebe015
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you update the example app as well? https://github.com/watson-developer-cloud/discovery-components/blob/master/examples/discovery-search-app/src/index.scss#L7
Going to be doing that today before I move this out of draft. Also will be updating docs. |
5ebe015
to
130fee8
Compare
130fee8
to
3711b47
Compare
35a3bb4
to
de50ffc
Compare
de50ffc
to
4d419ee
Compare
|
||
The Discovery Components styles package can be consumed in three ways | ||
|
||
1. Wholesale SCSS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not married to the definitions here. Just wanted something to quickly describe what the method is. Maybe single import SCSS and partial SCSS imports instead?
What do these changes do/fix?
This change removes carbon
import
s that are within each search component'sscss
files to remove the chance of duplicate imports that lead to longer build times.The problem
styles.scss
styles.scss
@ibm-watson/discovery-styles/scss/index.scss
Additionally, each discovery component scss file imports the base carbon styles required for the component.
@ibm-watson/discovery-styles/scss/components/search-input/_search-input.scss
Because the consumer app is already importing the base carbon styles required for its usage of carbon, anything that is also imported via discovery-components will be imported again, leading to longer build times.
The proposed solution
Follow suite with carbon-react and stay "hands off" on base carbon style imports, but still provide the discovery component styles for consumption by the consumer app.
In this change, I'm removing all global carbon style imports from the discovery components and placing them into a
global-carbon-styles
file. This allows us to do the following:Basically, instead of the consumer app doing:
it can instead do
How do you test/verify these changes?
Yes. Here is the sample app still running with the correct styles:
Have you documented your changes (if necessary)?
Yes
Are there any breaking changes included in this pull request?
I don't believe so. Because we still export the
index.scss
file which includes everything the same as before, this should be purely an additive change.