|
1 | 1 | /* You can add global styles to this file, and also import other style files */
|
| 2 | +@use "sass:map"; |
| 3 | +@use "@angular/material" as mat; |
| 4 | +@use "@angular/material-experimental" as matx; |
| 5 | + |
| 6 | +@mixin color-variant-styles($theme, $color-variant) { |
| 7 | + @include mat.option-color($theme, $color-variant: $color-variant); |
| 8 | + @include mat.progress-spinner-color($theme, $color-variant: $color-variant); |
| 9 | + @include mat.pseudo-checkbox-color($theme, $color-variant: $color-variant); |
| 10 | + |
| 11 | + &.mat-icon { |
| 12 | + @include mat.icon-color($theme, $color-variant: $color-variant); |
| 13 | + } |
| 14 | + |
| 15 | + &.mat-mdc-checkbox { |
| 16 | + @include mat.checkbox-color($theme, $color-variant: $color-variant); |
| 17 | + } |
| 18 | + |
| 19 | + &.mat-mdc-slider { |
| 20 | + @include mat.slider-color($theme, $color-variant: $color-variant); |
| 21 | + } |
| 22 | + |
| 23 | + &.mat-mdc-tab-group, |
| 24 | + &.mat-mdc-tab-nav-bar { |
| 25 | + @include mat.tabs-color($theme, $color-variant: $color-variant); |
| 26 | + } |
| 27 | + |
| 28 | + &.mat-mdc-slide-toggle { |
| 29 | + @include mat.slide-toggle-color($theme, $color-variant: $color-variant); |
| 30 | + } |
| 31 | + |
| 32 | + &.mat-mdc-form-field { |
| 33 | + @include mat.select-color($theme, $color-variant: $color-variant); |
| 34 | + } |
| 35 | + |
| 36 | + &.mat-mdc-radio-button { |
| 37 | + @include mat.radio-color($theme, $color-variant: $color-variant); |
| 38 | + } |
| 39 | + |
| 40 | + &.mat-mdc-progress-bar { |
| 41 | + @include mat.progress-bar-color($theme, $color-variant: $color-variant); |
| 42 | + } |
| 43 | + |
| 44 | + &.mat-mdc-form-field { |
| 45 | + @include mat.form-field-color($theme, $color-variant: $color-variant); |
| 46 | + } |
| 47 | + |
| 48 | + &.mat-datepicker-content { |
| 49 | + @include mat.datepicker-color($theme, $color-variant: $color-variant); |
| 50 | + } |
| 51 | + |
| 52 | + &.mat-mdc-button-base { |
| 53 | + @include mat.button-color($theme, $color-variant: $color-variant); |
| 54 | + } |
| 55 | + |
| 56 | + &.mat-mdc-standard-chip { |
| 57 | + @include mat.chips-color($theme, $color-variant: $color-variant); |
| 58 | + } |
| 59 | + |
| 60 | + .mdc-list-item__start, |
| 61 | + .mdc-list-item__end { |
| 62 | + @include mat.checkbox-color($theme, $color-variant: $color-variant); |
| 63 | + @include mat.radio-color($theme, $color-variant: $color-variant); |
| 64 | + } |
| 65 | + |
| 66 | + // M3 dropped support for warn/error color FABs. |
| 67 | + @if $color-variant != error { |
| 68 | + &.mat-mdc-fab, |
| 69 | + &.mat-mdc-mini-fab { |
| 70 | + @include mat.fab-color($theme, $color-variant: $color-variant); |
| 71 | + } |
| 72 | + } |
| 73 | +} |
| 74 | + |
| 75 | +// TODO(mmalerba): Consider adding this as a back-compat API for users who want it, rather than just |
| 76 | +// a demo thing. |
| 77 | +@mixin color-variants-back-compat($theme) { |
| 78 | + .mat-primary { |
| 79 | + @include color-variant-styles($theme, primary); |
| 80 | + } |
| 81 | + .mat-badge { |
| 82 | + @include mat.badge-color($theme, $color-variant: primary); |
| 83 | + } |
| 84 | + |
| 85 | + .mat-accent { |
| 86 | + @include color-variant-styles($theme, secondary); |
| 87 | + } |
| 88 | + .mat-badge-accent { |
| 89 | + @include mat.badge-color($theme, $color-variant: secondary); |
| 90 | + } |
| 91 | + |
| 92 | + .mat-warn { |
| 93 | + @include color-variant-styles($theme, error); |
| 94 | + } |
| 95 | + .mat-badge-warn { |
| 96 | + @include mat.badge-color($theme, $color-variant: error); |
| 97 | + } |
| 98 | +} |
| 99 | + |
| 100 | +// Emit Angular Material core styles. |
| 101 | +@include mat.core(); |
| 102 | + |
| 103 | +// Base theme configuration for our M3 theme. |
| 104 | +$m3-base-config: ( |
| 105 | + color: ( |
| 106 | + primary: matx.$m3-green-palette, |
| 107 | + secondary: matx.$m3-blue-palette, |
| 108 | + tertiary: matx.$m3-yellow-palette, |
| 109 | + ), |
| 110 | +); |
| 111 | + |
| 112 | +// Our M3 light theme. |
| 113 | +$light-theme: matx.define-theme($m3-base-config); |
| 114 | + |
| 115 | +// Our M3 dark theme. |
| 116 | +$dark-theme: matx.define-theme( |
| 117 | + map.set($m3-base-config, color, theme-type, dark) |
| 118 | +); |
| 119 | + |
| 120 | +// Emit default theme styles. |
| 121 | +html { |
| 122 | + @include mat.autocomplete-theme($light-theme); |
| 123 | + @include mat.badge-theme($light-theme); |
| 124 | + @include mat.bottom-sheet-theme($light-theme); |
| 125 | + @include mat.button-theme($light-theme); |
| 126 | + @include mat.button-toggle-theme($light-theme); |
| 127 | + @include mat.card-theme($light-theme); |
| 128 | + @include mat.checkbox-theme($light-theme); |
| 129 | + @include mat.chips-theme($light-theme); |
| 130 | + @include mat.core-theme($light-theme); |
| 131 | + @include mat.datepicker-theme($light-theme); |
| 132 | + @include mat.dialog-theme($light-theme); |
| 133 | + @include mat.divider-theme($light-theme); |
| 134 | + @include mat.expansion-theme($light-theme); |
| 135 | + @include mat.fab-theme($light-theme); |
| 136 | + @include mat.form-field-theme($light-theme); |
| 137 | + @include mat.grid-list-theme($light-theme); |
| 138 | + @include mat.icon-button-theme($light-theme); |
| 139 | + @include mat.icon-theme($light-theme); |
| 140 | + @include mat.input-theme($light-theme); |
| 141 | + @include mat.list-theme($light-theme); |
| 142 | + @include mat.menu-theme($light-theme); |
| 143 | + @include mat.paginator-theme($light-theme); |
| 144 | + @include mat.progress-bar-theme($light-theme); |
| 145 | + @include mat.progress-spinner-theme($light-theme); |
| 146 | + @include mat.radio-theme($light-theme); |
| 147 | + @include mat.select-theme($light-theme); |
| 148 | + @include mat.sidenav-theme($light-theme); |
| 149 | + @include mat.slide-toggle-theme($light-theme); |
| 150 | + @include mat.slider-theme($light-theme); |
| 151 | + @include mat.snack-bar-theme($light-theme); |
| 152 | + @include mat.sort-theme($light-theme); |
| 153 | + @include mat.stepper-theme($light-theme); |
| 154 | + @include mat.table-theme($light-theme); |
| 155 | + @include mat.tabs-theme($light-theme); |
| 156 | + @include mat.toolbar-theme($light-theme); |
| 157 | + @include mat.tooltip-theme($light-theme); |
| 158 | + @include mat.tree-theme($light-theme); |
| 159 | +} |
| 160 | + |
| 161 | +@include color-variants-back-compat($light-theme); |
| 162 | + |
| 163 | +// Emit dark theme styles. |
| 164 | +.dark { |
| 165 | + background: black; |
| 166 | + color: white; |
| 167 | + |
| 168 | + @include mat.autocomplete-color($dark-theme); |
| 169 | + @include mat.badge-color($dark-theme); |
| 170 | + @include mat.bottom-sheet-color($dark-theme); |
| 171 | + @include mat.button-color($dark-theme); |
| 172 | + @include mat.button-toggle-color($dark-theme); |
| 173 | + @include mat.card-color($dark-theme); |
| 174 | + @include mat.checkbox-color($dark-theme); |
| 175 | + @include mat.chips-color($dark-theme); |
| 176 | + @include mat.core-color($dark-theme); |
| 177 | + @include mat.datepicker-color($dark-theme); |
| 178 | + @include mat.dialog-color($dark-theme); |
| 179 | + @include mat.divider-color($dark-theme); |
| 180 | + @include mat.expansion-color($dark-theme); |
| 181 | + @include mat.fab-color($dark-theme); |
| 182 | + @include mat.form-field-color($dark-theme); |
| 183 | + @include mat.grid-list-color($dark-theme); |
| 184 | + @include mat.icon-button-color($dark-theme); |
| 185 | + @include mat.icon-color($dark-theme); |
| 186 | + @include mat.input-color($dark-theme); |
| 187 | + @include mat.list-color($dark-theme); |
| 188 | + @include mat.menu-color($dark-theme); |
| 189 | + @include mat.paginator-color($dark-theme); |
| 190 | + @include mat.progress-bar-color($dark-theme); |
| 191 | + @include mat.progress-spinner-color($dark-theme); |
| 192 | + @include mat.radio-color($dark-theme); |
| 193 | + @include mat.select-color($dark-theme); |
| 194 | + @include mat.sidenav-color($dark-theme); |
| 195 | + @include mat.slide-toggle-color($dark-theme); |
| 196 | + @include mat.slider-color($dark-theme); |
| 197 | + @include mat.snack-bar-color($dark-theme); |
| 198 | + @include mat.sort-color($dark-theme); |
| 199 | + @include mat.stepper-color($dark-theme); |
| 200 | + @include mat.table-color($dark-theme); |
| 201 | + @include mat.tabs-color($dark-theme); |
| 202 | + @include mat.toolbar-color($dark-theme); |
| 203 | + @include mat.tooltip-color($dark-theme); |
| 204 | + @include mat.tree-color($dark-theme); |
| 205 | + |
| 206 | + @include color-variants-back-compat($dark-theme); |
| 207 | +} |
| 208 | + |
| 209 | +// Emit density styles for each scale. |
| 210 | +@each $scale in (maximum, 0, -1, -2, -3, -4, minimum) { |
| 211 | + $scale-theme: matx.define-theme( |
| 212 | + map.set($m3-base-config, density, scale, $scale) |
| 213 | + ); |
| 214 | + |
| 215 | + .density-#{$scale} { |
| 216 | + @include mat.autocomplete-density($scale-theme); |
| 217 | + @include mat.badge-density($scale-theme); |
| 218 | + @include mat.bottom-sheet-density($scale-theme); |
| 219 | + @include mat.button-density($scale-theme); |
| 220 | + @include mat.button-toggle-density($scale-theme); |
| 221 | + @include mat.card-density($scale-theme); |
| 222 | + @include mat.checkbox-density($scale-theme); |
| 223 | + @include mat.chips-density($scale-theme); |
| 224 | + @include mat.core-density($scale-theme); |
| 225 | + @include mat.datepicker-density($scale-theme); |
| 226 | + @include mat.dialog-density($scale-theme); |
| 227 | + @include mat.divider-density($scale-theme); |
| 228 | + @include mat.expansion-density($scale-theme); |
| 229 | + @include mat.fab-density($scale-theme); |
| 230 | + @include mat.form-field-density($scale-theme); |
| 231 | + @include mat.grid-list-density($scale-theme); |
| 232 | + @include mat.icon-button-density($scale-theme); |
| 233 | + @include mat.icon-density($scale-theme); |
| 234 | + @include mat.input-density($scale-theme); |
| 235 | + @include mat.list-density($scale-theme); |
| 236 | + @include mat.menu-density($scale-theme); |
| 237 | + @include mat.paginator-density($scale-theme); |
| 238 | + @include mat.progress-bar-density($scale-theme); |
| 239 | + @include mat.progress-spinner-density($scale-theme); |
| 240 | + @include mat.radio-density($scale-theme); |
| 241 | + @include mat.select-density($scale-theme); |
| 242 | + @include mat.sidenav-density($scale-theme); |
| 243 | + @include mat.slide-toggle-density($scale-theme); |
| 244 | + @include mat.slider-density($scale-theme); |
| 245 | + @include mat.snack-bar-density($scale-theme); |
| 246 | + @include mat.sort-density($scale-theme); |
| 247 | + @include mat.stepper-density($scale-theme); |
| 248 | + @include mat.table-density($scale-theme); |
| 249 | + @include mat.tabs-density($scale-theme); |
| 250 | + @include mat.toolbar-density($scale-theme); |
| 251 | + @include mat.tooltip-density($scale-theme); |
| 252 | + @include mat.tree-density($scale-theme); |
| 253 | + } |
| 254 | +} |
0 commit comments