Some screen reader thingies
This commit is contained in:
@@ -170,3 +170,12 @@ a:active {
|
|||||||
margin-top: 1em;
|
margin-top: 1em;
|
||||||
font-variant-numeric: tabular-nums;
|
font-variant-numeric: tabular-nums;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.Game-sr-feedback {
|
||||||
|
position: absolute;
|
||||||
|
left: -10000px;
|
||||||
|
top: auto;
|
||||||
|
width: 1px;
|
||||||
|
height: 1px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|||||||
21
src/Game.tsx
21
src/Game.tsx
@@ -17,8 +17,7 @@ interface GameProps {
|
|||||||
hidden: boolean;
|
hidden: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const targets = targetList
|
const targets = targetList.slice(0, targetList.indexOf("murky") + 1); // Words no rarer than this one
|
||||||
.slice(0, targetList.indexOf("murky") + 1); // Words no rarer than this one
|
|
||||||
|
|
||||||
function randomTarget(wordLength: number) {
|
function randomTarget(wordLength: number) {
|
||||||
const eligible = targets.filter((word) => word.length === wordLength);
|
const eligible = targets.filter((word) => word.length === wordLength);
|
||||||
@@ -31,6 +30,7 @@ function Game(props: GameProps) {
|
|||||||
const [currentGuess, setCurrentGuess] = useState<string>("");
|
const [currentGuess, setCurrentGuess] = useState<string>("");
|
||||||
const [wordLength, setWordLength] = useState(5);
|
const [wordLength, setWordLength] = useState(5);
|
||||||
const [hint, setHint] = useState<string>(`Make your first guess!`);
|
const [hint, setHint] = useState<string>(`Make your first guess!`);
|
||||||
|
const [srStatus, setSrStatus] = useState<string>(``);
|
||||||
const [target, setTarget] = useState(() => {
|
const [target, setTarget] = useState(() => {
|
||||||
resetRng();
|
resetRng();
|
||||||
return randomTarget(wordLength);
|
return randomTarget(wordLength);
|
||||||
@@ -81,6 +81,7 @@ function Game(props: GameProps) {
|
|||||||
setGameState(GameState.Lost);
|
setGameState(GameState.Lost);
|
||||||
} else {
|
} else {
|
||||||
setHint("");
|
setHint("");
|
||||||
|
setSrStatus("Feedback goes here");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -117,7 +118,13 @@ function Game(props: GameProps) {
|
|||||||
<Row
|
<Row
|
||||||
key={i}
|
key={i}
|
||||||
wordLength={wordLength}
|
wordLength={wordLength}
|
||||||
rowState={lockedIn ? RowState.LockedIn : RowState.Pending}
|
rowState={
|
||||||
|
lockedIn
|
||||||
|
? RowState.LockedIn
|
||||||
|
: i === guesses.length
|
||||||
|
? RowState.Editing
|
||||||
|
: RowState.Pending
|
||||||
|
}
|
||||||
cluedLetters={cluedLetters}
|
cluedLetters={cluedLetters}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -146,7 +153,6 @@ function Game(props: GameProps) {
|
|||||||
setTarget(randomTarget(length));
|
setTarget(randomTarget(length));
|
||||||
setWordLength(length);
|
setWordLength(length);
|
||||||
setHint(`${length} letters`);
|
setHint(`${length} letters`);
|
||||||
(document.activeElement as HTMLElement)?.blur();
|
|
||||||
}}
|
}}
|
||||||
></input>
|
></input>
|
||||||
<button
|
<button
|
||||||
@@ -163,8 +169,11 @@ function Game(props: GameProps) {
|
|||||||
Give up
|
Give up
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{rowDivs}
|
<div className="Game-rows">{rowDivs}</div>
|
||||||
<p>{hint || `\u00a0`}</p>
|
<p role="status">{hint || `\u00a0`}</p>
|
||||||
|
<p role="status" className="Game-sr-feedback">
|
||||||
|
{srStatus}
|
||||||
|
</p>
|
||||||
<Keyboard letterInfo={letterInfo} onKey={onKey} />
|
<Keyboard letterInfo={letterInfo} onKey={onKey} />
|
||||||
{seed ? (
|
{seed ? (
|
||||||
<div className="Game-seed-info">
|
<div className="Game-seed-info">
|
||||||
|
|||||||
12
src/Row.tsx
12
src/Row.tsx
@@ -2,6 +2,7 @@ import { Clue, clueClass, CluedLetter } from "./clue";
|
|||||||
|
|
||||||
export enum RowState {
|
export enum RowState {
|
||||||
LockedIn,
|
LockedIn,
|
||||||
|
Editing,
|
||||||
Pending,
|
Pending,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -13,6 +14,7 @@ interface RowProps {
|
|||||||
|
|
||||||
export function Row(props: RowProps) {
|
export function Row(props: RowProps) {
|
||||||
const isLockedIn = props.rowState === RowState.LockedIn;
|
const isLockedIn = props.rowState === RowState.LockedIn;
|
||||||
|
const isEditing = props.rowState === RowState.Editing;
|
||||||
const letterDivs = props.cluedLetters
|
const letterDivs = props.cluedLetters
|
||||||
.concat(Array(props.wordLength).fill({ clue: Clue.Absent, letter: "" }))
|
.concat(Array(props.wordLength).fill({ clue: Clue.Absent, letter: "" }))
|
||||||
.slice(0, props.wordLength)
|
.slice(0, props.wordLength)
|
||||||
@@ -29,5 +31,13 @@ export function Row(props: RowProps) {
|
|||||||
});
|
});
|
||||||
let rowClass = "Row";
|
let rowClass = "Row";
|
||||||
if (isLockedIn) rowClass += " Row-locked-in";
|
if (isLockedIn) rowClass += " Row-locked-in";
|
||||||
return <div className={rowClass}>{letterDivs}</div>;
|
return (
|
||||||
|
<div
|
||||||
|
className={rowClass}
|
||||||
|
role={isEditing ? "input" : "row"}
|
||||||
|
tabIndex={isEditing ? 0 : undefined}
|
||||||
|
>
|
||||||
|
{letterDivs}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user