mirror of
https://github.com/material-components/material-web.git
synced 2024-09-21 02:27:12 +03:00
89eee57074
PiperOrigin-RevId: 493625319
75 lines
1.6 KiB
SCSS
75 lines
1.6 KiB
SCSS
//
|
|
// Copyright 2021 Google LLC
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
@use 'sass:map';
|
|
@use 'sass:meta';
|
|
@use '../../sass/theme';
|
|
@use '../../sass/var';
|
|
@use './elevation-overlay-theme';
|
|
|
|
@function resolve-theme(
|
|
$theme,
|
|
$resolver,
|
|
$shadow-color-token,
|
|
$elevation-tokens
|
|
) {
|
|
@if $resolver == null {
|
|
@return $theme;
|
|
}
|
|
|
|
$shadow-color: map.get($theme, $shadow-color-token);
|
|
|
|
// Resolve the value for each state key.
|
|
@each $token in $elevation-tokens {
|
|
$value: map.get($theme, $token);
|
|
$elevation-theme: meta.call(
|
|
$resolver,
|
|
$elevation: $value,
|
|
$shadow-color: $shadow-color
|
|
);
|
|
|
|
@each $resolved-token, $resolved-value in $elevation-theme {
|
|
$theme: map.set($theme, #{$token}-#{$resolved-token}, $resolved-value);
|
|
}
|
|
|
|
// clean up unused elevation token
|
|
$theme: map.remove($theme, $token);
|
|
}
|
|
|
|
// clean up unused shadow color token
|
|
$theme: map.remove($theme, $shadow-color-token);
|
|
|
|
@return $theme;
|
|
}
|
|
|
|
/// Represents the configurable values of the elevation theme.
|
|
$_flat-theme: map.merge(
|
|
elevation-overlay-theme.$transparent-theme,
|
|
(
|
|
shadow: none,
|
|
)
|
|
);
|
|
|
|
/// Applies the given theme styles.
|
|
///
|
|
/// @param {Map} $theme - @see $_flat-theme for accepted theme properties.
|
|
@mixin theme-styles($theme) {
|
|
$theme: theme.validate-theme-styles(
|
|
$_flat-theme,
|
|
$theme,
|
|
$require-all: false
|
|
);
|
|
|
|
@include _box-shadow(map.get($theme, shadow));
|
|
@include elevation-overlay-theme.theme-styles($theme);
|
|
}
|
|
|
|
/// Sets the box shadow of the element.
|
|
///
|
|
/// @param {String} $box-shadow - The shadow to apply to the element.
|
|
@mixin _box-shadow($box-shadow) {
|
|
box-shadow: $box-shadow;
|
|
}
|