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

Commit

Permalink
feat(color): Add on-surface and surface to theme. (#2556)
Browse files Browse the repository at this point in the history
Adds new variables, properties and classes for "surface" and "on-surface" colors. Refer to the documentation for information and examples.
  • Loading branch information
williamernest authored Apr 18, 2018
1 parent 777a0fd commit 9639689
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 14 deletions.
4 changes: 3 additions & 1 deletion packages/mdc-card/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@
// limitations under the License.
//

$mdc-card-stroke-color: #dbdbdb;
@import "@material/theme/mixins";

$mdc-card-stroke-color: mix(mdc-theme-prop-value(on-surface), mdc-theme-prop-value(surface), 12%);
$mdc-card-stroke-width: 1px;
2 changes: 1 addition & 1 deletion packages/mdc-card/mdc-card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// postcss-bem-linter: define card

.mdc-card {
@include mdc-card-fill-color(background);
@include mdc-card-fill-color(surface);
@include mdc-card-corner-radius(2px);
@include mdc-elevation(2);
@include mdc-card-container-layout_;
Expand Down
12 changes: 7 additions & 5 deletions packages/mdc-chips/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@
// limitations under the License.
//

@import "@material/theme/variables";

$mdc-chip-border-radius-default: 16px;
$mdc-chip-fill-color-default: rgba(black, .08);
$mdc-chip-ink-color-default: rgba(black, .6);
$mdc-chip-fill-color-default: rgba(mdc-theme-prop-value(on-surface), .12);
$mdc-chip-ink-color-default: rgba(mdc-theme-prop-value(on-surface), .87);
$mdc-chip-horizontal-padding: 12px;
$mdc-chip-vertical-padding: 7px;

$mdc-chip-icon-color: rgba(black, .54);
$mdc-chip-icon-color: rgba(mdc-theme-prop-value(on-surface), .54);
$mdc-chip-trailing-icon-size: 18px;
$mdc-chip-trailing-icon-hover-color: rgba(black, .62);
$mdc-chip-trailing-icon-focus-color: rgba(black, .87);
$mdc-chip-trailing-icon-hover-color: rgba(mdc-theme-prop-value(on-surface), .62);
$mdc-chip-trailing-icon-focus-color: rgba(mdc-theme-prop-value(on-surface), .87);

$mdc-chip-checkmark-animation-delay: 50ms;
$mdc-chip-checkmark-animation-duration: 150ms;
Expand Down
2 changes: 1 addition & 1 deletion packages/mdc-chips/chip/mdc-chip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
}

.mdc-chip--selected {
@include mdc-theme-prop(background-color, white);
@include mdc-theme-prop(background-color, surface);
}

.mdc-chip__text {
Expand Down
6 changes: 6 additions & 0 deletions packages/mdc-theme/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ $mdc-theme-secondary: $mdc-theme-accent !default;
$mdc-theme-on-secondary: if(mdc-theme-contrast-tone($mdc-theme-secondary) == "dark", #000, #fff) !default;
$mdc-theme-background: #fff !default; // White

$mdc-theme-surface: #fff !default;
$mdc-theme-on-surface: if(mdc-theme-contrast-tone($mdc-theme-surface) == "dark", #000, #fff) !default;

//
// Text colors according to light vs dark and text type.
//
Expand Down Expand Up @@ -70,8 +73,11 @@ $mdc-theme-property-values: (
secondary: $mdc-theme-secondary,
/* Background */
background: $mdc-theme-background,
/* Surface */
surface: $mdc-theme-surface,
on-primary: $mdc-theme-on-primary,
on-secondary: $mdc-theme-on-secondary,
on-surface: $mdc-theme-on-surface,
// Text-primary on "background" background
text-primary-on-background: mdc-theme-ink-color-for-fill_(primary, $mdc-theme-background),
text-secondary-on-background: mdc-theme-ink-color-for-fill_(secondary, $mdc-theme-background),
Expand Down
11 changes: 5 additions & 6 deletions packages/mdc-theme/mdc-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@
}
}

// Special case, so that .mdc-theme--background changes background color, not text color.
.mdc-theme--background {
@include mdc-theme-prop(background-color, background);
}

@each $style in map-keys($mdc-theme-property-values) {
@if $style != "background" {
@if $style != "background" and $style != "surface" {
.mdc-theme--#{$style} {
@include mdc-theme-prop(color, $style, true);
}
} @else {
.mdc-theme--#{$style} {
@include mdc-theme-prop(background-color, $style);
}
}
}

Expand Down

0 comments on commit 9639689

Please sign in to comment.