@material/chips
Version:
The Material Components for the Web chips component
120 lines (112 loc) • 4.11 kB
Plain Text
//
// Copyright 2021 Google Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
'sass:map';
'/theme/theme';
'/theme/keys';
'/tokens/resolvers';
'./chip-theme';
$_light-theme: (
container-shape: null,
container-height: null,
container-elevation: null,
outline-color: null,
outline-width: null,
container-shadow-color: null,
label-text-font: null,
label-text-line-height: null,
label-text-size: null,
label-text-weight: null,
label-text-tracking: null,
label-text-color: null,
with-trailing-icon-trailing-icon-size: null,
with-trailing-icon-trailing-icon-color: null,
with-leading-icon-leading-icon-size: null,
with-leading-icon-leading-icon-color: null,
with-avatar-avatar-size: null,
with-avatar-avatar-shape: null,
disabled-outline-color: null,
disabled-outline-opacity: null,
disabled-label-text-color: null,
disabled-label-text-opacity: null,
with-trailing-icon-disabled-trailing-icon-color: null,
with-trailing-icon-disabled-trailing-icon-opacity: null,
with-leading-icon-disabled-leading-icon-color: null,
with-leading-icon-disabled-leading-icon-opacity: null,
with-avatar-disabled-avatar-opacity: null,
hover-state-layer-color: null,
hover-state-layer-opacity: null,
hover-label-text-color: null,
with-trailing-icon-hover-trailing-icon-color: null,
with-leading-icon-hover-leading-icon-color: null,
focus-state-layer-color: null,
focus-state-layer-opacity: null,
focus-label-text-color: null,
focus-outline-color: null,
with-trailing-icon-focus-trailing-icon-color: null,
with-leading-icon-focus-leading-icon-color: null,
pressed-state-layer-color: null,
pressed-state-layer-opacity: null,
pressed-label-text-color: null,
with-trailing-icon-pressed-trailing-icon-color: null,
with-leading-icon-pressed-leading-icon-color: null,
container-surface-tint-layer-color: null,
);
$_custom-property-prefix: 'input-chip';
theme($theme, $resolvers: resolvers.$material) {
theme.validate-theme($_light-theme, $theme);
// Resolve elevation.
$key
in (
flat-container-elevation,
elevated-container-elevation,
elevated-disabled-container-elevation,
elevated-hover-container-elevation,
elevated-focus-container-elevation,
elevated-pressed-container-elevation
)
{
$value: map.get($theme, $key);
$value {
$theme: map.set(
$theme,
$key,
meta.call(
$elevation-resolver: map.get($resolvers, elevation),
$elevation: $value,
$shadow-color: map.get($theme, elevated-container-shadow-color),
)
);
}
}
keys.declare-custom-properties(
$theme,
$prefix: $_custom-property-prefix
);
}
theme-styles($theme, $resolvers: resolvers.$material) {
theme.validate-theme($_light-theme, $theme);
$theme: keys.create-theme-properties(
$theme,
$prefix: $_custom-property-prefix
);
chip-theme.theme-styles($theme, $resolvers: $resolvers);
}