Skip to content

Commit

Permalink
Fixed #192 More accessible checkboxes.
Browse files Browse the repository at this point in the history
  • Loading branch information
amyjko committed Oct 14, 2023
1 parent 74daab7 commit 1b6e01c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
7 changes: 6 additions & 1 deletion src/components/palette/BindCheckbox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@
}
</script>

<Checkbox on={values.getBool()} changed={handleChange} {editable} />
<Checkbox
on={values.getBool()}
changed={handleChange}
{editable}
id={property.getName()}
/>
1 change: 1 addition & 0 deletions src/components/palette/PaletteProperty.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
align-items: baseline;
gap: var(--wordplay-spacing);
row-gap: var(--wordplay-spacing);
user-select: none;
}
.name {
Expand Down
8 changes: 3 additions & 5 deletions src/components/widgets/Checkbox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
export let changed: undefined | ((value: boolean | undefined) => void) =
undefined;
export let editable = true;
/** Mandatory id for label */
export let id: string | null;
function handleInput() {
if (changed) changed(on);
Expand All @@ -11,6 +13,7 @@

<input
type="checkbox"
{id}
disabled={!editable}
bind:checked={on}
on:change={handleInput}
Expand All @@ -27,11 +30,6 @@
cursor: pointer;
}
input:focus {
outline: none;
border-color: var(--wordplay-highlight-color);
}
[type='checkbox']:checked {
background: var(--wordplay-foreground);
}
Expand Down
18 changes: 13 additions & 5 deletions src/routes/moderate/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
try {
await nextBatch();
} catch (_) {
lastBatch = undefined;
moderator = false;
}
});
Expand All @@ -64,7 +65,10 @@
setContext(ConceptPathSymbol, writable([]));
async function nextBatch() {
if (firestore === undefined) return firestore;
if (firestore === undefined) {
lastBatch = undefined;
return firestore;
}
const unmoderated = query(
collection(firestore, 'projects'),
// Construct a query for each flag to find any project that has a null flag.
Expand Down Expand Up @@ -133,16 +137,19 @@
<div class="flag">
<Checkbox
on={state === null ? undefined : state}
id={flag}
changed={(value) =>
(newFlags = withFlag(
newFlags,
flag,
value === true
))}
/>
<MarkupHtmlView
markup={getFlagDescription(flag, $locale) ?? ''}
/>
<label for={flag}>
<MarkupHtmlView
markup={getFlagDescription(flag, $locale) ?? ''}
/></label
>
</div>
{/each}
<div class="controls">
Expand Down Expand Up @@ -196,11 +203,12 @@
overflow-x: hidden;
overflow-y: auto;
}
.flag {
display: flex;
flex-direction: row;
gap: var(--wordplay-spacing);
align-items: center;
align-items: normal;
font-size: medium;
}
Expand Down

0 comments on commit 1b6e01c

Please sign in to comment.