Skip to content

Commit 27c6a65

Browse files
committed
feat: create root page + layout
1 parent 5bd1e25 commit 27c6a65

File tree

7 files changed

+124
-30
lines changed

7 files changed

+124
-30
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ $effect(() => {
5555
<Button.Icon icon={ViewIcon} iconColor={"white"} strokeWidth={2} onclick={viewBtn} />
5656
</div>
5757
{:else if variant === 'ePassport'}
58-
<p class="bg-white text-black flex items-center rounded-4xl px-5 py-2 text-xs font-semibold">HIGH SECURITY</p>
58+
<p class="bg-white text-black flex items-center leading-0 justify-center rounded-full h-7 px-5 text-xs font-medium">HIGH SECURITY</p>
5959
<Button.Icon icon={ViewIcon} iconColor={"white"} strokeWidth={2} onclick={viewBtn} />
6060

6161
{:else if variant === 'eVault'}
@@ -64,9 +64,9 @@ $effect(() => {
6464
</div>
6565
<div>
6666
{#if variant === "eName"}
67-
<p class="text-gray font-light">Your eName</p>
67+
<p class="text-gray font-normal">Your eName</p>
6868
<div class="flex items-center justify-between w-full">
69-
<p class="text-white w-[60%] font-medium">@{userId}</p>
69+
<p class="text-white w-full font-medium">@{userId}</p>
7070
</div>
7171
{:else if variant === "ePassport"}
7272
<div class="flex gap-2 flex-col">

infrastructure/eid-wallet/src/lib/ui/Drawer/Drawer.svelte

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,6 @@ $effect(() => {
5353
5454
return () => pane.destroy();
5555
});
56-
57-
$effect(() => {
58-
if (isPaneOpen) {
59-
pane.present({ animate: true });
60-
} else {
61-
pane.destroy({ animate: true });
62-
}
63-
drawerElem.addEventListener("click_outside", () => {
64-
handleClickOutside();
65-
});
66-
});
6756
</script>
6857

6958
<div
@@ -74,7 +63,7 @@ $effect(() => {
7463
})}
7564
onswipe={() => handleSwipe?.(isPaneOpen)}
7665
bind:this={drawerElem}
77-
use:clickOutside
66+
use:clickOutside={handleClickOutside}
7867
class={cn(restProps.class)}
7968
>
8069
<div class="px-6">

infrastructure/eid-wallet/src/lib/utils/clickOutside.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/** Dispatch event on click outside of node */
2-
export const clickOutside = (node: HTMLElement) => {
2+
export const clickOutside = (node: HTMLElement, callback: () => void) => {
33
const handleClick = (event: Event) => {
4-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
5-
// @ts-ignore
6-
if (node && !node.contains(event.target) && !event.defaultPrevented) {
7-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
8-
// @ts-ignore
9-
node.dispatchEvent(new CustomEvent("click_outside", node));
4+
if (
5+
node &&
6+
!node.contains(event.target as Node) &&
7+
!event.defaultPrevented
8+
) {
9+
callback(); // Call the provided callback
10+
node.dispatchEvent(new CustomEvent("click_outside"));
1011
}
1112
};
1213

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<script lang="ts">
2+
import type { Snippet } from "svelte";
3+
import type { LayoutData } from "./$types";
4+
5+
let { data, children }: { data: LayoutData; children: Snippet } = $props();
6+
</script>
7+
8+
<div class="p-6 mb-16">
9+
{@render children()}
10+
</div>
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<script lang="ts">
2+
import { Hero, IdentityCard } from "$lib/fragments";
3+
import { Drawer } from "$lib/ui";
4+
import * as Button from "$lib/ui/Button";
5+
import { QrCodeIcon } from "@hugeicons/core-free-icons";
6+
import { HugeiconsIcon } from "@hugeicons/svelte";
7+
import type { Snippet } from "svelte";
8+
9+
const dummyData = {
10+
Name: "John Doe",
11+
"Date of birth": "01 - 01 - 1990",
12+
"ID submitted": "American Passport",
13+
"Passport number": "1234567-US",
14+
};
15+
16+
let shareQRdrawerOpen = $state(false);
17+
18+
function shareQR() {
19+
alert("QR Code shared!");
20+
shareQRdrawerOpen = false;
21+
}
22+
</script>
23+
24+
25+
<Hero
26+
title="Good morning!"
27+
subtitle="Don't forget to drink water."
28+
showSettings
29+
/>
30+
31+
{#snippet Section(title: string, children: Snippet)}
32+
<section class="mt-8">
33+
<h4 class="mb-2">{title}</h4>
34+
{@render children()}
35+
</section>
36+
{/snippet}
37+
38+
{#snippet eName()}
39+
<IdentityCard
40+
variant="eName"
41+
userId="caa0f630-2413-5aceaa2c-4628ce93e497"
42+
viewBtn={() => alert("View button clicked!")}
43+
shareBtn={() => shareQRdrawerOpen = true}
44+
/>
45+
{/snippet}
46+
{#snippet ePassport()}
47+
<IdentityCard
48+
variant="ePassport"
49+
viewBtn={() => alert("View button clicked!")}
50+
userData={dummyData}
51+
/>
52+
{/snippet}
53+
{#snippet eVault()}
54+
<IdentityCard
55+
variant="eVault"
56+
usedStorage={15}
57+
totalStorage={100}
58+
/>
59+
{/snippet}
60+
61+
{@render Section("eName", eName)}
62+
{@render Section("ePassport", ePassport)}
63+
{@render Section("eVault", eVault)}
64+
65+
<Drawer
66+
title="Scan QR Code"
67+
bind:isPaneOpen={shareQRdrawerOpen}
68+
isCancelRequired={true}
69+
class="flex flex-col gap-4 items-center justify-center"
70+
>
71+
<div class="flex justify-center relative items-center overflow-hidden h-full bg-gray rounded-3xl p-8">
72+
<div class="bg-white h-[72px] w-[1000px] -rotate-45 absolute top-4"></div>
73+
<div class="bg-white h-[72px] w-[1000px] -rotate-45 absolute bottom-4"></div>
74+
<img class="z-10" src="/images/dummyQR.png" alt="QR Code" />
75+
</div>
76+
77+
<h4 class="text-center">Share your eName</h4>
78+
<p class="text-black-700 text-center">Anyone scanning this can see your eName</p>
79+
<div class="flex justify-center items-center mt-4">
80+
<Button.Action
81+
variant="solid"
82+
callback={shareQR}
83+
class="w-full"
84+
>
85+
Share
86+
</Button.Action>
87+
</div>
88+
</Drawer>
89+
90+
<Button.Action
91+
variant="solid"
92+
onclick={() => alert("Action button clicked!")}
93+
class="mx-auto text-nowrap flex gap-8 fixed bottom-5 left-1/2 -translate-x-1/2 z-10"
94+
>
95+
<HugeiconsIcon
96+
size={32}
97+
strokeWidth={2}
98+
className="mr-2"
99+
icon={QrCodeIcon}
100+
/>
101+
Scan to Login
102+
</Button.Action>

infrastructure/eid-wallet/src/routes/+page.svelte

Lines changed: 0 additions & 8 deletions
This file was deleted.
4.39 KB
Loading

0 commit comments

Comments
 (0)