Skip to content

Commit

Permalink
fix(elevation): tidy up tokens and update roadmap
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 523211633
  • Loading branch information
asyncLiz authored and copybara-github committed Apr 10, 2023
1 parent 8e507f8 commit 301eb9a
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 29 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Checkbox | ✅ | ✅ | ❌
Chips | 🟡 | ❌ | ❌
Dialog | ✅ | ✅ | ❌
Divider | ✅ | ✅ | 🟡
Elevation | ✅ | |
Elevation | ✅ | | 🟡
Focus ring | ✅ | ❌ | ❌
Field | ✅ | ✅ | 🟡
Icon | ✅ | ✅ | ❌
Expand Down
16 changes: 13 additions & 3 deletions button/lib/_elevation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,28 @@
// stylelint-disable selector-class-pattern --
// Selector '.md3-*' should only be used in this project.

// go/keep-sorted start
@use 'sass:map';
// go/keep-sorted end
// go/keep-sorted start
@use '../../elevation/elevation';
@use '../../tokens';
// go/keep-sorted end

$_md-sys-motion: tokens.md-sys-motion-values();

@mixin styles() {
md-elevation {
// TODO: replace duration with animation tokens
transition-duration: 280ms;
transition-timing-function: map.get($_md-sys-motion, 'emphasized-easing');
}

.md3-button {
@include elevation.theme(
(
// TODO: replace duration with animation tokens
'duration': 280ms,
'level': var(--_container-elevation),
'shadow-color': var(--_container-shadow-color)
'shadow-color': var(--_container-shadow-color),
)
);

Expand Down
12 changes: 5 additions & 7 deletions elevation/lib/_elevation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@

display: flex;
pointer-events: none;
transition-duration: var(--_duration);
transition-timing-function: var(--_easing);
}

:host,
Expand All @@ -40,17 +38,17 @@
border-radius: inherit;
inset: 0;
position: absolute;
transition-duration: inherit;
transition-timing-function: inherit;
}

.shadow::before,
.shadow::after {
content: '';
transition-duration: inherit;
transition-property: box-shadow, opacity;
transition-timing-function: inherit;
}

// Key box shadows
// Key box shadow
.shadow::before {
// level0: box-shadow: 0px 0px 0px 0px;
// level1: box-shadow: 0px 1px 2px 0px;
Expand Down Expand Up @@ -96,7 +94,7 @@
opacity: 0.3;
}

// Ambient box shadows
// Ambient box shadow
.shadow::after {
// level0: box-shadow: 0px 0px 0px 0px;
// level1: box-shadow: 0px 1px 3px 1px;
Expand Down Expand Up @@ -161,7 +159,7 @@
// Convert to px.
$spread: calc(1px * ($level1to4-spread + $level5-spread));

opacity: 0.15;
box-shadow: 0px $y $blur $spread var(--_shadow-color);
opacity: 0.15;
}
}
10 changes: 7 additions & 3 deletions fab/lib/_shared.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
@use '../../sass/shape';
@use '../../sass/theme';
@use '../../sass/touch-target';
@use '../../tokens';
// go/keep-sorted end

$_md-sys-motion: tokens.md-sys-motion-values();

