Skip to content

Commit

Permalink
fix(debug): Improve AI panel accessibility
Browse files Browse the repository at this point in the history
Make sure form input elements and their labels are properly associated
  • Loading branch information
delucis committed Aug 26, 2021
1 parent d2b611d commit 06bc747
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/client/debug/ai/AI.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@
{#if Object.keys(bot.opts()).length}
<section>
<h3>Options</h3>
<label>debug</label>
<input type=checkbox bind:checked={debug} on:change={OnDebug}>
<label for="ai-option-debug">debug</label>
<input id="ai-option-debug" type=checkbox bind:checked={debug} on:change={OnDebug}>
<Options bot={bot}/>
</section>
{/if}
Expand Down
12 changes: 6 additions & 6 deletions src/client/debug/ai/Options.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
bot.setOpt(key, value);
}
}
const makeID = (key) => 'ai-option-' + key;
</script>

<style>
Expand All @@ -34,15 +36,13 @@

{#each Object.entries(bot.opts()) as [key, value]}
<div class="option">
<label>{key}</label>
<label for={makeID(key)}>{key}</label>

{#if value.range}
<span class="value">{values[key]}</span>
<input type=range bind:value={values[key]} min={value.range.min} max={value.range.max} on:change={OnChange}>
{/if}

{#if typeof value.value === 'boolean'}
<input type=checkbox bind:checked={values[key]} on:change={OnChange}>
<input id={makeID(key)} type=range bind:value={values[key]} min={value.range.min} max={value.range.max} on:change={OnChange}>
{:else if typeof value.value === 'boolean'}
<input id={makeID(key)} type=checkbox bind:checked={values[key]} on:change={OnChange}>
{/if}
</div>
{/each}

0 comments on commit 06bc747

Please sign in to comment.