Skip to content

Commit a9e703d

Browse files
authored
Feat/settings navigation button (#140)
* feat: settings-navigation-button * fix: handler added * chore: another variant added * fix: as per given suggestion
1 parent 941ad7b commit a9e703d

4 files changed

Lines changed: 91 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script module>
2+
import { Shield02Icon } from '@hugeicons/core-free-icons';
3+
import { HugeiconsIcon } from '@hugeicons/svelte';
4+
5+
export { ButtonText, ButtonIcon };
6+
</script>
7+
8+
{#snippet ButtonText()}
9+
Settings Button
10+
{/snippet}
11+
12+
{#snippet ButtonIcon()}
13+
<HugeiconsIcon size="24px" icon={Shield02Icon} color="var(--color-brand-burnt-orange)" />
14+
{/snippet}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import type { ComponentProps } from 'svelte';
2+
import { SettingsNavigationButton } from '..';
3+
import { ButtonIcon, ButtonText } from './SettingsNavigationButton.stories.snippet.svelte';
4+
5+
export default {
6+
title: 'UI/SettingsNavigationButton',
7+
component: SettingsNavigationButton,
8+
tags: ['autodocs'],
9+
render: (args: {
10+
Component: SettingsNavigationButton;
11+
props: ComponentProps<typeof SettingsNavigationButton>;
12+
}) => ({
13+
Component: SettingsNavigationButton,
14+
props: args
15+
})
16+
};
17+
18+
export const Primary = {
19+
args: {
20+
children: ButtonText,
21+
leadingIcon: ButtonIcon,
22+
onclick: () => alert('clicked'),
23+
hasTrailingIcon: true
24+
}
25+
};
26+
27+
export const Secondary = {
28+
args: {
29+
children: ButtonText,
30+
leadingIcon: ButtonIcon,
31+
onclick: () => alert('clicked'),
32+
hasTrailingIcon: false
33+
}
34+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<script lang="ts">
2+
import { cn } from '$lib/utils';
3+
import { ArrowRight01Icon } from '@hugeicons/core-free-icons';
4+
import { HugeiconsIcon } from '@hugeicons/svelte';
5+
import type { Snippet } from 'svelte';
6+
import type { HTMLButtonAttributes } from 'svelte/elements';
7+
8+
interface ISettingsNaviationButtonProps extends HTMLButtonAttributes {
9+
leadingIcon?: Snippet;
10+
children: Snippet;
11+
onclick: () => void;
12+
hasTrailingIcon: boolean;
13+
}
14+
15+
let {
16+
leadingIcon,
17+
children,
18+
onclick,
19+
hasTrailingIcon = true,
20+
...restProps
21+
}: ISettingsNaviationButtonProps = $props();
22+
23+
const cBase = 'flex w-full items-center justify-between';
24+
</script>
25+
26+
<button {...restProps} class={cn([cBase, restProps.class].join(' '))} {onclick}>
27+
<div class="flex items-center gap-2">
28+
{#if leadingIcon}
29+
<div
30+
class="bg-brand-burnt-orange-100 flex h-10 w-10 items-center justify-center rounded-full"
31+
>
32+
{@render leadingIcon?.()}
33+
</div>
34+
{/if}
35+
<h3 class="text-black-800 font-semibold">
36+
{@render children?.()}
37+
</h3>
38+
</div>
39+
{#if hasTrailingIcon}
40+
<HugeiconsIcon icon={ArrowRight01Icon} color="var(--color-black-400)" />
41+
{/if}
42+
</button>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as SettingsNavigationButton } from './SettingsNavigationButton/SettingsNavigationButton.svelte';

0 commit comments

Comments
 (0)