| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523 |
- //
- // Copyright 2017 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:math';
- @use 'sass:list';
- @use 'sass:meta';
- @use '@material/feature-targeting/feature-targeting';
- @use '@material/animation/functions' as functions2;
- @use '@material/animation/variables' as animation-variables;
- @use '@material/rtl/rtl';
- @use '@material/typography/typography';
- @use '@material/theme/theme';
- @use '@material/theme/theme-color';
- @use '@material/list/mixins' as list-mixins;
- @use '@material/ripple/ripple-theme';
- @use '@material/shape/mixins' as shape-mixins;
- @use '@material/elevation/mixins' as elevation-mixins;
- @use './variables';
- //
- // Public
- //
- @mixin core-styles($query: feature-targeting.all()) {
- $feat-structure: feature-targeting.create-target($query, structure);
- $feat-animation: feature-targeting.create-target($query, animation);
- // postcss-bem-linter: define drawer
- .mdc-drawer {
- @include title-ink-color(variables.$title-ink-color, $query: $query);
- @include subtitle-ink-color(variables.$subtitle-ink-color, $query: $query);
- @include border-color(variables.$divider-color, $query: $query);
- @include surface-fill-color(variables.$surface-fill-color, $query: $query);
- @include item-icon-ink-color(
- variables.$item-inactive-ink-color,
- $query: $query
- );
- @include item-text-ink-color(
- variables.$item-inactive-ink-color,
- $query: $query
- );
- @include item-activated-icon-ink-color(
- variables.$item-activated-ink-color,
- $query: $query
- );
- @include item-activated-text-ink-color(
- variables.$item-activated-ink-color,
- $query: $query
- );
- @include shape-radius(variables.$shape-radius, $query: $query);
- @include item-shape-radius(variables.$item-shape-radius, $query: $query);
- @include z-index(variables.$z-index, $query: $query);
- @include width(variables.$width, $query: $query);
- @include feature-targeting.targets($feat-structure) {
- display: flex;
- flex-direction: column;
- flex-shrink: 0;
- box-sizing: border-box;
- height: 100%;
- @include rtl.ignore-next-line();
- border-right-width: 1px;
- @include rtl.ignore-next-line();
- border-right-style: solid;
- overflow: hidden;
- @include rtl.rtl {
- @include rtl.ignore-next-line();
- border-right-width: 0;
- @include rtl.ignore-next-line();
- border-left-width: 1px;
- @include rtl.ignore-next-line();
- border-right-style: none;
- @include rtl.ignore-next-line();
- border-left-style: solid;
- }
- }
- @include feature-targeting.targets($feat-animation) {
- transition-property: transform;
- transition-timing-function: animation-variables.$standard-curve-timing-function;
- }
- @include list-item_($query);
- }
- .mdc-drawer--animate {
- @include feature-targeting.targets($feat-structure) {
- transform: translateX(-100%);
- @include rtl.rtl {
- transform: translateX(100%);
- }
- }
- }
- .mdc-drawer--opening {
- @include feature-targeting.targets($feat-structure) {
- transform: translateX(0);
- // Required to level the specificity with animate class.
- @include rtl.rtl {
- transform: translateX(0);
- }
- }
- @include feature-targeting.targets($feat-animation) {
- transition-duration: variables.$animation-enter;
- }
- }
- .mdc-drawer--closing {
- @include feature-targeting.targets($feat-structure) {
- transform: translateX(-100%);
- @include rtl.rtl {
- transform: translateX(100%);
- }
- }
- @include feature-targeting.targets($feat-animation) {
- transition-duration: variables.$animation-exit;
- }
- }
- .mdc-drawer__header {
- @include feature-targeting.targets($feat-structure) {
- flex-shrink: 0;
- box-sizing: border-box;
- min-height: 64px; // same as $mdc-top-app-bar-row-height
- padding: 0 variables.$surface-padding 4px;
- }
- }
- .mdc-drawer__title {
- @include typography.typography(headline6, $query: $query);
- @include typography.text-baseline(
- $top: 36px,
- $bottom: 20px,
- $query: $query
- );
- }
- .mdc-drawer__subtitle {
- @include typography.typography(body2, $query: $query);
- @include typography.text-baseline($top: 20px, $query: $query);
- @include feature-targeting.targets($feat-structure) {
- margin-bottom: 0;
- }
- }
- .mdc-drawer__content {
- @include feature-targeting.targets($feat-structure) {
- height: 100%;
- overflow-y: auto;
- -webkit-overflow-scrolling: touch;
- }
- }
- // postcss-bem-linter: end
- }
- @mixin dismissible-core-styles($query: feature-targeting.all()) {
- $feat-structure: feature-targeting.create-target($query, structure);
- .mdc-drawer--dismissible {
- @include feature-targeting.targets($feat-structure) {
- @include rtl.reflexive-position(left, 0);
- display: none;
- position: absolute;
- &.mdc-drawer--open {
- display: flex;
- }
- }
- }
- .mdc-drawer-app-content {
- @include feature-targeting.targets($feat-structure) {
- @include rtl.reflexive-box(margin, left, 0);
- position: relative;
- }
- }
- }
- @mixin modal-core-styles($query: feature-targeting.all()) {
- $feat-structure: feature-targeting.create-target($query, structure);
- $feat-animation: feature-targeting.create-target($query, animation);
- .mdc-drawer--modal {
- @include scrim-fill-color(variables.$modal-scrim-color, $query: $query);
- @include elevation-mixins.elevation(
- variables.$modal-elevation,
- $query: $query
- );
- @include feature-targeting.targets($feat-structure) {
- @include rtl.reflexive-position(left, 0);
- display: none;
- position: fixed;
- }
- &.mdc-drawer--open {
- @include feature-targeting.targets($feat-structure) {
- display: flex;
- }
- }
- }
- .mdc-drawer-scrim {
- @include feature-targeting.targets($feat-structure) {
- display: none;
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- z-index: variables.$z-index - 1;
- }
- @include feature-targeting.targets($feat-animation) {
- transition-property: opacity;
- transition-timing-function: animation-variables.$standard-curve-timing-function;
- }
- .mdc-drawer--open + & {
- @include feature-targeting.targets($feat-structure) {
- display: block;
- }
- }
- .mdc-drawer--animate + & {
- @include feature-targeting.targets($feat-structure) {
- opacity: 0;
- }
- }
- .mdc-drawer--opening + & {
- @include feature-targeting.targets($feat-animation) {
- transition-duration: variables.$animation-enter;
- }
- @include feature-targeting.targets($feat-structure) {
- opacity: 1;
- }
- }
- .mdc-drawer--closing + & {
- @include feature-targeting.targets($feat-animation) {
- transition-duration: variables.$animation-exit;
- }
- @include feature-targeting.targets($feat-structure) {
- opacity: 0;
- }
- }
- }
- }
- @mixin activated-overlay-color($color, $query: feature-targeting.all()) {
- :not(.mdc-deprecated-list--non-interactive) > .mdc-deprecated-list-item {
- @include ripple-theme.states-activated($color, $query: $query);
- }
- }
- @mixin border-color($color, $query: feature-targeting.all()) {
- $feat-color: feature-targeting.create-target($query, color);
- $value: rgba(theme-color.prop-value($color), variables.$divider-opacity);
- @include feature-targeting.targets($feat-color) {
- @include theme.property(border-color, $value);
- }
- }
- @mixin item-shape-radius(
- $radius,
- $rtl-reflexive: true,
- $query: feature-targeting.all()
- ) {
- @include list-mixins.deprecated-single-line-shape-radius(
- $radius,
- $rtl-reflexive,
- $query: $query
- );
- }
- @mixin shape-radius($radius, $query: feature-targeting.all()) {
- // Check type since $radius may be a custom property Map
- $is-list: meta.type-of($radius) == 'list';
- @if $is-list and list.length($radius) > 2 {
- @error "Invalid radius: '#{$radius}' component doesn't allow customizing all corners";
- } @else if $is-list and list.length($radius) == 2 {
- $radius: 0 list.nth($radius, 1) list.nth($radius, 2) 0;
- } @else {
- $radius: 0 $radius $radius 0;
- }
- @include shape-mixins.radius($radius, $rtl-reflexive: true, $query: $query);
- }
- @mixin divider-color($color, $query: feature-targeting.all()) {
- $value: rgba(theme-color.prop-value($color), variables.$divider-opacity);
- @include list-mixins.deprecated-divider-color($value, $query: $query);
- }
- @mixin title-ink-color($color, $query: feature-targeting.all()) {
- $feat-color: feature-targeting.create-target($query, color);
- $value: rgba(theme-color.prop-value($color), variables.$title-ink-opacity);
- .mdc-drawer__title {
- @include feature-targeting.targets($feat-color) {
- @include theme.property(color, $value);
- }
- }
- }
- @mixin subtitle-ink-color($color, $query: feature-targeting.all()) {
- $feat-color: feature-targeting.create-target($query, color);
- $value: rgba(theme-color.prop-value($color), variables.$subtitle-ink-opacity);
- @include list-mixins.deprecated-group-subheader-ink-color(
- $value,
- $query: $query
- );
- .mdc-drawer__subtitle {
- @include feature-targeting.targets($feat-color) {
- @include theme.property(color, $value);
- }
- }
- }
- @mixin fill-color-accessible($color, $query: feature-targeting.all()) {
- $accessibleColor: theme-color.accessible-ink-color($color);
- @include title-ink-color($accessibleColor, $query: $query);
- @include subtitle-ink-color($accessibleColor, $query: $query);
- @include item-text-ink-color($accessibleColor, $query: $query);
- @include item-icon-ink-color($accessibleColor, $query: $query);
- @include surface-fill-color($color, $query: $query);
- }
- @mixin item-icon-ink-color($color, $query: feature-targeting.all()) {
- $value: rgba(
- theme-color.prop-value($color),
- variables.$item-inactive-icon-ink-opacity
- );
- @include list-mixins.deprecated-item-graphic-ink-color(
- $value,
- $query: $query
- );
- }
- @mixin item-activated-icon-ink-color($color, $query: feature-targeting.all()) {
- $value: rgba(
- theme-color.prop-value($color),
- variables.$item-active-icon-ink-opacity
- );
- .mdc-deprecated-list-item--activated {
- @include list-mixins.deprecated-item-graphic-ink-color(
- $value,
- $query: $query
- );
- }
- }
- @mixin item-activated-text-ink-color($color, $query: feature-targeting.all()) {
- $value: rgba(
- theme-color.prop-value($color),
- variables.$item-active-text-ink-opacity
- );
- .mdc-deprecated-list-item--activated {
- @include list-mixins.deprecated-item-primary-text-ink-color(
- $value,
- $query: $query
- );
- }
- }
- @mixin item-text-ink-color($color, $query: feature-targeting.all()) {
- $value: rgba(
- theme-color.prop-value($color),
- variables.$item-inactive-text-ink-opacity
- );
- .mdc-deprecated-list-item {
- @include list-mixins.deprecated-item-primary-text-ink-color(
- $value,
- $query: $query
- );
- }
- }
- @mixin surface-fill-color($color, $query: feature-targeting.all()) {
- $feat-color: feature-targeting.create-target($query, color);
- @include feature-targeting.targets($feat-color) {
- @include theme.property(background-color, $color);
- }
- }
- @mixin scrim-fill-color($color, $query: feature-targeting.all()) {
- $feat-color: feature-targeting.create-target($query, color);
- $value: rgba(theme-color.prop-value($color), variables.$modal-scrim-opacity);
- + .mdc-drawer-scrim {
- @include feature-targeting.targets($feat-color) {
- @include theme.property(background-color, $value);
- }
- }
- }
- @mixin z-index($value, $query: feature-targeting.all()) {
- $feat-structure: feature-targeting.create-target($query, structure);
- @include feature-targeting.targets($feat-structure) {
- z-index: $value;
- }
- }
- @mixin width($width, $query: feature-targeting.all()) {
- $feat-structure: feature-targeting.create-target($query, structure);
- @include feature-targeting.targets($feat-structure) {
- @include theme.property(width, $width);
- }
- &.mdc-drawer--open:not(.mdc-drawer--closing) + .mdc-drawer-app-content {
- @include feature-targeting.targets($feat-structure) {
- @include rtl.reflexive-box(margin, left, $width);
- }
- }
- }
- //
- // Private
- //
- @mixin list-item_($query: feature-targeting.all()) {
- $feat-structure: feature-targeting.create-target($query, structure);
- // postcss-bem-linter: ignore
- .mdc-deprecated-list-item {
- @include typography.typography(subtitle2, $query: $query);
- @include feature-targeting.targets($feat-structure) {
- height: calc(48px - 2 * #{variables.$list-item-spacing});
- // To accomodate margin conflict.
- margin: (variables.$list-item-spacing * 2) 8px;
- padding: 0 math.div(variables.$surface-padding, 2);
- }
- }
- // postcss-bem-linter: ignore
- .mdc-deprecated-list-item:nth-child(1) {
- @include feature-targeting.targets($feat-structure) {
- margin-top: 2px;
- }
- }
- // postcss-bem-linter: ignore
- .mdc-deprecated-list-item:nth-last-child(1) {
- @include feature-targeting.targets($feat-structure) {
- margin-bottom: 0;
- }
- }
- // postcss-bem-linter: ignore
- .mdc-deprecated-list-group__subheader {
- @include typography.typography(body2, $query: $query);
- @include typography.text-baseline($top: 24px, $query: $query);
- @include feature-targeting.targets($feat-structure) {
- margin: 0;
- padding: 0 variables.$surface-padding;
- }
- }
- // postcss-bem-linter: ignore
- .mdc-deprecated-list-divider {
- @include feature-targeting.targets($feat-structure) {
- margin: 3px 0 4px;
- }
- }
- // Prevents list item children from being included in the click target.
- // postcss-bem-linter: ignore
- .mdc-deprecated-list-item__text,
- .mdc-deprecated-list-item__graphic {
- @include feature-targeting.targets($feat-structure) {
- pointer-events: none;
- }
- }
- }
|