Skip to content

Commit

Permalink
Use radio buttons for picking the authority type, not a select
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Jul 12, 2023
1 parent ff214df commit 0a1648b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 14 deletions.
34 changes: 34 additions & 0 deletions src/lib/govuk/Radio.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<script lang="ts">
// A label for the entire group of radio buttons
export let legend: string;
// A unique (per page) ID of the radio group
export let id: string;
// A list of [value, label] representing the choices
export let choices: [string, string][];
// The current value
export let value: string;
</script>

<div class="govuk-form-group">
<fieldset class="govuk-fieldset">
<legend class="govuk-fieldset__legend">{legend}</legend>
<div class="govuk-radios" data-module="govuk-radios">
{#each choices as [thisValue, thisLabel]}
<div class="govuk-radios__item">
<input
class="govuk-radios__input"
id={id + thisValue}
type="radio"
bind:group={value}
value={thisValue}
on:change
/>
<label class="govuk-label govuk-radios__label" for={id + thisValue}>
{thisLabel}
</label>
</div>
{/each}
</div>
</fieldset>
</div>
28 changes: 14 additions & 14 deletions src/pages/ChooseArea.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { onMount } from "svelte";
import DefaultButton from "../lib/govuk/DefaultButton.svelte";
import FormElement from "../lib/govuk/FormElement.svelte";
import Radio from "../lib/govuk/Radio.svelte";
import SecondaryButton from "../lib/govuk/SecondaryButton.svelte";
import "maplibre-gl/dist/maplibre-gl.css";
import authoritiesUrl from "../../assets/authorities.geojson?url";
Expand Down Expand Up @@ -174,20 +175,19 @@

<hr />

<FormElement label="Or pick from the map" id="showBoundaries">
<select
id="showBoundaries"
class="govuk-select"
bind:value={showBoundaries}
on:change={changeBoundaries}
>
<option value="TA">Transport Authorities</option>
<option value="LAD">Local Authority District</option>
</select>
{#if hoveredBoundary}
<i>{hoveredBoundary}</i>
{/if}
</FormElement>
<Radio
legend="Or pick from the map"
id="showBoundaries"
choices={[
["TA", "Transport Authorities"],
["LAD", "Local Authority Districts"],
]}
bind:value={showBoundaries}
on:change={changeBoundaries}
/>
{#if hoveredBoundary}
<i>{hoveredBoundary}</i>
{/if}

<hr />

Expand Down

0 comments on commit 0a1648b

Please sign in to comment.