Skip to content

Commit 165ca39

Browse files
committed
feat: always display word length on click
1 parent 85f3834 commit 165ca39

File tree

4 files changed

+25
-48
lines changed

4 files changed

+25
-48
lines changed

frontend/components/game/article.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import {
1818
} from "@caviardeul/utils/caviarding";
1919

2020
const _WordContainer: React.FC<{ word: string }> = ({ word }) => {
21-
const { settings } = useContext(SettingsContext);
22-
2321
const { revealedWords, isOver, selection } = useContext(GameContext);
2422
if (word === undefined) {
2523
return null;
@@ -35,12 +33,7 @@ const _WordContainer: React.FC<{ word: string }> = ({ word }) => {
3533
);
3634
} else {
3735
return (
38-
<span
39-
className={
40-
"word caviarded" + (settings.displayWordLength ? " word-length" : "")
41-
}
42-
data-word-length={word.length}
43-
>
36+
<span className="word caviarded" data-word-length={word.length}>
4437
{"█".repeat(word.length)}
4538
</span>
4639
);

frontend/components/modals/settingsModal.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,12 @@ const SettingsModal: React.FC<{ open: boolean; onClose: () => void }> = ({
88
onClose,
99
}) => {
1010
const { settings, onChangeSettings } = useContext(SettingsContext);
11-
const { lightMode, displayWordLength, autoScroll } = settings;
11+
const { lightMode, autoScroll } = settings;
1212

1313
const handleToggleLightMode = useCallback(() => {
1414
onChangeSettings({ lightMode: !lightMode });
1515
}, [lightMode, onChangeSettings]);
1616

17-
const handleToggleDisplayWordLength = useCallback(() => {
18-
onChangeSettings({ displayWordLength: !displayWordLength });
19-
}, [displayWordLength, onChangeSettings]);
20-
2117
const handleToggleAutoscroll = useCallback(() => {
2218
onChangeSettings({ autoScroll: !autoScroll });
2319
}, [autoScroll, onChangeSettings]);
@@ -39,15 +35,6 @@ const SettingsModal: React.FC<{ open: boolean; onClose: () => void }> = ({
3935
Activer le mode sombre
4036
</label>
4137
<br />
42-
<label>
43-
<input
44-
type="checkbox"
45-
checked={displayWordLength}
46-
onChange={handleToggleDisplayWordLength}
47-
/>
48-
Afficher le nombre de lettres au clic
49-
</label>
50-
<br />
5138
<label>
5239
<input
5340
type="checkbox"

frontend/components/settings/manager.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import SaveManagement from "@caviardeul/utils/save";
77

88
const defaultSettings: Settings = {
99
lightMode: false,
10-
displayWordLength: true,
1110
autoScroll: true,
1211
};
1312
const getInitialSettings = (): Settings => {
@@ -19,8 +18,6 @@ const getInitialSettings = (): Settings => {
1918
}
2019
return {
2120
lightMode: settings?.lightMode ?? defaultSettings.lightMode,
22-
displayWordLength:
23-
settings?.displayWordLength ?? defaultSettings.displayWordLength,
2421
autoScroll: settings?.autoScroll ?? defaultSettings.autoScroll,
2522
};
2623
};

frontend/styles/style.scss

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,8 @@ main {
455455
height: calc(100% - #{$guessInputHeight});
456456
}
457457

458-
h1, h2 {
458+
h1,
459+
h2 {
459460
line-height: normal;
460461
}
461462

@@ -490,28 +491,27 @@ main {
490491
border-radius: 30px 255px 30px 225px/30px 225px 30px 250px;
491492
}
492493

493-
&.word-length {
494-
cursor: pointer;
495-
user-select: none;
496-
&::after {
497-
align-items: center;
498-
content: attr(data-word-length);
499-
color: var(--color-background);
500-
display: flex;
501-
height: 100%;
502-
left: 0;
503-
justify-content: center;
504-
opacity: 0;
505-
position: absolute;
506-
top: 0;
507-
transition: opacity 0.2s ease-in-out;
508-
width: 100%;
509-
}
510-
&:active::after,
511-
&:focus::after,
512-
&:focus-within::after {
513-
opacity: 1;
514-
}
494+
// word length indicator
495+
cursor: pointer;
496+
user-select: none;
497+
&::after {
498+
align-items: center;
499+
content: attr(data-word-length);
500+
color: var(--color-background);
501+
display: flex;
502+
height: 100%;
503+
left: 0;
504+
justify-content: center;
505+
opacity: 0;
506+
position: absolute;
507+
top: 0;
508+
transition: opacity 0.2s ease-in-out;
509+
width: 100%;
510+
}
511+
&:active::after,
512+
&:focus::after,
513+
&:focus-within::after {
514+
opacity: 1;
515515
}
516516
}
517517
}

0 commit comments

Comments
 (0)