Skip to content

Commit 97d3bc9

Browse files
authored
feat: Select (#148)
* feat: Select * fix: as per our design * fix: code format and as per svelte 5 * fix: font-size * fix: font-size * fix: icon
1 parent 5c09e14 commit 97d3bc9

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { ComponentProps } from 'svelte';
2+
import { Select } from '..';
3+
4+
export default {
5+
title: 'UI/Select',
6+
component: Select,
7+
tags: ['autodocs'],
8+
render: (args: { Component: Select; props: ComponentProps<typeof Select> }) => ({
9+
Component: Select,
10+
props: args
11+
})
12+
};
13+
14+
export const Primary = {
15+
args: {}
16+
};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<script lang="ts">
2+
import { cn } from '$lib/utils';
3+
import type { HTMLAttributes } from 'svelte/elements';
4+
5+
interface ISelectProps extends HTMLAttributes<HTMLElement> {
6+
options: Array<{
7+
code: string;
8+
icon: string;
9+
name: string;
10+
}>;
11+
}
12+
13+
let {
14+
options = [
15+
{ code: '+41', icon: '🇬🇧', name: 'United Kingdom' },
16+
{ code: '+49', icon: '🇩🇪', name: 'Germany' },
17+
{ code: '+33', icon: '🇫🇷', name: 'France' }
18+
],
19+
...restProps
20+
}: ISelectProps = $props();
21+
22+
let selectedCode = $state(options[0].code);
23+
24+
const cBase = 'bg-grey flex w-[max-content] items-center space-x-2 rounded-full p-1.5';
25+
</script>
26+
27+
<div {...restProps} class={cn([cBase, restProps.class].join(' '))}>
28+
<div class="rounded-full text-2xl">{options.find((c) => c.code === selectedCode)?.icon}</div>
29+
<select
30+
bind:value={selectedCode}
31+
class="text-base focus:ring-2 focus:ring-transparent focus:outline-none"
32+
>
33+
{#each options as country}
34+
<option value={country.code} class="text-black-600 text-base">
35+
{country.code}
36+
</option>
37+
{/each}
38+
</select>
39+
</div>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export { default as Button } from './Button/Button.svelte';
22
export { default as Avatar } from './Avatar/Avatar.svelte';
33
export { default as Input } from './Input/Input.svelte';
4+
export { default as Select } from './Select/Select.svelte';
45
export { default as Label } from './Label/Label.svelte';
56
export { default as Toggle } from './Toggle/Toggle.svelte';

0 commit comments

Comments
 (0)