|
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; |
13 |
| - |
14 | 5 | .mat-sort-header-container {
|
15 | 6 | display: flex;
|
16 | 7 | cursor: pointer;
|
@@ -51,93 +42,96 @@ $header-arrow-hint-opacity: 0.38;
|
51 | 42 | flex-direction: row-reverse;
|
52 | 43 | }
|
53 | 44 |
|
| 45 | +@keyframes _mat-sort-header-recently-cleared-ascending { |
| 46 | + from { |
| 47 | + transform: translateY(0); |
| 48 | + opacity: 1; |
| 49 | + } |
| 50 | + |
| 51 | + to { |
| 52 | + transform: translateY(-25%); |
| 53 | + opacity: 0; |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +@keyframes _mat-sort-header-recently-cleared-descending { |
| 58 | + from { |
| 59 | + transform: translateY(0) rotate(180deg); |
| 60 | + opacity: 1; |
| 61 | + } |
| 62 | + |
| 63 | + to { |
| 64 | + transform: translateY(25%) rotate(180deg); |
| 65 | + opacity: 0; |
| 66 | + } |
| 67 | +} |
| 68 | + |
54 | 69 | .mat-sort-header-arrow {
|
55 |
| - height: $header-arrow-container-size; |
56 |
| - width: $header-arrow-container-size; |
57 |
| - min-width: $header-arrow-container-size; |
| 70 | + $timing: 225ms cubic-bezier(0.4, 0, 0.2, 1); |
| 71 | + height: 12px; |
| 72 | + width: 12px; |
58 | 73 | position: relative;
|
59 |
| - display: flex; |
| 74 | + transition: transform $timing, opacity $timing; |
| 75 | + opacity: 0; |
| 76 | + overflow: visible; |
60 | 77 |
|
61 | 78 | @include token-utils.use-tokens(tokens-mat-sort.$prefix, tokens-mat-sort.get-token-slots()) {
|
62 | 79 | @include token-utils.create-token-slot(color, arrow-color);
|
63 | 80 | }
|
64 | 81 |
|
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; |
| 82 | + .mat-sort-header:hover & { |
| 83 | + opacity: 0.54; |
72 | 84 | }
|
73 | 85 |
|
74 |
| - .mat-sort-header-position-before &, |
75 |
| - [dir='rtl'] & { |
76 |
| - margin: 0 $header-arrow-margin 0 0; |
| 86 | + .mat-sort-header .mat-sort-header-sorted & { |
| 87 | + opacity: 1; |
77 | 88 | }
|
78 |
| -} |
79 | 89 |
|
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; |
87 |
| - |
88 |
| - @include cdk.high-contrast { |
89 |
| - width: 0; |
90 |
| - border-left: solid $header-arrow-thickness; |
| 90 | + .mat-sort-header-descending & { |
| 91 | + transform: rotate(180deg); |
91 | 92 | }
|
92 |
| -} |
93 | 93 |
|
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 |
| -} |
| 94 | + .mat-sort-header-recently-cleared-ascending & { |
| 95 | + transform: translateY(-25%); |
| 96 | + } |
103 | 97 |
|
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); |
| 98 | + .mat-sort-header-recently-cleared-ascending & { |
| 99 | + transition: none; // Without this the animation looks glitchy on Safari. |
| 100 | + animation: _mat-sort-header-recently-cleared-ascending $timing forwards; |
| 101 | + } |
110 | 102 |
|
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; |
| 103 | + .mat-sort-header-recently-cleared-descending & { |
| 104 | + transition: none; // Without this the animation looks glitchy on Safari. |
| 105 | + animation: _mat-sort-header-recently-cleared-descending $timing forwards; |
116 | 106 | }
|
117 |
| -} |
118 | 107 |
|
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; |
| 108 | + // Set the durations to 0, but keep the actual animation, since we still want it to play. |
| 109 | + .mat-sort-header-animations-disabled & { |
| 110 | + transition-duration: 0ms; |
| 111 | + animation-duration: 0ms; |
| 112 | + } |
126 | 113 |
|
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; |
| 114 | + svg { |
| 115 | + // Even though this is 24x24, the actual `path` inside ends up being 12x12. |
| 116 | + width: 24px; |
| 117 | + height: 24px; |
| 118 | + fill: currentColor; |
| 119 | + position: absolute; |
| 120 | + top: 50%; |
| 121 | + left: 50%; |
| 122 | + margin: -12px 0 0 -12px; |
| 123 | + |
| 124 | + // Without this transform the element twitches at the end of the transition on Safari. |
| 125 | + transform: translateZ(0); |
132 | 126 | }
|
133 |
| -} |
134 | 127 |
|
135 |
| -.mat-sort-header-pointer-left { |
136 |
| - transform-origin: right; |
137 |
| - left: 0; |
138 |
| -} |
| 128 | + &, |
| 129 | + [dir='rtl'] .mat-sort-header-position-before & { |
| 130 | + margin: 0 0 0 6px; |
| 131 | + } |
139 | 132 |
|
140 |
| -.mat-sort-header-pointer-right { |
141 |
| - transform-origin: left; |
142 |
| - right: 0; |
| 133 | + .mat-sort-header-position-before &, |
| 134 | + [dir='rtl'] & { |
| 135 | + margin: 0 6px 0 0; |
| 136 | + } |
143 | 137 | }
|
0 commit comments