Skip to content

Commit e2684c9

Browse files
authored
fix: some funboxes not working if reduced motion is preferred (@fehmer) (monkeytypegame#6104)
1 parent 0c8d156 commit e2684c9

File tree

4 files changed

+27
-13
lines changed

4 files changed

+27
-13
lines changed

frontend/src/styles/media-queries.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,8 @@ body {
10411041
}
10421042

10431043
@media (prefers-reduced-motion) {
1044-
*:not(.fa-spin, #backgroundLoader, .preloader) {
1044+
body:not(.ignore-reduced-motion)
1045+
*:not(.fa-spin, #backgroundLoader, .preloader) {
10451046
animation: none !important;
10461047
transition: none !important;
10471048

frontend/src/ts/test/funbox/funbox.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,20 @@ async function setFunboxBodyClasses(): Promise<boolean> {
214214
(name) => "fb-" + name.replaceAll("_", "-")
215215
);
216216

217-
const currentClasses =
218-
$body
219-
?.attr("class")
220-
?.split(/\s+/)
221-
?.filter((it) => !it.startsWith("fb-")) ?? [];
217+
const currentClasses = $body?.attr("class")?.split(/\s+/) ?? [];
218+
219+
if (
220+
getActiveFunboxes().some((it) =>
221+
it.properties?.includes("ignoreReducedMotion")
222+
)
223+
) {
224+
currentClasses.push("ignore-reduced-motion");
225+
}
222226

223-
$body.attr("class", [...currentClasses, ...activeFbClasses].join(" "));
227+
$body.attr(
228+
"class",
229+
[...new Set([...currentClasses, ...activeFbClasses]).keys()].join(" ")
230+
);
224231

225232
return true;
226233
}

packages/funbox/src/list.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ const list: Record<FunboxName, FunboxMetadata> = {
3737
description: "I think I'm gonna be sick.",
3838
canGetPb: true,
3939
difficultyLevel: 2,
40-
properties: ["hasCssFile"],
40+
properties: ["hasCssFile", "ignoreReducedMotion"],
4141
},
4242
round_round_baby: {
4343
name: "round_round_baby",
4444
description:
4545
"...right round, like a record baby. Right, round round round.",
4646
canGetPb: true,
4747
difficultyLevel: 3,
48-
properties: ["hasCssFile"],
48+
properties: ["hasCssFile", "ignoreReducedMotion"],
4949
},
5050
simon_says: {
5151
name: "simon_says",
@@ -73,7 +73,12 @@ const list: Record<FunboxName, FunboxMetadata> = {
7373
choo_choo: {
7474
canGetPb: true,
7575
difficultyLevel: 2,
76-
properties: ["hasCssFile", "noLigatures", "conflictsWithSymmetricChars"],
76+
properties: [
77+
"hasCssFile",
78+
"noLigatures",
79+
"conflictsWithSymmetricChars",
80+
"ignoreReducedMotion",
81+
],
7782
name: "choo_choo",
7883
description: "All the letters are spinning!",
7984
},
@@ -138,14 +143,14 @@ const list: Record<FunboxName, FunboxMetadata> = {
138143
description: "Everybody get down! The words are shaking!",
139144
canGetPb: true,
140145
difficultyLevel: 1,
141-
properties: ["hasCssFile", "noLigatures"],
146+
properties: ["hasCssFile", "noLigatures", "ignoreReducedMotion"],
142147
name: "earthquake",
143148
},
144149
space_balls: {
145150
description: "In a galaxy far far away.",
146151
canGetPb: true,
147152
difficultyLevel: 0,
148-
properties: ["hasCssFile"],
153+
properties: ["hasCssFile", "ignoreReducedMotion"],
149154
name: "space_balls",
150155
},
151156
gibberish: {

packages/funbox/src/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ export type FunboxProperty =
6262
| "noInfiniteDuration"
6363
| "noLigatures"
6464
| `toPush:${number}`
65-
| "wordOrder:reverse";
65+
| "wordOrder:reverse"
66+
| "ignoreReducedMotion";
6667

6768
export type FunboxMetadata = {
6869
name: FunboxName;

0 commit comments

Comments
 (0)