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

automatically load css at runtime as fallback #1734

Merged
merged 21 commits into from
Dec 19, 2023
Merged

automatically load css at runtime as fallback #1734

merged 21 commits into from
Dec 19, 2023

Conversation

mayank99
Copy link
Contributor

@mayank99 mayank99 commented Dec 12, 2023

Changes

  1. In styles.css, we will set a variable --_iui-v3-loaded. At runtime, we check for this variable and do nothing else if found.
  2. If variable not found, that means styles are not loaded. We will first attempt to use a side-effect import to dynamically import styles.css. Many bundlers know how to resolve this, so we should be good.
  3. If this doesn't work, we'll fall back to loading styles.css from a CDN.

All of this only happens when using theme="inherit". The includeCss prop can be used to control this behavior for other themes as well.

Testing

Tested thoroughly across different bundlers/frameworks.

Docs

Added jsdocs and changeset.

@mayank99 mayank99 self-assigned this Dec 12, 2023
@mayank99 mayank99 marked this pull request as ready for review December 18, 2023 17:27
@mayank99 mayank99 requested review from a team as code owners December 18, 2023 17:27
@mayank99 mayank99 requested review from siddhantrawal and r100-stack and removed request for a team December 18, 2023 17:27
Copy link
Contributor Author

@mayank99 mayank99 left a comment

Choose a reason for hiding this comment

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

i've retested this PR and #1744 via 3.2.0-dev.0, works fine everywhere except remix. going to merge and release this now 🚀

@mayank99 mayank99 merged commit 269668c into main Dec 19, 2023
16 checks passed
@mayank99 mayank99 deleted the mayank/auto-css branch December 19, 2023 16:17
@imodeljs-admin imodeljs-admin mentioned this pull request Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants