Skip to content

Commit

Permalink
Support web components/shadow DOM.
Browse files Browse the repository at this point in the history
Add :host to all uses of :root
  • Loading branch information
rcoup committed Dec 3, 2024
1 parent 6dc6489 commit 02c9fb6
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion scss/colors/utilities/_css-vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
$css-var-color-prefix: #{settings.$css-var-prefix}#{$color-property-name};

@if $enable-css-vars {
:root {
:root,
:host {
// Loop through color families
@each $family, $colors in colors.$colors {
@if index(map.get(settings.$palette, "color-families"), $family) {
Expand Down
3 changes: 2 additions & 1 deletion scss/components/_modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* Modal (<dialog>)
*/

:root {
:root,
:host {
#{$css-var-prefix}scrollbar-width: 0px;
}

Expand Down
3 changes: 2 additions & 1 deletion scss/content/_embedded.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
}

// Hide the overflow in IE
#{$parent-selector} svg:not(:root) {
#{$parent-selector} svg:not(:root),
#{$parent-selector} svg:not(:host) {
overflow: hidden;
}
}
3 changes: 2 additions & 1 deletion scss/layout/_document.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
// 3. Use a 4-space tab width in all browsers (opinionated)
// 4. Remove the grey highlight on links in iOS (opinionated)
// 5. Prevent adjustments of font size after orientation changes in iOS
:where(:root) {
:where(:root),
:where(:host) {
-webkit-tap-highlight-color: transparent; // 4
-webkit-text-size-adjust: 100%; // 5
text-size-adjust: 100%; // 5
Expand Down
6 changes: 4 additions & 2 deletions scss/themes/default/_schemes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
// Light color scheme (Default)
// Can be forced with data-theme="light"
[data-theme="light"],
:root:not([data-theme="dark"]) {
:root:not([data-theme="dark"]),
:host(:not([data-theme="dark"])) {
@include light.theme;
}

// Dark color scheme (Auto)
// Automatically enabled if user has Dark mode enabled
@media only screen and (prefers-color-scheme: dark) {
:root:not([data-theme]) {
:root:not([data-theme]),
:host(:not([data-theme])) {
@include dark.theme;
}
}
Expand Down
3 changes: 2 additions & 1 deletion scss/themes/default/_styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
* Styles
*/

:root {
:root,
:host {
// Typography
#{$css-var-prefix}font-family-emoji: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
"Noto Color Emoji";
Expand Down

0 comments on commit 02c9fb6

Please sign in to comment.