-
Notifications
You must be signed in to change notification settings - Fork 39
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
remove css imports from components #1322
Conversation
e03d97b
to
8ad4039
Compare
So now we will always import all the css even if we use few components from iTwinUI ? :( |
Yes. This is actually a requirement for CSS modules. We cannot scope every component separately, as the same class when used in two different css files would get different hashes. If you're concerned about bundle size, it's only 30KB gzipped and easily cacheable. |
737371c
to
52144fe
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.
I think this is good now. I have checked the visuals and they look good/not broken anymore. Also checked code changes and Overview page 👍
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.
Lets do dev release with this and css modules and try to migrate real app (eg. AppUI with its test apps)
Do you mean from a branch? Because we have changesets set up, so merging the PR will also allow doing a dev release. |
No, with changesets. Just saying it's a good idea to test this in real app. |
Background
Up until now, we were importing
.css
files inside our React components. Such imports are not valid javascript syntax, and we have been relying on bundlers to magically take care of it. In hindsight, this was a mistake, just like automatically setting theme on the document was a mistake (eventually fixed in iTwin/iTwinUI-react#825 and #1265).Some of the many issues with using such non-standard imports:
FileUpload
missing styles #1309).next-global-css
in older nextjs versions,transpilePackages
in nextjs 13)Changes
Removed all css imports from every component and created a
styles.css
file that can be manually imported. (This change was initially part of #1302 but pulled out for ease of review.)Testing
All tests/playgrounds been updated to explicitly import the css.
Docs
Updated readme/md pages and added changeset.