Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Reusable Svelte drop down menu component #95

Merged
merged 7 commits into from
Jan 17, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/components/DropDownMenu.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<script lang="ts">
export let label: string;
export let id: string;
export let options: Record<string, string>;
claireolmstead marked this conversation as resolved.
Show resolved Hide resolved
export let selected: string;
export let placeholder: string;
export let onChange = () => {};
export let onSelect = () => {};
export let required = false;
</script>

<style>
option[value=""][disabled] {
display: none;
}
</style>

<label class="section-title" for={id}>{label}</label>
claireolmstead marked this conversation as resolved.
Show resolved Hide resolved
rlaferla marked this conversation as resolved.
Show resolved Hide resolved
<div style="margin-bottom: 14px;"></div>
claireolmstead marked this conversation as resolved.
Show resolved Hide resolved
rlaferla marked this conversation as resolved.
Show resolved Hide resolved
<select {id} bind:value={selected} {required} on:change={onChange} on:select={onSelect} class="dropdown">
claireolmstead marked this conversation as resolved.
Show resolved Hide resolved
claireolmstead marked this conversation as resolved.
Show resolved Hide resolved
{#if placeholder}
<option value="" disabled selected>{placeholder}</option>
{/if}
claireolmstead marked this conversation as resolved.
Show resolved Hide resolved
{#each Object.keys(options) as option}
<option value={option} class="bg-base">{option}: {options[option]}</option>
{/each}
</select>