mirror of
https://github.com/material-components/material-web.git
synced 2024-11-13 00:29:03 +03:00
chore(form-field): merge static/theme-styles
PiperOrigin-RevId: 483690911
This commit is contained in:
parent
f2bf1a5c47
commit
f038b2fac6
@ -1,47 +0,0 @@
|
||||
//
|
||||
// Copyright 2022 Google LLC
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
// stylelint-disable selector-class-pattern --
|
||||
// Selector '.md3-*' should only be used in this project.
|
||||
|
||||
@use 'sass:map';
|
||||
|
||||
@use '../../sass/theme';
|
||||
@use '../../tokens';
|
||||
|
||||
$custom-property-prefix: 'formfield';
|
||||
|
||||
$light-theme: (
|
||||
label-text-color:
|
||||
map.get(tokens.md-sys-color-values-light-dynamic(), on-surface),
|
||||
disabled-label-text-color:
|
||||
map.get(tokens.md-sys-color-values-light-dynamic(), on-surface-variant),
|
||||
);
|
||||
|
||||
@mixin theme($theme) {
|
||||
$theme: theme.validate-theme($light-theme, $theme);
|
||||
@include theme.emit-theme-vars(
|
||||
theme.create-theme-vars($theme, $custom-property-prefix)
|
||||
);
|
||||
}
|
||||
|
||||
@mixin theme-styles($theme) {
|
||||
$theme: theme.validate-theme($light-theme, $theme);
|
||||
$theme: theme.create-theme-vars($theme, $prefix: $custom-property-prefix);
|
||||
|
||||
& {
|
||||
@each $token, $value in $theme {
|
||||
--_#{$token}: #{$value};
|
||||
}
|
||||
}
|
||||
|
||||
.md3-formfield__label {
|
||||
color: var(--_label-text-color);
|
||||
}
|
||||
|
||||
&.md3-formfield--disabled .md3-formfield__label {
|
||||
color: var(--_disabled-label-text-color);
|
||||
}
|
||||
}
|
@ -6,7 +6,28 @@
|
||||
// stylelint-disable selector-class-pattern --
|
||||
// Selector '.md3-*' should only be used in this project.
|
||||
|
||||
@mixin static-styles() {
|
||||
@use '../../sass/theme';
|
||||
@use './md-comp-formfield';
|
||||
|
||||
$custom-property-prefix: 'formfield';
|
||||
|
||||
@mixin theme($tokens) {
|
||||
$tokens: theme.validate-theme(md-comp-formfield.values(), $tokens);
|
||||
$tokens: theme.create-theme-vars($tokens, $custom-property-prefix);
|
||||
|
||||
@include theme.emit-theme-vars($tokens);
|
||||
}
|
||||
|
||||
@mixin styles() {
|
||||
$tokens: md-comp-formfield.values();
|
||||
$tokens: theme.create-theme-vars($tokens, $custom-property-prefix);
|
||||
|
||||
* {
|
||||
@each $token, $value in $tokens {
|
||||
--_#{$token}: #{$value};
|
||||
}
|
||||
}
|
||||
|
||||
:host {
|
||||
display: inline-flex;
|
||||
}
|
||||
@ -19,9 +40,14 @@
|
||||
}
|
||||
|
||||
.md3-formfield__label {
|
||||
color: var(--_label-text-color);
|
||||
margin-inline: 0 auto;
|
||||
order: 0;
|
||||
padding-inline: 4px 0;
|
||||
|
||||
.md3-formfield--disabled & {
|
||||
color: var(--_disabled-label-text-color);
|
||||
}
|
||||
}
|
||||
|
||||
.md3-formfield--align-end .md3-formfield__label {
|
||||
|
18
formfield/lib/_md-comp-formfield.scss
Normal file
18
formfield/lib/_md-comp-formfield.scss
Normal file
@ -0,0 +1,18 @@
|
||||
//
|
||||
// Copyright 2022 Google LLC
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
@use 'sass:map';
|
||||
@use '../../tokens';
|
||||
|
||||
$_default: (
|
||||
md-sys-color: tokens.md-sys-color-values-light-dynamic(),
|
||||
);
|
||||
|
||||
@function values($deps: $_default, $exclude-hardcoded-values: false) {
|
||||
@return (
|
||||
label-text-color: map.get($deps, md-sys-color, on-surface),
|
||||
disabled-label-text-color: map.get($deps, md-sys-color, on-surface-variant)
|
||||
);
|
||||
}
|
@ -3,14 +3,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
// stylelint-disable selector-class-pattern --
|
||||
// Selector '.md3-*' should only be used in this project.
|
||||
|
||||
@use './formfield';
|
||||
@use './formfield-theme';
|
||||
|
||||
@include formfield.static-styles();
|
||||
|
||||
.md3-formfield {
|
||||
@include formfield-theme.theme-styles(formfield-theme.$light-theme);
|
||||
}
|
||||
@include formfield.styles;
|
||||
|
Loading…
Reference in New Issue
Block a user