| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326 |
- //
- // Copyright 2016 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.
- //
- // stylelint-disable selector-class-pattern --
- // Selector '.mdc-*' should only be used in this project.
- @use 'sass:map';
- @use '@material/animation/animation';
- @use '@material/dom/dom';
- @use '@material/feature-targeting/feature-targeting';
- @use '@material/ripple/ripple';
- @use '@material/ripple/ripple-theme';
- @use '@material/touch-target/mixins' as touch-target-mixins;
- @use '@material/touch-target/variables' as touch-target-variables;
- @use './radio-theme';
- @use '@material/focus-ring/focus-ring';
- $ripple-target: radio-theme.$ripple-target;
- ///
- /// Radio core styles.
- ///
- @mixin core-styles($query: feature-targeting.all()) {
- @include without-ripple($query);
- @include ripple($query);
- }
- @mixin static-styles($query: feature-targeting.all()) {
- $feat-animation: feature-targeting.create-target($query, animation);
- $feat-color: feature-targeting.create-target($query, color);
- $feat-structure: feature-targeting.create-target($query, structure);
- .mdc-radio {
- @include feature-targeting.targets($feat-structure) {
- display: inline-block;
- position: relative;
- flex: 0 0 auto;
- box-sizing: content-box;
- width: radio-theme.$icon-size;
- height: radio-theme.$icon-size;
- cursor: pointer;
- /* @alternate */
- will-change: opacity, transform, border-color, color;
- &[hidden] {
- display: none;
- }
- }
- // Container for radio circles and ripple.
- &__background {
- @include feature-targeting.targets($feat-structure) {
- display: inline-block;
- position: relative;
- box-sizing: border-box;
- width: radio-theme.$icon-size;
- height: radio-theme.$icon-size;
- }
- &::before {
- @include feature-targeting.targets($feat-structure) {
- position: absolute;
- transform: scale(0, 0);
- border-radius: 50%;
- opacity: 0;
- pointer-events: none;
- content: '';
- }
- @include feature-targeting.targets($feat-animation) {
- transition: exit(opacity), exit(transform);
- }
- }
- }
- &__outer-circle {
- @include feature-targeting.targets($feat-structure) {
- position: absolute;
- top: 0;
- left: 0;
- box-sizing: border-box;
- width: 100%;
- height: 100%;
- border-width: 2px;
- border-style: solid;
- border-radius: 50%;
- }
- @include feature-targeting.targets($feat-animation) {
- transition: exit(border-color);
- }
- }
- &__inner-circle {
- @include feature-targeting.targets($feat-structure) {
- position: absolute;
- top: 0;
- left: 0;
- box-sizing: border-box;
- width: 100%;
- height: 100%;
- transform: scale(0, 0);
- border-width: 10px;
- border-style: solid;
- border-radius: 50%;
- }
- @include feature-targeting.targets($feat-animation) {
- transition: exit(transform), exit(border-color);
- }
- }
- &__native-control {
- @include feature-targeting.targets($feat-structure) {
- position: absolute;
- margin: 0;
- padding: 0;
- opacity: 0;
- cursor: inherit;
- z-index: 1;
- }
- }
- &--touch {
- @include touch-target-mixins.margin(
- $component-height: radio-theme.$ripple-size,
- $component-width: radio-theme.$ripple-size,
- $query: $query
- );
- @include radio-theme.touch-target(
- $size: touch-target-variables.$height,
- $query: $query
- );
- }
- @include ripple-theme.focus {
- .mdc-radio__focus-ring {
- @include focus-ring.focus-ring(
- $container-outer-padding-vertical: 0,
- $container-outer-padding-horizontal: 0,
- $query: $query
- );
- }
- }
- }
- .mdc-radio__native-control:checked,
- .mdc-radio__native-control:disabled {
- + .mdc-radio__background {
- @include feature-targeting.targets($feat-animation) {
- transition: enter(opacity), enter(transform);
- }
- .mdc-radio__outer-circle {
- @include feature-targeting.targets($feat-animation) {
- transition: enter(border-color);
- }
- }
- .mdc-radio__inner-circle {
- @include feature-targeting.targets($feat-animation) {
- transition: enter(transform), enter(border-color);
- }
- }
- }
- }
- .mdc-radio--disabled {
- @include feature-targeting.targets($feat-structure) {
- cursor: default;
- pointer-events: none;
- }
- }
- .mdc-radio__native-control:checked {
- + .mdc-radio__background {
- .mdc-radio__inner-circle {
- @include feature-targeting.targets($feat-structure) {
- transform: scale(0.5);
- }
- @include feature-targeting.targets($feat-animation) {
- transition: enter(transform), enter(border-color);
- }
- }
- }
- }
- .mdc-radio__native-control:disabled,
- [aria-disabled='true'] .mdc-radio__native-control {
- + .mdc-radio__background {
- @include feature-targeting.targets($feat-structure) {
- cursor: default;
- }
- }
- }
- .mdc-radio__native-control:focus {
- + .mdc-radio__background::before {
- @include feature-targeting.targets($feat-structure) {
- transform: scale(1);
- opacity: map.get(ripple-theme.$dark-ink-opacities, focus);
- }
- @include feature-targeting.targets($feat-animation) {
- transition: enter(opacity), enter(transform);
- }
- }
- }
- }
- // This API is intended for use by frameworks that may want to separate the ripple-related styles from the other
- // radio styles. It is recommended that most users use `mdc-radio-core-styles` instead.
- @mixin without-ripple($query: feature-targeting.all()) {
- // postcss-bem-linter: define radio
- @include touch-target-mixins.wrapper($query); // COPYBARA_COMMENT_THIS_LINE
- .mdc-radio {
- @include radio-theme.unchecked-stroke-color(
- radio-theme.$unchecked-color,
- $query: $query
- );
- @include radio-theme.checked-stroke-color(
- radio-theme.$baseline-theme-color,
- $query: $query
- );
- @include radio-theme.ink-color(
- radio-theme.$baseline-theme-color,
- $query: $query
- );
- @include radio-theme.disabled-unchecked-stroke-color(
- radio-theme.$disabled-circle-color,
- $query: $query
- );
- @include radio-theme.disabled-checked-stroke-color(
- radio-theme.$disabled-circle-color,
- $query: $query
- );
- @include radio-theme.disabled-ink-color(
- radio-theme.$disabled-circle-color,
- $query: $query
- );
- @include radio-theme.focus-indicator-color(
- radio-theme.$baseline-theme-color,
- $query: $query
- );
- @include radio-theme.density(radio-theme.$density-scale, $query: $query);
- @include dom.forced-colors-mode {
- &.mdc-radio--disabled {
- @include radio-theme.disabled-unchecked-stroke-color(
- GrayText,
- $query: $query
- );
- @include radio-theme.disabled-checked-stroke-color(
- GrayText,
- $query: $query
- );
- @include radio-theme.disabled-ink-color(GrayText, $query: $query);
- }
- }
- }
- @include static-styles($query: $query);
- // postcss-bem-linter: end
- }
- // This API is intended for use by frameworks that may want to separate the ripple-related styles from the other
- // radio styles. It is recommended that most users use `mdc-radio-core-styles` instead.
- @mixin ripple($query: feature-targeting.all()) {
- $feat-structure: feature-targeting.create-target($query, structure);
- @include ripple.common($query); // COPYBARA_COMMENT_THIS_LINE
- .mdc-radio {
- @include ripple.surface($query: $query, $ripple-target: $ripple-target);
- @include ripple.radius-unbounded(
- $query: $query,
- $ripple-target: $ripple-target
- );
- @include ripple-theme.states(
- $color: radio-theme.$baseline-theme-color,
- $query: $query,
- $ripple-target: $ripple-target
- );
- &.mdc-ripple-upgraded,
- &.mdc-ripple-upgraded--background-focused {
- .mdc-radio__background::before {
- @include feature-targeting.targets($feat-structure) {
- content: none;
- }
- }
- }
- }
- #{$ripple-target} {
- @include ripple.target-common($query: $query);
- }
- }
- @function enter($name) {
- @return animation.enter($name, radio-theme.$transition-duration);
- }
- @function exit($name) {
- @return animation.exit-temporary($name, radio-theme.$transition-duration);
- }
|