Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
feat(select): do not emit styles when calling theme-styles(()).
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 489980365
  • Loading branch information
codr authored and copybara-github committed Nov 21, 2022
1 parent 96f4726 commit 18b8f31
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 12 deletions.
14 changes: 8 additions & 6 deletions packages/mdc-select/_select-shared-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@
@function _resolve-theme-elevation($theme, $resolver) {
$elevation: map.get($theme, menu-container-elevation);
$shadow-color: map.get($theme, menu-container-shadow-color);
$resolved-value: meta.call(
$resolver,
$elevation: $elevation,
$shadow-color: $shadow-color
);
$theme: map.set($theme, menu-container-elevation, $resolved-value);
@if $elevation and $shadow-color {
$resolved-value: meta.call(
$resolver,
$elevation: $elevation,
$shadow-color: $shadow-color
);
$theme: map.set($theme, menu-container-elevation, $resolved-value);
}
@return $theme;
}
17 changes: 11 additions & 6 deletions packages/mdc-select/_select-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -707,11 +707,13 @@ $_light-theme: (
}

@mixin _menu-container-elevation($elevation) {
.mdc-select__menu {
@include elevation-theme.shadow(map.get($elevation, shadow));
@include elevation-theme.overlay-opacity(
map.get($elevation, overlay-opacity)
);
@if $elevation {
.mdc-select__menu {
@include elevation-theme.shadow(map.get($elevation, shadow));
@include elevation-theme.overlay-opacity(
map.get($elevation, overlay-opacity)
);
}
}
}

Expand Down Expand Up @@ -975,7 +977,10 @@ $_light-theme: (
$query: feature-targeting.all()
) {
@if (meta.type-of($radius) == 'list' and list.length($radius) > 2) and
(list.nth($radius, 3) != 0 or list.nth($radius, 4) != 0)
(
(list.nth($radius, 3) != 0 and list.nth($radius, 3) != 0px) or
(list.nth($radius, 4) != 0 and list.nth($radius, 4) != 0px)
)
{
@error "mdc-select: Invalid radius #{$radius}. Only top-left and top-right corners may be customized.";
}
Expand Down
37 changes: 37 additions & 0 deletions packages/mdc-select/test/select-theme.test.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@use 'third_party/javascript/material_components_web/tokens/v0_132/' as tokens;
@use 'true' as test;

@use '../select-filled-theme';
@use '../select-outlined-theme';

@include test.describe('select-filled-theme') {
@include test.describe('theme-styles()') {
@include test.it('return no styles when no theme is provided') {
@include test.assert {
@include test.output {
@include select-filled-theme.theme-styles(());
}

@include test.expect {
// No content. This is testing that an error isn't thrown.
}
}
}
}
}

@include test.describe('select-outlined-theme') {
@include test.describe('theme-styles()') {
@include test.it('return no styles when no theme is provided') {
@include test.assert {
@include test.output {
@include select-outlined-theme.theme-styles(());
}

@include test.expect {
// No content. This is testing that an error isn't thrown.
}
}
}
}
}

0 comments on commit 18b8f31

Please sign in to comment.