diff --git a/src/app/header/header.component.scss b/src/app/header/header.component.scss index c6657a22..848c2d2f 100644 --- a/src/app/header/header.component.scss +++ b/src/app/header/header.component.scss @@ -15,7 +15,7 @@ header { @include borders.panel(bottom); background-color: var(--app-color-toolbar-background); - @include animations.when-motion-host-context { + @include animations.when-motion { @include animations.multiple-transitions( (background-color, border-color), animations.$emphasized-style diff --git a/src/app/header/light-dark-toggle/light-dark-toggle.component.scss b/src/app/header/light-dark-toggle/light-dark-toggle.component.scss index 62a318bf..733d26f5 100644 --- a/src/app/header/light-dark-toggle/light-dark-toggle.component.scss +++ b/src/app/header/light-dark-toggle/light-dark-toggle.component.scss @@ -15,7 +15,7 @@ button { } } - @include animations.when-motion-host-context { + @include animations.when-motion { @include animations.single-transition(color, animations.$emphasized-style); } diff --git a/src/app/header/tab/tab.component.scss b/src/app/header/tab/tab.component.scss index 11131531..d8ff642f 100644 --- a/src/app/header/tab/tab.component.scss +++ b/src/app/header/tab/tab.component.scss @@ -27,7 +27,7 @@ } } - @include animations.when-motion-host-context { + @include animations.when-motion { @include animations.multiple-transitions( (border-bottom-color, color), animations.$emphasized-style diff --git a/src/app/resume-page/attribute/attribute.component.scss b/src/app/resume-page/attribute/attribute.component.scss index 2f8a3099..f292e760 100644 --- a/src/app/resume-page/attribute/attribute.component.scss +++ b/src/app/resume-page/attribute/attribute.component.scss @@ -8,7 +8,7 @@ cursor: pointer; color: var(--ui-text); - @include animations.when-motion-host-context { + @include animations.when-motion { @include animations.single-transition(color); } @@ -29,7 +29,7 @@ visibility: hidden; right: 150%; opacity: 0; - @include animations.when-motion-host-context { + @include animations.when-motion { @include animations.multiple-transitions( (right, opacity, visibility, background-color, color, border-color), animations.$emphasized-style diff --git a/src/app/resume-page/card/card-header/card-header-detail/card-header-detail.component.scss b/src/app/resume-page/card/card-header/card-header-detail/card-header-detail.component.scss index 940bd3ca..b13c7804 100644 --- a/src/app/resume-page/card/card-header/card-header-detail/card-header-detail.component.scss +++ b/src/app/resume-page/card/card-header/card-header-detail/card-header-detail.component.scss @@ -3,7 +3,7 @@ :host { font-size: 1rem; color: var(--ui-text); - @include animations.when-motion-host-context { + @include animations.when-motion { @include animations.single-transition(color, animations.$emphasized-style); } } diff --git a/src/app/resume-page/card/card-header/card-header-image/card-header-image.component.scss b/src/app/resume-page/card/card-header/card-header-image/card-header-image.component.scss index 28f972ab..f1d35d8a 100644 --- a/src/app/resume-page/card/card-header/card-header-image/card-header-image.component.scss +++ b/src/app/resume-page/card/card-header/card-header-image/card-header-image.component.scss @@ -8,7 +8,7 @@ img { border-radius: card-header-image.$size; filter: var(--img-filter); - @include animations.when-motion-host-context { + @include animations.when-motion { @include animations.single-transition(filter, animations.$emphasized-style); } } diff --git a/src/app/resume-page/card/card-header/card-header-subtitle/card-header-subtitle.component.scss b/src/app/resume-page/card/card-header/card-header-subtitle/card-header-subtitle.component.scss index 0d3384a4..46b10b01 100644 --- a/src/app/resume-page/card/card-header/card-header-subtitle/card-header-subtitle.component.scss +++ b/src/app/resume-page/card/card-header/card-header-subtitle/card-header-subtitle.component.scss @@ -4,7 +4,7 @@ font-size: 1.15rem; color: var(--ui-text); - @include animations.when-motion-host-context { + @include animations.when-motion { @include animations.single-transition(color, animations.$emphasized-style); } } diff --git a/src/app/resume-page/card/card.component.scss b/src/app/resume-page/card/card.component.scss index ce4a4363..4175f0ca 100644 --- a/src/app/resume-page/card/card.component.scss +++ b/src/app/resume-page/card/card.component.scss @@ -11,7 +11,7 @@ @include borders.panel; background-color: var(--sys-color-surface1); - @include animations.when-motion-host-context { + @include animations.when-motion { @include animations.multiple-transitions( (background-color, border-color), animations.$emphasized-style diff --git a/src/app/resume-page/chip/chip.component.scss b/src/app/resume-page/chip/chip.component.scss index 7bd571ca..350abb75 100644 --- a/src/app/resume-page/chip/chip.component.scss +++ b/src/app/resume-page/chip/chip.component.scss @@ -11,7 +11,7 @@ color: var(--sys-color-on-surface); border-color: var(--adorner-border-color); - @include animations.when-motion-host-context { + @include animations.when-motion { @include animations.multiple-transitions( (background-color, color, border-color), animations.$emphasized-style diff --git a/src/app/resume-page/content-chip/content-chip.component.scss b/src/app/resume-page/content-chip/content-chip.component.scss index 7a510ec7..14728b43 100644 --- a/src/app/resume-page/content-chip/content-chip.component.scss +++ b/src/app/resume-page/content-chip/content-chip.component.scss @@ -7,7 +7,7 @@ padding: paddings.$s; background-color: var(--sys-color-surface3); - @include animations.when-motion-host-context { + @include animations.when-motion { @include animations.multiple-transitions( (background-color, border-color), animations.$emphasized-style diff --git a/src/app/resume-page/languages-section/language-item/language-tag/language-tag.component.scss b/src/app/resume-page/languages-section/language-item/language-tag/language-tag.component.scss index 059253f7..bd65109c 100644 --- a/src/app/resume-page/languages-section/language-item/language-tag/language-tag.component.scss +++ b/src/app/resume-page/languages-section/language-item/language-tag/language-tag.component.scss @@ -27,7 +27,7 @@ code { font-weight: bold; font-size: math.div(3 * card-header-image.$size, 8); - @include animations.when-motion-host-context { + @include animations.when-motion { @include animations.multiple-transitions( (background-color), animations.$emphasized-style diff --git a/src/app/resume-page/profile-section/profile-contacts/profile-contacts.component.scss b/src/app/resume-page/profile-section/profile-contacts/profile-contacts.component.scss index 9802e377..b39e8eff 100644 --- a/src/app/resume-page/profile-section/profile-contacts/profile-contacts.component.scss +++ b/src/app/resume-page/profile-section/profile-contacts/profile-contacts.component.scss @@ -22,7 +22,7 @@ li { &:hover { color: var(--sys-color-on-surface); } - @include animations.when-motion-host-context { + @include animations.when-motion { @include animations.single-transition( color, animations.$emphasized-style diff --git a/src/app/resume-page/profile-section/profile-picture/profile-picture.component.scss b/src/app/resume-page/profile-section/profile-picture/profile-picture.component.scss index cd9d4a60..e7d033df 100644 --- a/src/app/resume-page/profile-section/profile-picture/profile-picture.component.scss +++ b/src/app/resume-page/profile-section/profile-picture/profile-picture.component.scss @@ -44,7 +44,7 @@ img { border-color: var(--sys-color-divider); filter: var(--img-filter); - @include animations.when-motion-host-context { + @include animations.when-motion { transition: animations.transition(opacity), animations.transition(visibility), animations.transition(filter, animations.$emphasized-style), @@ -78,7 +78,7 @@ img { padding: paddings.$s; border-radius: paddings.$s; - @include animations.when-motion-host-context { + @include animations.when-motion { @include animations.multiple-transitions((opacity, visibility)); } diff --git a/src/app/resume-page/section-title/section-title.component.scss b/src/app/resume-page/section-title/section-title.component.scss index 371ab7b8..a7746660 100644 --- a/src/app/resume-page/section-title/section-title.component.scss +++ b/src/app/resume-page/section-title/section-title.component.scss @@ -16,7 +16,7 @@ background-color: var(--app-color-toolbar-background); color: var(--ui-text); - @include animations.when-motion-host-context { + @include animations.when-motion { @include animations.multiple-transitions( (color, background-color, border-color), animations.$emphasized-style diff --git a/src/app/sports-page/sports-page.component.scss b/src/app/sports-page/sports-page.component.scss index 6653ca1a..905ad19e 100644 --- a/src/app/sports-page/sports-page.component.scss +++ b/src/app/sports-page/sports-page.component.scss @@ -11,10 +11,10 @@ @include texts.page; img.sports-equation { - @include theming.when-dark-mode-host-context { + @include theming.when-dark-mode { filter: invert(1); } - @include animations.when-motion-host-context { + @include animations.when-motion { @include animations.single-transition(filter, animations.$emphasized-style); } } diff --git a/src/sass/_animations.scss b/src/sass/_animations.scss index 07786d85..27fe8009 100644 --- a/src/sass/_animations.scss +++ b/src/sass/_animations.scss @@ -53,23 +53,10 @@ $emphasized-style: ( $_reduced-motion-attribute-selector: '[data-reduced-motion]'; $_no-reduced-motion-selector: ':not(#{$_reduced-motion-attribute-selector})'; -@mixin when-motion-host-context() { - @include root-attribute.host-context($_no-reduced-motion-selector) { - @include no-reduced-motion-preference { +@mixin when-motion($hostContext: true) { + @include root-attribute.context($_no-reduced-motion-selector, $hostContext) { + @media (prefers-reduced-motion: no-preference) { @content; } } } -@mixin when-motion() { - @include root-attribute.context($_no-reduced-motion-selector) { - @include no-reduced-motion-preference { - @content; - } - } -} - -@mixin no-reduced-motion-preference() { - @media (prefers-reduced-motion: no-preference) { - @content; - } -} diff --git a/src/sass/_theming.scss b/src/sass/_theming.scss index 41e35435..3f2f15d9 100644 --- a/src/sass/_theming.scss +++ b/src/sass/_theming.scss @@ -50,11 +50,11 @@ $_no-color-scheme-attribute-selector: ':not([data-color-scheme])'; $_dark-mode-attribute-selector: '[data-color-scheme="dark"]'; -@mixin when-dark-mode-host-context { - @include root-attribute.host-context($_dark-mode-attribute-selector) { +@mixin when-dark-mode { + @include root-attribute.context($_dark-mode-attribute-selector) { @content; } - @include root-attribute.host-context($_no-color-scheme-attribute-selector) { + @include root-attribute.context($_no-color-scheme-attribute-selector) { @media (prefers-color-scheme: dark) { @content; } diff --git a/src/sass/helpers/_root-attribute.scss b/src/sass/helpers/_root-attribute.scss index 24723eb3..893239cc 100644 --- a/src/sass/helpers/_root-attribute.scss +++ b/src/sass/helpers/_root-attribute.scss @@ -2,7 +2,20 @@ @use 'sass:string'; $_root-selector: 'html'; // could use :root 🤷 -@mixin host-context($attributeSelector) { + +@mixin context($attributeSelector, $hostContext: true) { + @if ($hostContext) { + @include _host-context($attributeSelector) { + @content; + } + } @else { + @include _root-context($attributeSelector) { + @content; + } + } +} + +@mixin _host-context($attributeSelector) { @at-root { // 👇 Angular adds [_nghost-ng-g4rb4g3] when using :host-context(selector) twice to: // - Match selector in host: `selector:host` @@ -24,7 +37,7 @@ $_root-selector: 'html'; // could use :root 🤷 } } -@mixin context($attributeSelector) { +@mixin _root-context($attributeSelector) { @at-root { #{selector.nest(_root-attribute-selector($attributeSelector), &)} { @content; diff --git a/src/styles.scss b/src/styles.scss index 955d57e0..9f4e8506 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -28,7 +28,7 @@ body { // Do not allow scroll "bounce" effect overscroll-behavior: none; - @include animations.when-motion { + @include animations.when-motion($hostContext: false) { @include animations.multiple-transitions( (color, background-color), animations.$emphasized-style @@ -51,7 +51,7 @@ a { text-decoration-line: underline; text-decoration-thickness: 1px; - @include animations.when-motion { + @include animations.when-motion($hostContext: false) { @include animations.multiple-transitions( (color, text-decoration-color), animations.$emphasized-style