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

Themes: Scope component styles to component #13770

Open
simeonoff opened this issue Jan 2, 2024 · 5 comments
Open

Themes: Scope component styles to component #13770

simeonoff opened this issue Jan 2, 2024 · 5 comments

Comments

@simeonoff
Copy link
Collaborator

Is your feature request related to a problem? Please describe.

Currently all component themes are located in the global stylesheet. This works fine, however if a user doesn't take advantage of all components, they get all styles for them regardless. The only way to alter this behavior is by creating a modified theme that specifically excludes all unwanted component styles/themes. We should research a way to move component-related styles to the components themselves.

Describe the solution you'd like

For instance, instead of having a mixin for the avatar theme (and all other components), included in the global theme, we can simply have all component related styles be bound to the component itself. This would mean that component mixins should be removed or bound to specific CSS layers for backward compatibility.

@simeonoff simeonoff self-assigned this Jan 2, 2024
@simeonoff simeonoff changed the title Scope component styles to component. Themes: Scope component styles to component Jan 2, 2024
@simeonoff
Copy link
Collaborator Author

simeonoff commented Jan 2, 2024

After some initial research, we've discovered the following:

Potential deprecations:

  • All theme mixins (@include avatar(…), etc.).

Breaking Changes:

  • Global schemas can no longer be passed to the theme mixin, breaking the ability to provide custom schemas on a global level. Component themes can still consume custom-made(uses) schemas, but they will need to be passed to the each individual component theme.

Issues:

  • Global theme config for schema cannot be used by the scoped theme. The order of Sass compilation cannot be controlled and the globally configured schema is not being read by the scoped theme. (Racing issues)
  • Following the first issue, users cannot provide custom made global schemas.
  • Custom components themes and typography don’t work out of the box. The reason is that theme-related CSS variables (those declared in the component styles) have higher specificity as the styles are closer in the DOM structure to the component, always overriding the user-specific variables declared in a global stylesheet.
  • All CSS variables (included using css-vars) declared in the component styles must be included (layered) all at once for all theme variants.

Potential Problems:

  • Components implemented with this way of theming must have their view encapsulation set to 'None'. Another more laborious approach can be to use 'ShadowDOM' encapsulation, but this will make it difficult to style components from the stylesheets of other components.

Solutions:

  • CSS layers can be used to define custom CSS variables on per theme basis. All theme CSS variables, however, must live alongside one another so that by changing the global theme, the appropriate layer is used by the component theme.

Game Plan:

  • Deprecate theme mixins (avatar, badge, etc.)
  • Deprecate 'schema' from the global theme mixin. Make users provide theme and variant arguments instead (defaults are theme - material, variant 'light').

Here's a draft PR highlighting some of the changes needed.

Copy link

github-actions bot commented Mar 3, 2024

There has been no recent activity and this issue has been marked inactive.

@github-actions github-actions bot added the status: inactive Used to stale issues and pull requests label Mar 3, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 10, 2024
@simeonoff simeonoff removed the status: inactive Used to stale issues and pull requests label Mar 11, 2024
@simeonoff simeonoff reopened this Mar 21, 2024
Copy link

There has been no recent activity and this issue has been marked inactive.

@github-actions github-actions bot added the status: inactive Used to stale issues and pull requests label May 21, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 28, 2024
@simeonoff simeonoff reopened this May 28, 2024
@github-actions github-actions bot removed the status: inactive Used to stale issues and pull requests label May 29, 2024
Copy link

There has been no recent activity and this issue has been marked inactive.

@github-actions github-actions bot added the status: inactive Used to stale issues and pull requests label Jul 28, 2024
@simeonoff simeonoff removed the status: inactive Used to stale issues and pull requests label Jul 29, 2024
Copy link

There has been no recent activity and this issue has been marked inactive.

@github-actions github-actions bot added the status: inactive Used to stale issues and pull requests label Nov 27, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 5, 2024
@simeonoff simeonoff reopened this Dec 6, 2024
@github-actions github-actions bot removed the status: inactive Used to stale issues and pull requests label Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants