Skip to content

Commit

Permalink
Fix radio button ID references (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
VojtaStruhar authored Jun 10, 2024
1 parent bca704e commit f293b3c
Showing 1 changed file with 27 additions and 24 deletions.
51 changes: 27 additions & 24 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,38 @@ import PageLayout from "../layouts/PageLayout.astro";
Leaving it there is optional, but highly appreciated! Thanks!
</p>
{
config_json.categories.map((category) => (
config_json.categories.map((category, categoryIndex) => (
<form class="flex flex-col gap-2 ">
<fieldset class="rounded-lg my-4 shadow-md border bg-sky-100">
<legend class="font-mono font-bold text-xl bg-emerald-300 px-4 rounded-lg shadow">
{category.title}
</legend>
{category.options.map((item) => (
<>
{category.type == "radio" ? (
<input
type="radio"
id={item}
name={category.title}
value={item}
/>
) : (
<input
type="checkbox"
id={item}
name={category.title}
value={item}
/>
)}
<label class="mx-2" for={item}>
{item}
</label>
<br />
</>
))}
{category.options.map((item, itemIndex) => {
const itemId = `${categoryIndex}:${itemIndex}`;
return (
<>
{category.type == "radio" ? (
<input
type="radio"
id={itemId}
name={category.title}
value={item}
/>
) : (
<input
type="checkbox"
id={itemId}
name={category.title}
value={item}
/>
)}
<label class="mx-2" for={itemId}>
{item}
</label>
<br />
</>
);
})}
</fieldset>
</form>
))
Expand Down

0 comments on commit f293b3c

Please sign in to comment.