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

Support to "Shadow DOM" #384

Merged
merged 1 commit into from
Jul 12, 2023
Merged

Conversation

mauromascarenhas
Copy link

Proposed changes

Made "CSS" variables compatible with custom elements (shadow dom).

This PR aims to close #329.

Screenshots (if appropriate) or codepen:

It is possible to check the current behaviour in this pen provided at #329.

With this "fix", the inputs should render correcly:

Form input element being correctly rendered

Types of changes

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to change).

Checklist:

  • I have read the CONTRIBUTING document.
  • My commit messages follows the conventional commit format
  • My change requires a change to the documentation, and updated it accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Made "CSS" variables compatible with custom elements (shadow dom).
@wuda-io
Copy link
Member

wuda-io commented Jun 22, 2023

Ok this is nice, but I think it is more like a workaround. What is the best practice here?

https://stackoverflow.com/questions/48380267/css-variables-root-vs-host
Probably we should avoid the use of the root-selector completely.

@mauromascarenhas
Copy link
Author

Ok this is nice, but I think it is more like a workaround. What is the best practice here?

https://stackoverflow.com/questions/48380267/css-variables-root-vs-host Probably we should avoid the use of the root-selector completely.

I could not find anywhere else that using :root selector is a bad practice (at least, not a terrible one)...

This probably happens due to the context of application, like the one in the question (eg.: implementing stylesheets for Angular components).

I've found an article which presents other forms of declarations for CSS variables, but it still makes use of ":root" for some purposes. Not to mention the example of Bootstrap, which also makes use of it (see the screenshot below).

Screenshot of Bootstrap home page

The problem actually lies in the fact that the code may become realy messy in the long term when everthing is defined under "root". But that should not be a problem for us, since we use a dedicated file for that (_variables.scss) 😄.

@wuda-io wuda-io merged commit 2ca72c3 into materializecss:v2-dev Jul 12, 2023
@wuda-io wuda-io mentioned this pull request Jul 12, 2023
@mauromascarenhas mauromascarenhas deleted the shadow-dom branch July 12, 2023 14:07
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