Skip to content

Commit e5a594e

Browse files
committed
support hiding spoilers in chinese, japanese, korean
1 parent 03ce97c commit e5a594e

File tree

7 files changed

+55
-11
lines changed

7 files changed

+55
-11
lines changed

.github/workflows/pages.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
- "!frontend/scripts/**"
1111
workflow_dispatch:
1212

13+
env:
14+
JUST_COLOR: always
15+
1316
jobs:
1417
build:
1518
# https://vite.dev/guide/static-deploy.html#github-pages
@@ -28,6 +31,12 @@ jobs:
2831
steps:
2932
- uses: actions/checkout@v4
3033

34+
- uses: DeterminateSystems/nix-installer-action@main
35+
- uses: DeterminateSystems/magic-nix-cache-action@main
36+
37+
- name: install tools
38+
run: nix profile add "nixpkgs#just" && just -V
39+
3140
- uses: actions/setup-node@v4
3241
with:
3342
node-version: "lts/*"

.justfile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1+
spoilers-font := "https://github.com/istudyatuni/spoilers-ahead-font/raw/refs/heads/master/SpoilersAhead.otf"
2+
spoilers-font-file := "frontend/public/SpoilersAhead.otf"
3+
14
[private]
25
@default:
36
just --list --unsorted
47

58
# run frontend dev server
6-
dev: (yarn "dev --host --port 8080")
9+
dev: download-spoilers-font (yarn "dev --host --port 8080")
710

811
# build frontend
9-
build: (yarn-prod "build")
12+
build: download-spoilers-font (yarn-prod "build")
1013

1114
# run frontend in prod mode
12-
preview: (yarn-prod "preview")
15+
preview: download-spoilers-font (yarn-prod "preview")
1316

1417
# format frontend code
1518
format: (yarn "format")
@@ -22,6 +25,11 @@ yarn cmd:
2225
yarn-prod cmd:
2326
export VITE_BUILD_VERSION=$(git rev-parse HEAD) && cd frontend && yarn {{cmd}}
2427

28+
download-spoilers-font:
29+
if [[ ! -e "{{ spoilers-font-file }}" ]]; then \
30+
wget "{{ spoilers-font }}" -O "{{ spoilers-font-file }}"; \
31+
fi
32+
2533
# extract game translations
2634
extract-translations:
2735
cargo r --release --package tr-extractor -- --write -vv --output-dir=frontend/public

frontend/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ dist-ssr
2222
*.njsproj
2323
*.sln
2424
*.sw?
25+
26+
/public/*.otf

frontend/src/App.svelte

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
SESSION_SETTINGS,
1515
SELECTED_CATEGORIES,
1616
SETTINGS,
17+
LANGUAGE,
1718
} from "@/lib/stores";
1819
import { get_facts_for } from "@/lib/data";
1920
import { init_i18n, t } from "@/lib/i18n";
21+
import { NEED_EXTENDED_SPOILER_FONT } from "./lib/language";
2022
</script>
2123

2224
<script>
@@ -50,7 +52,10 @@
5052
);
5153
</script>
5254

53-
<main class={hide_categories} class:hide-spoilers={$SETTINGS.hide_spoilers}>
55+
<main
56+
class={hide_categories}
57+
class:hide-spoilers={$SETTINGS.hide_spoilers}
58+
class:extended-spoiler-font={NEED_EXTENDED_SPOILER_FONT.has($LANGUAGE)}>
5459
<Sidebar />
5560
<Map />
5661
<FactsPanel {facts} />

frontend/src/Leaflet.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
3636
MAP_SIZE.subscribe((bounds) => {
3737
map
38-
.fitBounds(map_bounds_to_leaflet(bounds))
39-
.setView(bounds_center(bounds));
38+
?.fitBounds(map_bounds_to_leaflet(bounds))
39+
?.setView(bounds_center(bounds));
4040
});
4141
4242
return {

frontend/src/app.scss

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33

44
@import url("https://fonts.googleapis.com/css2?family=Flow+Circular&display=swap");
55

6+
// https://github.com/istudyatuni/spoilers-ahead-font
7+
@font-face {
8+
font-family: "Spoilers Ahead";
9+
src: url("/SpoilersAhead.otf") format("opentype");
10+
}
11+
612
$button-bg: #082638;
13+
$extended-spoilers-font: "Spoilers Ahead";
714
$spoilers-font: "Flow Circular";
815

916
:root {
@@ -161,7 +168,7 @@ input[type="checkbox"]:checked::after {
161168
rect.card,
162169
line.arrow,
163170
// "line.arrow +" is required to override leaflet's style for "svg path" with "pointer-events: none"
164-
line.arrow + path.arrow {
171+
line.arrow+path.arrow {
165172
@extend %pointer;
166173

167174
pointer-events: auto;
@@ -188,7 +195,7 @@ line.arrow:hover,
188195
// hover on arrow head
189196
line.arrow:has(+ path.arrow:hover),
190197
// connection is active
191-
svg.active > line.arrow {
198+
svg.active>line.arrow {
192199
stroke: $arrow-color-hover;
193200

194201
& + path.arrow {
@@ -254,9 +261,9 @@ $categories-colors: map.set($categories-colors, "other", $other-color);
254261
fill: $c;
255262

256263
// card is hovered
257-
svg:hover > &,
264+
svg:hover>&,
258265
// card is opened
259-
svg.active > & {
266+
svg.active>& {
260267
fill: $highlight;
261268
}
262269
}
@@ -283,7 +290,7 @@ $categories-colors: map.set($categories-colors, "other", $other-color);
283290
}
284291
}
285292

286-
.hide-spoilers {
293+
main.hide-spoilers {
287294
& .spoiler,
288295
&.spoiler {
289296
font-family: $spoilers-font;
@@ -306,6 +313,13 @@ $categories-colors: map.set($categories-colors, "other", $other-color);
306313
}
307314
}
308315

316+
main.hide-spoilers.extended-spoiler-font {
317+
& .spoiler,
318+
&.spoiler {
319+
font-family: $extended-spoilers-font;
320+
}
321+
}
322+
309323
// question sign background
310324
rect.img-q-bg {
311325
fill: var(--bg);

frontend/src/lib/language.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ export const LANGUAGE_NAMES = {
2828
turkish: "Türkçe",
2929
};
3030

31+
export const NEED_EXTENDED_SPOILER_FONT = new Set([
32+
LANGUAGES.ChineseSimple,
33+
LANGUAGES.Japanese,
34+
LANGUAGES.Korean,
35+
]);
36+
3137
export function detect_language() {
3238
return (
3339
get_language() ||

0 commit comments

Comments
 (0)