Skip to content

Commit

Permalink
add underscore_spaces with new funbox package refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Spurkus committed Dec 6, 2024
1 parent e994e84 commit 16074de
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
7 changes: 7 additions & 0 deletions frontend/src/styles/test.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,13 @@ body.fb-nospace {
}
}

/* funbox underscore_spaces */
body.fb-underscore-spaces {
#words .word {
margin: 0.5em 0;
}
}

/* funbox arrows */
body.fb-arrows {
#words .word {
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/ts/pages/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,9 @@ async function fillSettingsPage(): Promise<void> {
/_/g,
" "
)}</div>`;
} else if (funbox.name === "underscore_spaces") {
// Display as "underscore_spaces". Does not replace underscores with spaces.
funboxElHTML += `<div class="funbox button" data-config-value='${funbox.name}' aria-label="${funbox.description}" data-balloon-pos="up" data-balloon-length="fit">${funbox.name}</div>`;
} else {
funboxElHTML += `<div class="funbox button" data-config-value='${
funbox.name
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/ts/test/funbox/funbox-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,18 @@ const list: Partial<Record<FunboxName, FunboxFunctions>> = {
return GetText.getMorse(word);
},
},
underscore_spaces: {
rememberSettings(): void {
save(
"highlightMode",
Config.highlightMode,
UpdateConfig.setHighlightMode
);
},
alterText(word: string): string {
return word + "_"; //add underscore at the end instead of space
},
},
crt: {
applyGlobalCSS(): void {
const isSafari = /^((?!chrome|android).)*safari/i.test(
Expand Down
8 changes: 8 additions & 0 deletions packages/funbox/src/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,14 @@ const list: Record<FunboxName, FunboxMetadata> = {
frontendFunctions: ["alterText"],
name: "instant_messaging",
},
underscore_spaces: {
description: "Underscores_are_better.",
canGetPb: false,
difficultyLevel: 0,
properties: ["ignoresLanguage", "ignoresLayout", "nospace"],
frontendFunctions: ["alterText", "applyConfig", "rememberSettings"],
name: "underscore_spaces",
},
};

export function getFunbox(name: FunboxName): FunboxMetadata;
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 @@ -38,7 +38,8 @@ export type FunboxName =
| "crt"
| "backwards"
| "ddoouubblleedd"
| "instant_messaging";
| "instant_messaging"
| "underscore_spaces";

export type FunboxForcedConfig = Record<string, string[] | boolean[]>;

Expand Down

0 comments on commit 16074de

Please sign in to comment.