@mixin styles() {
:host {
display: inline-flex;
Expand Down Expand Up @@ -65,10 +68,8 @@

@include elevation.theme(
(
// TODO: replace duration with animation tokens
'duration': 280ms,
'level': var(--_container-elevation),
'shadow-color': var(--_container-shadow-color)
'shadow-color': var(--_container-shadow-color),
)
);

Expand Down Expand Up @@ -136,6 +137,9 @@
}

md-elevation {
// TODO: replace duration with animation tokens
transition-duration: 280ms;
transition-timing-function: map.get($_md-sys-motion, 'emphasized-easing');
z-index: -1; // Place behind content
}

Expand Down
8 changes: 7 additions & 1 deletion navigationbar/lib/_navigation-bar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
// stylelint-disable selector-class-pattern --
// Selector '.md3-*' should only be used in this project.

// go/keep-sorted start
@use 'sass:map';
// go/keep-sorted end
// go/keep-sorted start
@use '../../elevation/elevation';
@use '../../sass/theme';
@use '../../tokens';
// go/keep-sorted end

$_md-sys-motion: tokens.md-sys-motion-values();

@mixin theme($tokens) {
$tokens: theme.validate-theme(
tokens.md-comp-navigation-bar-values(),
Expand All @@ -33,7 +38,6 @@

@include elevation.theme(
(
'duration': 280ms,
'level': var(--_container-elevation),
'shadow-color': var(--_container-shadow-color),
)
Expand All @@ -57,6 +61,8 @@
}

md-elevation {
transition-duration: 280ms;
transition-timing-function: map.get($_md-sys-motion, 'emphasized-easing');
z-index: 0;
}
}
25 changes: 15 additions & 10 deletions slider/lib/_slider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// SPDX-License-Identifier: Apache-2.0
//

// PUBLIC PROPERTIES

// go/keep-sorted start
@use 'sass:map';
// go/keep-sorted end
Expand All @@ -16,19 +14,22 @@
@use '../../sass/shape';
@use '../../sass/theme';
@use '../../sass/var';
@use './tokens';
@use '../../tokens';
@use './tokens' as slider-tokens;
// go/keep-sorted end

$_md-sys-motion: tokens.md-sys-motion-values();

@mixin theme($tokens) {
$tokens: tokens.remove-unsupported-tokens($tokens);
$tokens: theme.validate-theme(tokens.md-comp-slider-values(), $tokens);
$tokens: slider-tokens.remove-unsupported-tokens($tokens);
$tokens: theme.validate-theme(slider-tokens.md-comp-slider-values(), $tokens);
$tokens: theme.create-theme-vars($tokens, 'slider');

@include theme.emit-theme-vars($tokens);
}

@mixin styles() {
$tokens: tokens.md-comp-slider-values();
$tokens: slider-tokens.md-comp-slider-values();
$tokens: theme.create-theme-vars($tokens, 'slider');

:host {
Expand All @@ -43,14 +44,18 @@

@include elevation.theme(
(
// TODO: replace duration with animation tokens
duration: 280ms,
level: var(--_handle-elevation),
shadow-color: var(--_handle-shadow-color)
shadow-color: var(--_handle-shadow-color),
)
);
}

md-elevation {
// TODO: replace duration with animation tokens
transition-duration: 280ms;
transition-timing-function: map.get($_md-sys-motion, 'emphasized-easing');
}

@media (prefers-reduced-motion) {
:host {
--_handle-motion-duration: 0;
Expand Down Expand Up @@ -470,7 +475,7 @@
@include focus-ring.theme(
(
offset: -2px,
shape: map.get(tokens.md-sys-shape-values(), corner-full),
shape: map.get(slider-tokens.md-sys-shape-values(), corner-full),
)
);
}
Expand Down
4 changes: 0 additions & 4 deletions tokens/_md-comp-elevation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,15 @@
// go/keep-sorted start
@use './md-sys-color';
@use './md-sys-elevation';
@use './md-sys-motion';
// go/keep-sorted end

$_default: (
'md-sys-color': md-sys-color.values-light(),
'md-sys-elevation': md-sys-elevation.values(),
'md-sys-motion': md-sys-motion.values(),
);

@function values($deps: $_default, $exclude-hardcoded-values: false) {
@return (
'duration': if($exclude-hardcoded-values, null, 0s),
'easing': map.get($deps, 'md-sys-motion', 'easing-emphasized'),
'level': map.get($deps, 'md-sys-elevation', 'level0'),
'shadow-color': map.get($deps, 'md-sys-color', 'shadow')
);
Expand Down

0 comments on commit 301eb9a

Please sign in to comment.