Skip to content

Commit

Permalink
refacto choice component
Browse files Browse the repository at this point in the history
  • Loading branch information
dlaxcess committed Feb 1, 2024
1 parent 7e012c4 commit a5278f8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions svelte/components/Input/Config/ConfigFieldChoice.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
export let namespace;
$: attribute = attributes[namespace];
$: fieldsGroups = attribute.fieldsGroups;
$: defaultChoice = attribute.default.value;
$: defaultChoiceDisplay = attribute.fieldsGroups[defaultChoice].display;
let open = false;
Expand All @@ -20,13 +22,13 @@
>
<div class="select" class:open>
<div class="select-trigger">
<span>{attribute.fieldsGroups[defaultChoice].display}</span>
<span>{defaultChoiceDisplay}</span>
</div>

<div class="custom-options">
{#each Object.entries(attribute.fieldsGroups) as [key, choice]}
{#each Object.entries(fieldsGroups) as [key, choice]}
<span
class="custom-option {key == attribute.default.value && 'selected'}"
class="custom-option {key == defaultChoice && 'selected'}"
on:click={() => (attributes[namespace].default.value = key)}
on:keydown={() => (attributes[namespace].default.value = key)}
>
Expand Down

0 comments on commit a5278f8

Please sign in to comment.