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

Typography mixin doesn't fully generate CSS when included in :host selectors. #64

Closed
simeonoff opened this issue Feb 8, 2023 · 0 comments · Fixed by #65
Closed

Typography mixin doesn't fully generate CSS when included in :host selectors. #64

simeonoff opened this issue Feb 8, 2023 · 0 comments · Fixed by #65
Assignees
Labels
typography ✅ status: resolved Applies to issues that have pending PRs resolving them, or PRs that have already merged.

Comments

@simeonoff
Copy link
Contributor

Consider the following scenario. When the typography mixin is included in the :host selector of a component.

:host {
   @include typography(...);
}

This code will only produce CSS variables related to the type styles of the type scale. This is an intentional design decision, as we don't want to include element or class selectors referring to the same CSS variables every time we create scoped typography as in the case above. The typography mixin should only include classes and element selector when declared in the root of the stylesheet.

So essentially, one would have to do this in a stylesheet of a component:

// Includes all CSS variables, element and class selectors
@include typography(...);

:host {
   // Include only CSS variables, overriding the ones included by the previous typography declaration
   @include typography(...);
}

This approach works well in most cases, however, I can see that some people would want to treat the :host scope as the limiting scope. For that reason, let's treat the :host scope the same as :root and include all classes and element selectors when the typography is included in there, meaning that the following is equivalent to the previous example:

:host {
    // Includes all CSS variables, elements, and class selectors
    @include typography(...);

   .custom-typography {
       // Include only CSS variables, overriding the ones included by the previous typography declaration
       @include typography(...);
   }
}
@simeonoff simeonoff self-assigned this Feb 8, 2023
@simeonoff simeonoff added the ✅ status: resolved Applies to issues that have pending PRs resolving them, or PRs that have already merged. label Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typography ✅ status: resolved Applies to issues that have pending PRs resolving them, or PRs that have already merged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant