| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- //
- // Copyright 2023 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 '@material/dom/dom';
- @use '@material/elevation/mixins' as elevation-mixins;
- @use '@material/feature-targeting/feature-targeting';
- @use '@material/ripple/ripple-theme';
- @use '@material/rtl/rtl';
- @use '@material/list/mixins' as list-mixins;
- @use '@material/list/variables' as list-variables;
- @use '@material/ripple/ripple';
- @use '@material/theme/theme';
- @use '@material/theme/custom-properties';
- @use './menu-custom-properties';
- @use './variables';
- @use '@material/menu-surface/menusurface-theme';
- /// @deprecated Use static-styles() instead.
- @mixin core-styles($query: feature-targeting.all()) {
- @include static-styles($query);
- }
- @mixin static-styles($query: feature-targeting.all()) {
- $feat-color: feature-targeting.create-target($query, color);
- $feat-structure: feature-targeting.create-target($query, structure);
- @include ripple.common($query); // COPYBARA_COMMENT_THIS_LINE
- // prettier-ignore
- @include elevation-mixins.overlay-common($query); // COPYBARA_COMMENT_THIS_LINE
- // Customize the menu-surface and contained list to match the mdc-menu styles.
- .mdc-menu {
- @include list-mixins.deprecated-item-meta-ink-color(
- variables.$ink-color,
- $query
- );
- @include list-mixins.deprecated-item-graphic-ink-color(
- variables.$ink-color,
- $query
- );
- @include min-width(variables.$min-width, $query: $query);
- @include open-item-opacity(variables.$open-item-opacity, $query: $query);
- // Include mdc-deprecated-list selector to ensure list-inside-menu overrides default list styles
- .mdc-deprecated-list {
- @include list-mixins.deprecated-item-primary-text-ink-color(
- variables.$ink-color,
- $query
- );
- }
- .mdc-deprecated-list,
- .mdc-list {
- @include elevation-mixins.overlay-surface-position($query: $query);
- @include elevation-mixins.overlay-dimensions(100%, $query: $query);
- &::before {
- @include dom.transparent-border($query: $query);
- }
- }
- .mdc-deprecated-list-divider {
- @include feature-targeting.targets($feat-structure) {
- margin: 8px 0;
- }
- }
- .mdc-deprecated-list-item {
- @include feature-targeting.targets($feat-structure) {
- user-select: none;
- }
- }
- .mdc-deprecated-list-item--disabled {
- @include feature-targeting.targets($feat-structure) {
- cursor: auto;
- }
- }
- a.mdc-deprecated-list-item .mdc-deprecated-list-item__text,
- a.mdc-deprecated-list-item .mdc-deprecated-list-item__graphic {
- @include feature-targeting.targets($feat-structure) {
- pointer-events: none;
- }
- }
- }
- // postcss-bem-linter: define menu
- .mdc-menu__selection-group {
- @include feature-targeting.targets($feat-structure) {
- padding: 0;
- fill: currentColor;
- }
- .mdc-deprecated-list-item {
- @include feature-targeting.targets($feat-structure) {
- @include rtl.reflexive-property(
- padding,
- 56px,
- list-variables.$deprecated-side-padding
- );
- }
- }
- .mdc-menu__selection-group-icon {
- @include feature-targeting.targets($feat-structure) {
- @include rtl.reflexive-position(left, 16px);
- visibility: hidden;
- position: absolute;
- // IE11 requires the icon to be vertically centered due to its absolute positioning
- top: 50%;
- transform: translateY(-50%);
- // This is an instant transition with a delay that ensures the checkmark
- // appears when menu is closed. Visibility property was used on purpose to
- // indicate that there is no actual transition, but instant shift from start
- // to end state with a delay.
- transition-property: visibility;
- transition-delay: menusurface-theme.$fade-out-duration;
- }
- }
- }
- // postcss-bem-linter: end
- .mdc-menu-item--selected .mdc-menu__selection-group-icon {
- @include feature-targeting.targets($feat-structure) {
- display: inline;
- visibility: visible;
- }
- }
- }
- @mixin open-item-opacity($opacity, $query: feature-targeting.all()) {
- $feat-color: feature-targeting.create-target($query, color);
- .mdc-menu-item--submenu-open {
- @include ripple-theme.states-background-selector(
- list-variables.$deprecated-ripple-target
- ) {
- @include feature-targeting.targets($feat-color) {
- opacity: $opacity;
- }
- }
- @include ripple-theme.states-background-selector(
- list-variables.$deprecated-temporary-ripple-target
- ) {
- @include feature-targeting.targets($feat-color) {
- opacity: $opacity;
- }
- }
- }
- }
- @mixin width($width, $query: feature-targeting.all()) {
- $feat-structure: feature-targeting.create-target($query, structure);
- @include feature-targeting.targets($feat-structure) {
- @if math.is-unitless($width) {
- width: $width * variables.$width-base;
- } @else {
- width: $width;
- }
- }
- }
- /// Sets the min-width of the menu.
- /// @param {Number} $min-width - the desired min-width.
- @mixin min-width($min-width, $query: feature-targeting.all()) {
- $feat-structure: feature-targeting.create-target($query, structure);
- @include feature-targeting.targets($feat-structure) {
- $min-width-custom-property: custom-properties.create(
- menu-custom-properties.$min-width,
- $min-width
- );
- @include theme.property(min-width, $min-width-custom-property);
- }
- }
|