| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- //
- // Copyright 2022 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.
- //
- // Selector '.mdc-*' should only be used in this project.
- // stylelint-disable selector-class-pattern --
- // NOTE: this is the implementation of the aforementioned classes.
- @use 'sass:map';
- @use '@material/notched-outline/mixins' as notched-outline-mixins;
- @use '@material/theme/custom-properties';
- @use '@material/theme/keys';
- @use '@material/theme/theme';
- @use '@material/theme/validate';
- @use '@material/tokens/resolvers';
- @use './text-field-theme';
- @use './mixins';
- $custom-property-prefix: 'outlined-text-field';
- $_light-theme: (
- caret-color: null,
- container-height: null,
- container-shape: null,
- disabled-input-text-color: null,
- disabled-input-text-opacity: null,
- disabled-label-text-color: null,
- disabled-label-text-opacity: null,
- disabled-leading-icon-color: null,
- disabled-leading-icon-opacity: null,
- disabled-outline-color: null,
- disabled-outline-opacity: null,
- disabled-outline-width: null,
- disabled-supporting-text-color: null,
- disabled-supporting-text-opacity: null,
- disabled-trailing-icon-color: null,
- disabled-trailing-icon-opacity: null,
- error-caret-color: null,
- error-focus-caret-color: null,
- error-focus-input-text-color: null,
- error-focus-label-text-color: null,
- error-focus-leading-icon-color: null,
- error-focus-outline-color: null,
- error-focus-supporting-text-color: null,
- error-focus-trailing-icon-color: null,
- error-hover-caret-color: null,
- error-hover-input-text-color: null,
- error-hover-label-text-color: null,
- error-hover-leading-icon-color: null,
- error-hover-outline-color: null,
- error-hover-supporting-text-color: null,
- error-hover-trailing-icon-color: null,
- error-input-text-color: null,
- error-label-text-color: null,
- error-leading-icon-color: null,
- error-outline-color: null,
- error-supporting-text-color: null,
- error-trailing-icon-color: null,
- focus-caret-color: null,
- focus-input-text-color: null,
- focus-label-text-color: null,
- focus-leading-icon-color: null,
- focus-outline-color: null,
- focus-outline-width: null,
- focus-supporting-text-color: null,
- focus-trailing-icon-color: null,
- hover-caret-color: null,
- hover-input-text-color: null,
- hover-label-text-color: null,
- hover-leading-icon-color: null,
- hover-outline-color: null,
- hover-outline-width: null,
- hover-supporting-text-color: null,
- hover-trailing-icon-color: null,
- input-text-color: null,
- input-text-font: null,
- input-text-line-height: null,
- input-text-placeholder-color: null,
- input-text-prefix-color: null,
- input-text-size: null,
- input-text-suffix-color: null,
- input-text-tracking: null,
- input-text-type: null,
- input-text-weight: null,
- label-text-color: null,
- label-text-font: null,
- label-text-line-height: null,
- label-text-populated-line-height: null,
- label-text-populated-size: null,
- label-text-size: null,
- label-text-tracking: null,
- label-text-type: null,
- label-text-weight: null,
- leading-icon-color: null,
- leading-icon-size: null,
- outline-color: null,
- outline-width: null,
- supporting-text-color: null,
- supporting-text-font: null,
- supporting-text-line-height: null,
- supporting-text-size: null,
- supporting-text-tracking: null,
- supporting-text-type: null,
- supporting-text-weight: null,
- trailing-icon-color: null,
- trailing-icon-size: null,
- );
- @mixin theme($theme) {
- $theme: validate.theme($_light-theme, $theme);
- @include keys.declare-custom-properties(
- $theme,
- $prefix: $custom-property-prefix
- );
- }
- @mixin theme-styles($theme, $resolvers: resolvers.$material) {
- $theme: validate.theme-styles($_light-theme, $theme, false);
- $theme: keys.create-theme-properties(
- $theme,
- $prefix: $custom-property-prefix
- );
- @include text-field-theme.theme-styles($theme, $resolvers: $resolvers);
- &:not(.mdc-text-field--textarea) {
- $container-height: map.get($theme, container-height);
- @if $container-height {
- $container-height-value: if(
- custom-properties.is-custom-prop($container-height),
- custom-properties.get-declaration-value($container-height),
- $container-height
- );
- $keyframe-suffix: if(
- custom-properties.is-custom-prop($container-height),
- 'text-field-outlined-#{custom-properties.get-fallback($container-height)}',
- 'text-field-outlined-#{$container-height}'
- );
- @include mixins.outlined-height($container-height-value, $keyframe-suffix);
- &.mdc-text-field--with-leading-icon {
- $with-leading-icon-keyframe-suffix: if(
- custom-properties.is-custom-prop($container-height),
- 'text-field-outlined-with-leading-icon-#{custom-properties.get-fallback($container-height)}',
- 'text-field-outlined-with-leading-icon-#{$container-height}'
- );
- @include mixins.outlined-with-leading-icon-height($container-height-value, $with-leading-icon-keyframe-suffix);
- }
- }
- }
- @if map.get($theme, container-shape) {
- @include mixins.outline-shape-radius(map.get($theme, container-shape));
- }
- @include _outline-color(
- (
- default: map.get($theme, outline-color),
- hover: map.get($theme, hover-outline-color),
- focus: map.get($theme, focus-outline-color),
- disabled: map.get($theme, disabled-outline-color),
- )
- );
- @include _error-outline-color(
- (
- default: map.get($theme, error-outline-color),
- hover: map.get($theme, error-hover-outline-color),
- focus: map.get($theme, error-focus-outline-color),
- )
- );
- @include _outline-width(
- (
- default: map.get($theme, outline-width),
- hover: map.get($theme, hover-outline-width),
- focus: map.get($theme, focus-outline-width),
- )
- );
- }
- @mixin _outline-color($colors) {
- @include text-field-theme.if-enabled {
- @include _set-outline-color(map.get($colors, default));
- @include text-field-theme.if-hovered {
- .mdc-notched-outline {
- @include _set-outline-color(map.get($colors, hover));
- }
- }
- @include text-field-theme.if-focused {
- @include _set-outline-color(map.get($colors, focus));
- }
- }
- @include text-field-theme.if-disabled {
- @include _set-outline-color(map.get($colors, disabled));
- }
- }
- @mixin _set-outline-color($color) {
- @include notched-outline-mixins.color($color);
- }
- @mixin _error-outline-color($color) {
- &.mdc-text-field--invalid {
- @include _outline-color($color);
- }
- }
- @mixin _outline-width($width) {
- @include text-field-theme.if-enabled {
- @include _set-outline-width(map.get($width, default));
- @include text-field-theme.if-hovered {
- @include _set-outline-width(map.get($width, hover));
- }
- @include text-field-theme.if-focused {
- @include _set-outline-width(map.get($width, focus));
- }
- }
- }
- @mixin _set-outline-width($width) {
- .mdc-notched-outline {
- @include notched-outline-mixins.stroke-width($width);
- }
- }
|