Skip to content

Commit 8d7f510

Browse files
authored
update: use ButtonIcon is IdentityCard (#78)
* update: use ButtonIcon is IdentityCard * feat: refactor ButtonIcon to be used anywhere in the app * chore: format indent * chore: remove useless change
1 parent 5fe5c93 commit 8d7f510

File tree

4 files changed

+165
-133
lines changed

4 files changed

+165
-133
lines changed
Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
2+
import * as Button from "$lib/ui/Button";
23
import { cn } from "$lib/utils";
34
import { ArrowLeft01Icon, UserCircleIcon } from "@hugeicons/core-free-icons";
4-
import { HugeiconsIcon } from "@hugeicons/svelte";
55
import type { HTMLAttributes } from "svelte/elements";
66
77
interface IHeaderProps extends HTMLAttributes<HTMLElement> {
@@ -11,7 +11,7 @@ interface IHeaderProps extends HTMLAttributes<HTMLElement> {
1111
handleProfile?: () => void;
1212
}
1313
14-
let {
14+
const {
1515
title = "Create PIN",
1616
isUserLoggedIn = true,
1717
isBackRequired = true,
@@ -23,20 +23,14 @@ const cBase = "w-full h-[9vh] flex justify-between items-center";
2323

2424
<header {...restProps} class={cn(cBase, restProps.class)}>
2525
{#if isBackRequired}
26-
<button class="flex justify-start" onclick={() => window.history.back()}>
27-
<HugeiconsIcon size="5.5vw" color="var(--color-black-700)" icon={ArrowLeft01Icon} />
28-
</button>
26+
<Button.Icon icon={ArrowLeft01Icon} iconSize="5.5vw" iconColor={"text-black-700"} onclick={() => window.history.back()} />
2927
{:else}
30-
<!-- svelte-ignore element_invalid_self_closing_tag -->
31-
<span aria-hidden="true"/>
28+
<span aria-hidden="true"></span>
3229
{/if}
3330
<h3 class="text-center">{title}</h3>
3431
{#if isUserLoggedIn}
35-
<button class="flex justify-end" onclick={handleProfile}>
36-
<HugeiconsIcon size="8.1vw" color="var(--color-black-700)" icon={UserCircleIcon} />
37-
</button>
32+
<Button.Icon icon={UserCircleIcon} iconSize="8.1vw" iconColor={"text-black-700"} onclick={handleProfile} />
3833
{:else}
39-
<!-- svelte-ignore element_invalid_self_closing_tag -->
40-
<span aria-hidden="true"/>
34+
<span aria-hidden="true"></span>
4135
{/if}
4236
</header>

infrastructure/eid-wallet/src/lib/fragments/IdentityCard/IdentityCard.svelte

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script lang="ts">
2+
import * as Button from "$lib/ui/Button";
23
import {
34
CheckmarkBadge02Icon,
45
Upload03Icon,
@@ -20,7 +21,7 @@ interface IIdentityCard extends HTMLAttributes<HTMLElement> {
2021
usedStorage?: number;
2122
}
2223
23-
let {
24+
const {
2425
variant = "eName",
2526
userId,
2627
viewBtn,
@@ -48,22 +49,17 @@ $effect(() => {
4849
<div class="p-5 flex flex-col gap-2">
4950
<div class="flex justify-between">
5051
{#if variant === 'eName'}
51-
<HugeiconsIcon size={30} strokeWidth={2} color="var(--color-secondary)" icon={CheckmarkBadge02Icon} />
52-
<div class="flex gap-3 items-center">
53-
<button class="flex justify-start" onclick={shareBtn}>
54-
<HugeiconsIcon size={30} strokeWidth={2} color="white" icon={Upload03Icon} />
55-
</button>
56-
<button class="flex justify-start" onclick={viewBtn}>
57-
<HugeiconsIcon size={30} strokeWidth={2} color="white" icon={ViewIcon} />
58-
</button>
59-
</div>
52+
<HugeiconsIcon size={30} strokeWidth={2} className="text-secondary" icon={CheckmarkBadge02Icon} />
53+
<div class="flex gap-3 items-center">
54+
<Button.Icon icon={Upload03Icon} iconColor={"white"} strokeWidth={2} onclick={shareBtn} />
55+
<Button.Icon icon={ViewIcon} iconColor={"white"} strokeWidth={2} onclick={viewBtn} />
56+
</div>
6057
{:else if variant === 'ePassport'}
61-
<p class="bg-white flex items-center rounded-4xl px-5 py-2 small font-semibold">HIGH SECURITY</p>
62-
<button class="flex justify-start" onclick={viewBtn}>
63-
<HugeiconsIcon size={30} strokeWidth={2} color="white" icon={ViewIcon} />
64-
</button>
58+
<p class="bg-white text-black flex items-center rounded-4xl px-5 py-2 text-xs font-semibold">HIGH SECURITY</p>
59+
<Button.Icon icon={ViewIcon} iconColor={"white"} strokeWidth={2} onclick={viewBtn} />
60+
6561
{:else if variant === 'eVault'}
66-
<h3 class="text-black-300 font-semibold mb-3">{state.progressWidth} Used</h3>
62+
<div class="text-black-300 text-3xl mb-3">{state.progressWidth} Used</div>
6763
{/if}
6864
</div>
6965
<div>
@@ -98,4 +94,5 @@ $effect(() => {
9894
</div>
9995
</div>
10096

101-
97+
98+
Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
import { FlashlightIcon } from "@hugeicons/core-free-icons";
1+
import { FlashlightIcon, ViewIcon } from "@hugeicons/core-free-icons";
22
import type { ComponentProps } from "svelte";
33
import ButtonIcon from "./ButtonIcon.svelte";
44

55
export default {
66
title: "UI/ButtonIcon",
77
component: ButtonIcon,
88
tags: ["autodocs"],
9-
render: (args: {
10-
Component: ButtonIcon<{ icon: typeof FlashlightIcon }>;
11-
props: ComponentProps<typeof ButtonIcon>;
12-
}) => ({
9+
render: (args: ComponentProps<typeof ButtonIcon>) => ({
1310
Component: ButtonIcon,
1411
props: args,
1512
}),
@@ -19,10 +16,26 @@ export const Default = {
1916
render: () => ({
2017
Component: ButtonIcon,
2118
props: {
22-
variant: "white",
2319
ariaLabel: "Default button",
24-
size: "md",
20+
bgSize: "md", // Predefined size
21+
iconSize: "md",
22+
icon: ViewIcon,
23+
bgColor: "black",
24+
iconColor: "white",
25+
},
26+
}),
27+
};
28+
29+
export const CustomSize = {
30+
render: () => ({
31+
Component: ButtonIcon,
32+
props: {
33+
ariaLabel: "Custom sized button",
34+
bgSize: "w-[120px] h-[120px]", // Custom Tailwind size
35+
iconSize: 56, // Custom pixel size
2536
icon: FlashlightIcon,
37+
bgColor: "bg-danger",
38+
iconColor: "white",
2639
},
2740
}),
2841
};
@@ -31,24 +44,32 @@ export const Loading = {
3144
render: () => ({
3245
Component: ButtonIcon,
3346
props: {
34-
variant: "white",
3547
ariaLabel: "Loading button",
36-
size: "md",
48+
bgSize: "md",
49+
iconSize: "md",
3750
icon: FlashlightIcon,
3851
isLoading: true,
52+
bgColor: "black",
53+
iconColor: "white",
3954
},
4055
}),
4156
};
4257

43-
export const Active = {
58+
export const WithCallback = {
4459
render: () => ({
4560
Component: ButtonIcon,
4661
props: {
47-
variant: "white",
48-
ariaLabel: "Active button",
49-
size: "md",
62+
ariaLabel: "Button with async callback",
63+
bgSize: "md",
64+
iconSize: "md",
5065
icon: FlashlightIcon,
51-
isActive: true,
66+
callback: async () => {
67+
await new Promise((resolve) => setTimeout(resolve, 2000));
68+
console.log("Action completed!");
69+
},
70+
blockingClick: true,
71+
bgColor: "primary",
72+
iconColor: "white",
5273
},
5374
}),
5475
};

0 commit comments

Comments
 (0)