[6a3a178] | 1 | @use 'sass:map';
|
---|
| 2 | @use '../core/theming/theming';
|
---|
| 3 | @use '../core/typography/typography';
|
---|
| 4 | @use '../core/typography/typography-utils';
|
---|
| 5 |
|
---|
| 6 |
|
---|
| 7 | @mixin color($config-or-theme) {
|
---|
| 8 | $config: theming.get-color-config($config-or-theme);
|
---|
| 9 | $is-dark-theme: map.get($config, is-dark);
|
---|
| 10 | $primary: map.get($config, primary);
|
---|
| 11 | $accent: map.get($config, accent);
|
---|
| 12 | $warn: map.get($config, warn);
|
---|
| 13 | $background: map.get($config, background);
|
---|
| 14 | $foreground: map.get($config, foreground);
|
---|
| 15 |
|
---|
| 16 |
|
---|
| 17 | // The color of the checkbox's checkmark / mixedmark.
|
---|
| 18 | $checkbox-mark-color: theming.get-color-from-palette($background, background);
|
---|
| 19 |
|
---|
| 20 | // NOTE(traviskaufman): While the spec calls for translucent blacks/whites for disabled colors,
|
---|
| 21 | // this does not work well with elements layered on top of one another. To get around this we
|
---|
| 22 | // blend the colors together based on the base color and the theme background.
|
---|
| 23 | $white-30pct-opacity-on-dark: #686868;
|
---|
| 24 | $black-26pct-opacity-on-light: #b0b0b0;
|
---|
| 25 | $disabled-color: if($is-dark-theme, $white-30pct-opacity-on-dark, $black-26pct-opacity-on-light);
|
---|
| 26 |
|
---|
| 27 | .mat-checkbox-frame {
|
---|
| 28 | border-color: theming.get-color-from-palette($foreground, secondary-text);
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | .mat-checkbox-checkmark {
|
---|
| 32 | fill: $checkbox-mark-color;
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | .mat-checkbox-checkmark-path {
|
---|
| 36 | // !important is needed here because a stroke must be set as an
|
---|
| 37 | // attribute on the SVG in order for line animation to work properly.
|
---|
| 38 | stroke: $checkbox-mark-color !important;
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | .mat-checkbox-mixedmark {
|
---|
| 42 | background-color: $checkbox-mark-color;
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | .mat-checkbox-indeterminate, .mat-checkbox-checked {
|
---|
| 46 | &.mat-primary .mat-checkbox-background {
|
---|
| 47 | background-color: theming.get-color-from-palette($primary);
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | &.mat-accent .mat-checkbox-background {
|
---|
| 51 | background-color: theming.get-color-from-palette($accent);
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | &.mat-warn .mat-checkbox-background {
|
---|
| 55 | background-color: theming.get-color-from-palette($warn);
|
---|
| 56 | }
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | .mat-checkbox-disabled {
|
---|
| 60 | &.mat-checkbox-checked,
|
---|
| 61 | &.mat-checkbox-indeterminate {
|
---|
| 62 | .mat-checkbox-background {
|
---|
| 63 | background-color: $disabled-color;
|
---|
| 64 | }
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | &:not(.mat-checkbox-checked) {
|
---|
| 68 | .mat-checkbox-frame {
|
---|
| 69 | border-color: $disabled-color;
|
---|
| 70 | }
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | .mat-checkbox-label {
|
---|
| 74 | color: theming.get-color-from-palette($foreground, secondary-text);
|
---|
| 75 | }
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | // Switch this to a solid color since we're using `opacity`
|
---|
| 79 | // to control how opaque the ripple should be.
|
---|
| 80 | .mat-checkbox .mat-ripple-element {
|
---|
| 81 | background-color: map.get(map.get($config, foreground), base);
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | .mat-checkbox-checked:not(.mat-checkbox-disabled),
|
---|
| 85 | .mat-checkbox:active:not(.mat-checkbox-disabled) {
|
---|
| 86 | &.mat-primary .mat-ripple-element {
|
---|
| 87 | background: theming.get-color-from-palette($primary);
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | &.mat-accent .mat-ripple-element {
|
---|
| 91 | background: theming.get-color-from-palette($accent);
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | &.mat-warn .mat-ripple-element {
|
---|
| 95 | background: theming.get-color-from-palette($warn);
|
---|
| 96 | }
|
---|
| 97 | }
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | @mixin typography($config-or-theme) {
|
---|
| 101 | $config: typography.private-typography-to-2014-config(
|
---|
| 102 | theming.get-typography-config($config-or-theme));
|
---|
| 103 | .mat-checkbox {
|
---|
| 104 | font-family: typography-utils.font-family($config);
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | // TODO(kara): Remove this style when fixing vertical baseline
|
---|
| 108 | .mat-checkbox-layout .mat-checkbox-label {
|
---|
| 109 | line-height: typography-utils.line-height($config, body-2);
|
---|
| 110 | }
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | @mixin _density($config-or-theme) {}
|
---|
| 114 |
|
---|
| 115 | @mixin theme($theme-or-color-config) {
|
---|
| 116 | $theme: theming.private-legacy-get-theme($theme-or-color-config);
|
---|
| 117 | @include theming.private-check-duplicate-theme-styles($theme, 'mat-checkbox') {
|
---|
| 118 | $color: theming.get-color-config($theme);
|
---|
| 119 | $density: theming.get-density-config($theme);
|
---|
| 120 | $typography: theming.get-typography-config($theme);
|
---|
| 121 |
|
---|
| 122 | @if $color != null {
|
---|
| 123 | @include color($color);
|
---|
| 124 | }
|
---|
| 125 | @if $density != null {
|
---|
| 126 | @include _density($density);
|
---|
| 127 | }
|
---|
| 128 | @if $typography != null {
|
---|
| 129 | @include typography($typography);
|
---|
| 130 | }
|
---|
| 131 | }
|
---|
| 132 | }
|
---|