|
1 | 1 | @use '@angular/material' as mat; |
2 | 2 | @use 'sass:map'; |
3 | 3 |
|
4 | | -@mixin color($theme) { |
5 | | - $resizable-hover-divider: mat.get-theme-color($theme, primary, 60); |
6 | | - $resizable-active-divider: mat.get-theme-color($theme, primary, 60); |
| 4 | +@mixin color($theme: null) { |
| 5 | + // If a theme is provided, use the primary color defined by the system map. Otherwise, let it |
| 6 | + // fallback to the CSS variable system token. Wrap CSS variable definition in a root selector, if |
| 7 | + // the call was made at the top level without a selector. |
| 8 | + @if ($theme) { |
| 9 | + @include _current-selector-or-root() { |
| 10 | + --mat-column-resize-outline-color: #{map.get($theme, _mat-system, outline)}; |
| 11 | + --mat-column-resize-hover-color: #{map.get($theme, _mat-system, primary)}; |
| 12 | + --mat-column-resize-active-color: #{map.get($theme, _mat-system, primary)}; |
| 13 | + } |
| 14 | + } |
7 | 15 |
|
8 | 16 | // TODO: these styles don't really belong in the `color` part of the theme. |
9 | 17 | // We should figure out a better place for them. |
|
65 | 73 |
|
66 | 74 | .mat-header-cell:not(.mat-resizable)::after, |
67 | 75 | .mat-mdc-header-cell:not(.mat-resizable)::after { |
68 | | - background: map.get($theme, _mat-system, outline); |
| 76 | + background: var(--mat-column-resize-border-color, var(--mat-sys-outline)); |
69 | 77 | } |
70 | 78 |
|
71 | 79 | .mat-resizable-handle { |
72 | | - background: $resizable-hover-divider; |
| 80 | + background: var(--mat-column-resize-hover-color, var(--mat-sys-primary)); |
73 | 81 | } |
74 | 82 |
|
75 | 83 | .cdk-resizable-resize-disabled > .mat-resizable-handle { |
76 | | - background: map.get($theme, _mat-system, outline); |
| 84 | + background: var(--mat-column-resize-border-color, var(--mat-sys-outline)); |
77 | 85 | } |
78 | 86 | } |
79 | 87 |
|
|
99 | 107 | transition: none; |
100 | 108 | } |
101 | 109 |
|
| 110 | + $resizable-active-divider: var(--mat-column-resize-active-color, var(--mat-sys-primary)); |
| 111 | + |
102 | 112 | .mat-resizable-handle:focus, |
103 | 113 | .mat-header-row.cdk-column-resize-hover-or-active .mat-resizable-handle:focus, |
104 | 114 | .mat-mdc-header-row.cdk-column-resize-hover-or-active .mat-resizable-handle:focus { |
|
136 | 146 | } |
137 | 147 | } |
138 | 148 |
|
139 | | -@mixin typography($theme) {} |
| 149 | +@mixin typography($theme: null) {} |
140 | 150 |
|
141 | | -@mixin density($theme) {} |
| 151 | +@mixin density($theme: null) {} |
142 | 152 |
|
143 | | -@mixin theme($theme) { |
144 | | - @if mat.theme-has($theme, color) { |
| 153 | +@mixin theme($theme: null) { |
| 154 | + @if mat.theme-has($theme, color) or not $theme { |
145 | 155 | @include color($theme); |
146 | 156 | } |
147 | | - @if mat.theme-has($theme, density) { |
| 157 | + @if mat.theme-has($theme, density) or not $theme { |
148 | 158 | @include density($theme); |
149 | 159 | } |
150 | | - @if mat.theme-has($theme, typography) { |
| 160 | + @if mat.theme-has($theme, typography) or not $theme { |
151 | 161 | @include typography($theme); |
152 | 162 | } |
153 | 163 | } |
| 164 | + |
| 165 | +// Copy of Angular Material's `sass-utils.current-selector-or-root` function so |
| 166 | +// that variables can be defined at a top-level safely. |
| 167 | +// src/material/core/style/_sass-utils.scss |
| 168 | +@mixin _current-selector-or-root($root: html) { |
| 169 | + @if & { |
| 170 | + @content; |
| 171 | + } |
| 172 | + @else { |
| 173 | + #{$root} { |
| 174 | + @content; |
| 175 | + } |
| 176 | + } |
| 177 | +} |
0 commit comments