|
1 |
| -@use '@angular/cdk'; |
2 |
| - |
3 | 1 | @use '../core/tokens/m2/mat/sort' as tokens-mat-sort;
|
4 | 2 | @use '../core/tokens/token-utils';
|
5 | 3 | @use '../core/focus-indicators/private';
|
6 | 4 |
|
7 |
| -$header-arrow-margin: 6px; |
8 |
| -$header-arrow-container-size: 12px; |
9 |
| -$header-arrow-stem-size: 10px; |
10 |
| -$header-arrow-pointer-length: 6px; |
11 |
| -$header-arrow-thickness: 2px; |
12 |
| -$header-arrow-hint-opacity: 0.38; |
| 5 | +$header-arrow-margin: 4px; |
| 6 | +$header-arrow-container-size: 24px; |
13 | 7 |
|
14 | 8 | .mat-sort-header-container {
|
15 | 9 | display: flex;
|
@@ -51,93 +45,90 @@ $header-arrow-hint-opacity: 0.38;
|
51 | 45 | flex-direction: row-reverse;
|
52 | 46 | }
|
53 | 47 |
|
| 48 | +@keyframes _mat-sort-header-recently-cleared-ascending { |
| 49 | + from { |
| 50 | + transform: translateY(0); |
| 51 | + opacity: 1; |
| 52 | + } |
| 53 | + |
| 54 | + to { |
| 55 | + transform: translateY(-25%); |
| 56 | + opacity: 0; |
| 57 | + } |
| 58 | +} |
| 59 | + |
| 60 | +@keyframes _mat-sort-header-recently-cleared-descending { |
| 61 | + from { |
| 62 | + transform: translateY(0) rotate(180deg); |
| 63 | + opacity: 1; |
| 64 | + } |
| 65 | + |
| 66 | + to { |
| 67 | + transform: translateY(25%) rotate(180deg); |
| 68 | + opacity: 0; |
| 69 | + } |
| 70 | +} |
| 71 | + |
54 | 72 | .mat-sort-header-arrow {
|
| 73 | + $timing: 225ms cubic-bezier(0.4, 0, 0.2, 1); |
55 | 74 | height: $header-arrow-container-size;
|
56 | 75 | width: $header-arrow-container-size;
|
57 |
| - min-width: $header-arrow-container-size; |
58 | 76 | position: relative;
|
59 |
| - display: flex; |
| 77 | + transition: transform $timing, opacity $timing; |
| 78 | + opacity: 0; |
60 | 79 |
|
61 | 80 | @include token-utils.use-tokens(tokens-mat-sort.$prefix, tokens-mat-sort.get-token-slots()) {
|
62 | 81 | @include token-utils.create-token-slot(color, arrow-color);
|
63 | 82 | }
|
64 | 83 |
|
65 |
| - // Start off at 0 since the arrow may become visible while parent are animating. |
66 |
| - // This will be overwritten when the arrow animations kick in. See #11819. |
67 |
| - opacity: 0; |
68 |
| - |
69 |
| - &, |
70 |
| - [dir='rtl'] .mat-sort-header-position-before & { |
71 |
| - margin: 0 0 0 $header-arrow-margin; |
| 84 | + .mat-sort-header:hover & { |
| 85 | + opacity: 0.54; |
72 | 86 | }
|
73 | 87 |
|
74 |
| - .mat-sort-header-position-before &, |
75 |
| - [dir='rtl'] & { |
76 |
| - margin: 0 $header-arrow-margin 0 0; |
| 88 | + .mat-sort-header .mat-sort-header-sorted & { |
| 89 | + opacity: 1; |
77 | 90 | }
|
78 |
| -} |
79 | 91 |
|
80 |
| -.mat-sort-header-stem { |
81 |
| - background: currentColor; |
82 |
| - height: $header-arrow-stem-size; |
83 |
| - width: $header-arrow-thickness; |
84 |
| - margin: auto; |
85 |
| - display: flex; |
86 |
| - align-items: center; |
| 92 | + .mat-sort-header-descending & { |
| 93 | + transform: rotate(180deg); |
| 94 | + } |
87 | 95 |
|
88 |
| - @include cdk.high-contrast { |
89 |
| - width: 0; |
90 |
| - border-left: solid $header-arrow-thickness; |
| 96 | + .mat-sort-header-recently-cleared-ascending & { |
| 97 | + transform: translateY(-25%); |
91 | 98 | }
|
92 |
| -} |
93 | 99 |
|
94 |
| -.mat-sort-header-indicator { |
95 |
| - width: 100%; |
96 |
| - height: $header-arrow-thickness; |
97 |
| - display: flex; |
98 |
| - align-items: center; |
99 |
| - position: absolute; |
100 |
| - top: 0; |
101 |
| - left: 0; |
102 |
| -} |
| 100 | + .mat-sort-header-recently-cleared-ascending & { |
| 101 | + transition: none; // Without this the animation looks glitchy on Safari. |
| 102 | + animation: _mat-sort-header-recently-cleared-ascending $timing forwards; |
| 103 | + } |
103 | 104 |
|
104 |
| -.mat-sort-header-pointer-middle { |
105 |
| - margin: auto; |
106 |
| - height: $header-arrow-thickness; |
107 |
| - width: $header-arrow-thickness; |
108 |
| - background: currentColor; |
109 |
| - transform: rotate(45deg); |
| 105 | + .mat-sort-header-recently-cleared-descending & { |
| 106 | + transition: none; // Without this the animation looks glitchy on Safari. |
| 107 | + animation: _mat-sort-header-recently-cleared-descending $timing forwards; |
| 108 | + } |
110 | 109 |
|
111 |
| - @include cdk.high-contrast { |
112 |
| - width: 0; |
113 |
| - height: 0; |
114 |
| - border-top: solid $header-arrow-thickness; |
115 |
| - border-left: solid $header-arrow-thickness; |
| 110 | + // Set the durations to 0, but keep the actual animation, since we still want it to play. |
| 111 | + .mat-sort-header-animations-disabled & { |
| 112 | + transition-duration: 0ms; |
| 113 | + animation-duration: 0ms; |
116 | 114 | }
|
117 |
| -} |
118 | 115 |
|
119 |
| -.mat-sort-header-pointer-left, |
120 |
| -.mat-sort-header-pointer-right { |
121 |
| - background: currentColor; |
122 |
| - width: $header-arrow-pointer-length; |
123 |
| - height: $header-arrow-thickness; |
124 |
| - position: absolute; |
125 |
| - top: 0; |
| 116 | + svg { |
| 117 | + width: 100%; |
| 118 | + height: 100%; |
| 119 | + fill: currentColor; |
126 | 120 |
|
127 |
| - @include cdk.high-contrast { |
128 |
| - width: 0; |
129 |
| - height: 0; |
130 |
| - border-left: solid $header-arrow-pointer-length; |
131 |
| - border-top: solid $header-arrow-thickness; |
| 121 | + // Without this transform the element twitches at the end of the transition on Safari. |
| 122 | + transform: translateZ(0); |
132 | 123 | }
|
133 |
| -} |
134 | 124 |
|
135 |
| -.mat-sort-header-pointer-left { |
136 |
| - transform-origin: right; |
137 |
| - left: 0; |
138 |
| -} |
| 125 | + &, |
| 126 | + [dir='rtl'] .mat-sort-header-position-before & { |
| 127 | + margin: 0 0 0 $header-arrow-margin; |
| 128 | + } |
139 | 129 |
|
140 |
| -.mat-sort-header-pointer-right { |
141 |
| - transform-origin: left; |
142 |
| - right: 0; |
| 130 | + .mat-sort-header-position-before &, |
| 131 | + [dir='rtl'] & { |
| 132 | + margin: 0 $header-arrow-margin 0 0; |
| 133 | + } |
143 | 134 | }
|
0 commit comments