mirror of
https://github.com/material-components/material-web.git
synced 2024-10-26 21:56:56 +03:00
5e40a1bcec
Adds `@material/web/tokens/internal/shape` to take a shape token and create 4 logical tokens from its value. All components' logical shape tokens are now generated by the token files themselves, rather than added in each component's styles. PiperOrigin-RevId: 601783846
182 lines
4.9 KiB
SCSS
182 lines
4.9 KiB
SCSS
//
|
|
// Copyright 2023 Google LLC
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
// go/keep-sorted start
|
|
@use 'sass:map';
|
|
@use 'sass:string';
|
|
// go/keep-sorted end
|
|
// go/keep-sorted start
|
|
@use './internal/shape';
|
|
@use './internal/validate';
|
|
@use './md-sys-color';
|
|
@use './md-sys-shape';
|
|
@use './md-sys-typescale';
|
|
@use './v0_192/md-comp-outlined-text-field';
|
|
// go/keep-sorted end
|
|
|
|
$supported-tokens: (
|
|
// go/keep-sorted start
|
|
'bottom-space',
|
|
'caret-color',
|
|
'container-shape',
|
|
'container-shape-end-end',
|
|
'container-shape-end-start',
|
|
'container-shape-start-end',
|
|
'container-shape-start-start',
|
|
'disabled-input-text-color',
|
|
'disabled-input-text-opacity',
|
|
'disabled-label-text-color',
|
|
'disabled-label-text-opacity',
|
|
'disabled-leading-icon-color',
|
|
'disabled-leading-icon-opacity',
|
|
'disabled-outline-color',
|
|
'disabled-outline-opacity',
|
|
'disabled-outline-width',
|
|
'disabled-supporting-text-color',
|
|
'disabled-supporting-text-opacity',
|
|
'disabled-trailing-icon-color',
|
|
'disabled-trailing-icon-opacity',
|
|
'error-focus-caret-color',
|
|
'error-focus-input-text-color',
|
|
'error-focus-label-text-color',
|
|
'error-focus-leading-icon-color',
|
|
'error-focus-outline-color',
|
|
'error-focus-supporting-text-color',
|
|
'error-focus-trailing-icon-color',
|
|
'error-hover-input-text-color',
|
|
'error-hover-label-text-color',
|
|
'error-hover-leading-icon-color',
|
|
'error-hover-outline-color',
|
|
'error-hover-supporting-text-color',
|
|
'error-hover-trailing-icon-color',
|
|
'error-input-text-color',
|
|
'error-label-text-color',
|
|
'error-leading-icon-color',
|
|
'error-outline-color',
|
|
'error-supporting-text-color',
|
|
'error-trailing-icon-color',
|
|
'focus-caret-color',
|
|
'focus-input-text-color',
|
|
'focus-label-text-color',
|
|
'focus-leading-icon-color',
|
|
'focus-outline-color',
|
|
'focus-outline-width',
|
|
'focus-supporting-text-color',
|
|
'focus-trailing-icon-color',
|
|
'hover-input-text-color',
|
|
'hover-label-text-color',
|
|
'hover-leading-icon-color',
|
|
'hover-outline-color',
|
|
'hover-outline-width',
|
|
'hover-supporting-text-color',
|
|
'hover-trailing-icon-color',
|
|
'input-text-color',
|
|
'input-text-font',
|
|
'input-text-line-height',
|
|
'input-text-placeholder-color',
|
|
'input-text-prefix-color',
|
|
'input-text-prefix-trailing-space',
|
|
'input-text-size',
|
|
'input-text-suffix-color',
|
|
'input-text-suffix-leading-space',
|
|
'input-text-weight',
|
|
'label-text-color',
|
|
'label-text-font',
|
|
'label-text-line-height',
|
|
'label-text-populated-line-height',
|
|
'label-text-populated-size',
|
|
'label-text-size',
|
|
'label-text-weight',
|
|
'leading-icon-color',
|
|
'leading-icon-size',
|
|
'leading-space',
|
|
'outline-color',
|
|
'outline-width',
|
|
'supporting-text-color',
|
|
'supporting-text-font',
|
|
'supporting-text-line-height',
|
|
'supporting-text-size',
|
|
'supporting-text-weight',
|
|
'top-space',
|
|
'trailing-icon-color',
|
|
'trailing-icon-size',
|
|
'trailing-space',
|
|
// go/keep-sorted end
|
|
);
|
|
|
|
$unsupported-tokens: (
|
|
// go/keep-sorted start
|
|
'input-text-tracking',
|
|
'input-text-type',
|
|
'label-text-tracking',
|
|
'label-text-type',
|
|
'supporting-text-tracking',
|
|
'supporting-text-type',
|
|
// go/keep-sorted end
|
|
);
|
|
|
|
$_default: (
|
|
'md-sys-color': md-sys-color.values-light(),
|
|
'md-sys-shape': md-sys-shape.values(),
|
|
'md-sys-typescale': md-sys-typescale.values(),
|
|
);
|
|
|
|
@function values(
|
|
$deps: $_default,
|
|
$exclude-hardcoded-values: false,
|
|
$exclude-custom-properties: true
|
|
) {
|
|
$tokens: md-comp-outlined-text-field.values($deps, $exclude-hardcoded-values);
|
|
$new-tokens: map.merge(
|
|
shape.get-new-logical-shape-tokens($tokens, 'container-shape'),
|
|
(
|
|
'leading-space': if($exclude-hardcoded-values, null, 16px),
|
|
'trailing-space': if($exclude-hardcoded-values, null, 16px),
|
|
'top-space': if($exclude-hardcoded-values, null, 16px),
|
|
'bottom-space': if($exclude-hardcoded-values, null, 16px),
|
|
'input-text-prefix-trailing-space':
|
|
if($exclude-hardcoded-values, null, 2px),
|
|
'input-text-suffix-leading-space':
|
|
if($exclude-hardcoded-values, null, 2px),
|
|
// TODO(b/270705687): remove when focus-caret-color token added
|
|
'focus-caret-color': map.get($deps, 'md-sys-color', 'primary'),
|
|
)
|
|
);
|
|
|
|
$tokens: validate.values(
|
|
$tokens,
|
|
$supported-tokens: $supported-tokens,
|
|
$unsupported-tokens: $unsupported-tokens,
|
|
$new-tokens: $new-tokens
|
|
);
|
|
|
|
$tokens: map.merge(
|
|
$tokens,
|
|
(
|
|
// TODO(b/259455114): remove when focus tokens update to 3px
|
|
'focus-outline-width': if($exclude-hardcoded-values, null, 3px)
|
|
)
|
|
);
|
|
|
|
// Default to `$exclude-custom-properties: false` in the next breaking change.
|
|
// See b/321816473.
|
|
@if not $exclude-custom-properties {
|
|
@each $token, $value in $tokens {
|
|
@if string.index($token, 'container-shape-') == 1 {
|
|
// Add fallback to shorthand for logical shape properties.
|
|
$value: var(--md-outlined-text-field-container-shape, #{$value});
|
|
}
|
|
|
|
$tokens: map.set(
|
|
$tokens,
|
|
$token,
|
|
var(--md-outlined-text-field-#{$token}, #{$value})
|
|
);
|
|
}
|
|
}
|
|
|
|
@return $tokens;
|
|
}
|