Skip to content

Commit fdc984f

Browse files
committed
Add a nice cooldown animation for the 'Reveal Players' text
1 parent 4d7ca75 commit fdc984f

File tree

2 files changed

+47
-9
lines changed

2 files changed

+47
-9
lines changed

Code/skyrim_ui/src/app/components/root/root.component.html

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,24 @@
4848
>
4949
{{ 'COMPONENT.ROOT.PLAYER_MANAGER' | transloco }}
5050
</button>
51-
<button
52-
data-style-ornament="inverted"
53-
(click)="revealPlayers()"
54-
[disabled]="revealingInProgress$"
55-
[class.reveal-disabled]="revealingInProgress$"
56-
>
57-
{{ 'COMPONENT.ROOT.REVEAL_PLAYERS' | transloco }}
51+
<button data-style-ornament="inverted" (click)="revealPlayers()">
52+
<!-- See note in 'root.component.scss' for explanation -->
53+
<div style="position: relative;">
54+
<span
55+
class="cooldown-supporting-text-normal"
56+
[class.cooldown-supporting-text-animating]="revealingInProgress$"
57+
>
58+
{{ 'COMPONENT.ROOT.REVEAL_PLAYERS' | transloco }}
59+
</span>
60+
<span
61+
style="position: absolute; left: 0; top: 0;"
62+
class="text-cooldown-effect"
63+
[class.cooldown-active]="revealingInProgress$"
64+
[style.--cooldown-duration]="revealingInProgress$ ? '6s' : '0.3s'"
65+
>
66+
{{ 'COMPONENT.ROOT.REVEAL_PLAYERS' | transloco }}
67+
</span>
68+
</div>
5869
</button>
5970
</ng-container>
6071
<button

Code/skyrim_ui/src/app/components/root/root.component.scss

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,33 @@
132132
}
133133
}
134134

135-
.reveal-disabled {
136-
opacity: 0.25;
135+
// Note: due to how `-webkit-background-clip` renders clipped text (that's needed for
136+
// the cooldown effect), we need to apply a few workarounds to make it look just right. I'm sorry!
137+
138+
.cooldown-supporting-text-normal {
139+
color: mod($-color-background, 0.8);
140+
transition: color 0.3s linear;
141+
}
142+
143+
.cooldown-supporting-text-animating {
144+
color: mod($-color-background, 0.3);
145+
}
146+
147+
.text-cooldown-effect {
148+
--cooldown-duration: 6s;
149+
background: linear-gradient(
150+
to left,
151+
mod($-color-background, 0.3) 50%,
152+
mod($-color-background, 1) 50%
153+
);
154+
background-clip: text;
155+
-webkit-background-clip: text;
156+
transition: background-position var(--cooldown-duration) linear;
157+
color: transparent;
158+
background-size: 200%;
159+
background-position: 0%;
160+
161+
&.cooldown-active {
162+
background-position: 100%;
163+
}
137164
}

0 commit comments

Comments
 (0)