Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: some funboxes not working if reduced motion is preferred (@fehmer) #6104

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/styles/media-queries.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ body {
}

@media (prefers-reduced-motion) {
*:not(.fa-spin, #backgroundLoader, .preloader) {
body:not(.force-animation) *:not(.fa-spin, #backgroundLoader, .preloader) {
animation: none !important;
transition: none !important;

Expand Down
17 changes: 11 additions & 6 deletions frontend/src/ts/test/funbox/funbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,18 @@ async function setFunboxBodyClasses(): Promise<boolean> {
(name) => "fb-" + name.replaceAll("_", "-")
);

const currentClasses =
$body
?.attr("class")
?.split(/\s+/)
?.filter((it) => !it.startsWith("fb-")) ?? [];
const currentClasses = $body?.attr("class")?.split(/\s+/) ?? [];

if (
getActiveFunboxes().some((it) => it.properties?.includes("forceAnimation"))
) {
currentClasses.push("force-animation");
}

$body.attr("class", [...currentClasses, ...activeFbClasses].join(" "));
$body.attr(
"class",
[...new Set([...currentClasses, ...activeFbClasses]).keys()].join(" ")
);

return true;
}
Expand Down
15 changes: 10 additions & 5 deletions packages/funbox/src/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ const list: Record<FunboxName, FunboxMetadata> = {
description: "I think I'm gonna be sick.",
canGetPb: true,
difficultyLevel: 2,
properties: ["hasCssFile"],
properties: ["hasCssFile", "forceAnimation"],
fehmer marked this conversation as resolved.
Show resolved Hide resolved
},
round_round_baby: {
name: "round_round_baby",
description:
"...right round, like a record baby. Right, round round round.",
canGetPb: true,
difficultyLevel: 3,
properties: ["hasCssFile"],
properties: ["hasCssFile", "forceAnimation"],
},
simon_says: {
name: "simon_says",
Expand Down Expand Up @@ -73,7 +73,12 @@ const list: Record<FunboxName, FunboxMetadata> = {
choo_choo: {
canGetPb: true,
difficultyLevel: 2,
properties: ["hasCssFile", "noLigatures", "conflictsWithSymmetricChars"],
properties: [
"hasCssFile",
"noLigatures",
"conflictsWithSymmetricChars",
"forceAnimation",
],
name: "choo_choo",
description: "All the letters are spinning!",
},
Expand Down Expand Up @@ -138,14 +143,14 @@ const list: Record<FunboxName, FunboxMetadata> = {
description: "Everybody get down! The words are shaking!",
canGetPb: true,
difficultyLevel: 1,
properties: ["hasCssFile", "noLigatures"],
properties: ["hasCssFile", "noLigatures", "forceAnimation"],
name: "earthquake",
},
space_balls: {
description: "In a galaxy far far away.",
canGetPb: true,
difficultyLevel: 0,
properties: ["hasCssFile"],
properties: ["hasCssFile", "forceAnimation"],
name: "space_balls",
},
gibberish: {
Expand Down
3 changes: 2 additions & 1 deletion packages/funbox/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export type FunboxProperty =
| "noInfiniteDuration"
| "noLigatures"
| `toPush:${number}`
| "wordOrder:reverse";
| "wordOrder:reverse"
| "forceAnimation";

export type FunboxMetadata = {
name: FunboxName;
Expand Down
Loading