-
Notifications
You must be signed in to change notification settings - Fork 904
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(elevation)!: remove surface for tonal surface update
Changes: - Elevation is now `inset:0;position:absolute;` by default - Separated surface styles into a temporary `<md-elevation-surface>` element (this will be removed after tonal surface update) PiperOrigin-RevId: 521934300
- Loading branch information
1 parent
988ad97
commit d12ed3e
Showing
28 changed files
with
187 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* @license | ||
* Copyright 2023 Google LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import {customElement} from 'lit/decorators.js'; | ||
|
||
import {styles} from './lib/elevation-styles.css.js'; | ||
import {ElevationSurface} from './lib/elevation-surface.js'; | ||
import {styles as surfaceStyles} from './lib/surface-styles.css.js'; | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'md-elevation-surface': MdElevationSurface; | ||
} | ||
} | ||
|
||
/** | ||
* @deprecated An elevation component with a surface-tint. Will be removed | ||
* once components are updated. | ||
*/ | ||
@customElement('md-elevation-surface') | ||
export class MdElevationSurface extends ElevationSurface { | ||
static override styles = [styles, surfaceStyles]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// Copyright 2023 Google LLC | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
/// @deprecated Remove once components are updated for tonal surfaces | ||
@mixin styles() { | ||
.surface { | ||
// Surface tint opacities: | ||
// level0: opacity: 0; | ||
// level1: opacity: 0.05; | ||
// level2: opacity: 0.08; | ||
// level3: opacity: 0.11; | ||
// level4: opacity: 0.12; | ||
// level5: opacity: 0.14; | ||
|
||
// Add a clamped value for each level to build the correct values. | ||
// Sass will simplify nested calc()s. | ||
|
||
// 0 + 0 = 0 | ||
// $level0-opacity: 0; // +0 is a no-op | ||
// 0 + 0.05 = 0.05 | ||
$level1-opacity: clamp(0, var(--_level), 0.05); | ||
// 0.05 + 0.03 = 0.08 | ||
$level2-opacity: clamp(0, var(--_level) - 1, 0.03); | ||
// 0.08 + 0.03 = 0.11 | ||
$level3-opacity: clamp(0, var(--_level) - 2, 0.03); | ||
// (can't simplify levels 2-3 since the value is < 1) | ||
// 0.11 + 0.01 = 0.12 | ||
$level4-opacity: clamp(0, var(--_level) - 3, 0.01); | ||
// 0.12 + 0.02 = 0.14 | ||
$level5-opacity: clamp(0, var(--_level) - 4, 0.02); | ||
$opacity: calc( | ||
$level1-opacity + $level2-opacity + $level3-opacity + $level4-opacity + | ||
$level5-opacity | ||
); | ||
|
||
background: var( | ||
--md-elevation-surface-tint, | ||
var(--md-sys-color-surface-tint, #6750a4) | ||
); | ||
border-radius: inherit; | ||
inset: 0; | ||
opacity: $opacity; | ||
position: absolute; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* @license | ||
* Copyright 2023 Google LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import {html, nothing} from 'lit'; | ||
import {property} from 'lit/decorators.js'; | ||
|
||
import {Elevation} from './elevation.js'; | ||
|
||
/** | ||
* @deprecated An elevation component with a surface-tint. Will be removed | ||
* once components are updated. | ||
*/ | ||
export class ElevationSurface extends Elevation { | ||
/** | ||
* Whether or not the elevation level should display a shadow. | ||
*/ | ||
@property({type: Boolean}) shadow = false; | ||
|
||
override render() { | ||
return html` | ||
<span class="surface"></span> | ||
${this.shadow ? super.render() : nothing} | ||
`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.