Skip to content

Commit e018910

Browse files
authored
feat: add Hero fragment (#88)
* feat: add Hero fragment * chore: sort imports + add doc
1 parent 8fcd64e commit e018910

File tree

12 files changed

+147
-102
lines changed

12 files changed

+147
-102
lines changed

infrastructure/eid-wallet/src/app.css

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@
1111
@layer base {
1212
/* Typography */
1313
h1 {
14-
@apply text-[90px] text-black font-semibold;
14+
@apply text-[90px]/[1.5] text-black font-semibold;
1515
}
1616

1717
h2 {
18-
@apply text-6xl text-black font-semibold;
18+
@apply text-6xl/[1.5] text-black font-semibold;
1919
}
2020

2121
h3 {
22-
@apply text-3xl text-black font-semibold;
22+
@apply text-3xl/[1.5] text-black font-semibold;
2323
}
2424

2525
h4 {
26-
@apply text-xl text-black font-semibold;
26+
@apply text-xl/[1.5] text-black font-semibold;
2727
}
2828

2929
p {
30-
@apply text-base text-black font-normal;
30+
@apply text-base/[1.5] text-black font-normal;
3131
}
3232

3333
.small {
34-
@apply text-xs text-black font-normal;
34+
@apply text-xs/[1.5] text-black font-normal;
3535
}
3636
}
3737

infrastructure/eid-wallet/src/lib/fragments/Header/Header.stories.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

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

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import type { ComponentProps } from "svelte";
2+
import Hero from "./Hero.svelte";
3+
4+
export default {
5+
title: "Fragments/Hero",
6+
component: Hero,
7+
tags: ["autodocs"],
8+
render: (args: {
9+
Component: Hero;
10+
props: ComponentProps<typeof Hero>;
11+
}) => ({
12+
Component: Hero,
13+
props: args,
14+
}),
15+
};
16+
17+
export const Basic = {
18+
args: {
19+
title: "Create PIN",
20+
subtitle: "Create a PIN to protect your wallet",
21+
},
22+
};
23+
24+
export const WithSettings = {
25+
args: {
26+
title: "Good morning!",
27+
subtitle: "Don't forget to drink water.",
28+
titleClasses: "-mb-2",
29+
showSettings: true,
30+
},
31+
};
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<script lang="ts">
2+
import * as Button from "$lib/ui/Button";
3+
import { cn } from "$lib/utils";
4+
import { Settings02Icon } from "@hugeicons/core-free-icons";
5+
import type { HTMLAttributes } from "svelte/elements";
6+
7+
interface IHeroProps extends HTMLAttributes<HTMLElement> {
8+
title?: string;
9+
subtitle?: string;
10+
showSettings?: boolean;
11+
titleClasses?: string;
12+
}
13+
const {
14+
title,
15+
subtitle,
16+
showSettings = false,
17+
titleClasses,
18+
children,
19+
...restProps
20+
}: IHeroProps = $props();
21+
const baseClasses = "w-full flex justify-between items-center";
22+
</script>
23+
24+
<header {...restProps} class={cn(baseClasses, restProps.class)}>
25+
<div class="flex flex-col items-start">
26+
<h3 class={cn(titleClasses)}>
27+
{@render children?.()}
28+
{title}
29+
</h3>
30+
{#if subtitle}
31+
<p class="text-black-700 mt-2">{subtitle}</p>
32+
{/if}
33+
</div>
34+
{#if showSettings}
35+
<Button.Nav href="/settings">
36+
<Button.Icon
37+
icon={Settings02Icon}
38+
iconSize="lg"
39+
/>
40+
</Button.Nav>
41+
{:else}
42+
<span aria-hidden="true"></span>
43+
{/if}
44+
</header>
45+
46+
<!--
47+
@component
48+
@name Hero
49+
@description A component that displays a header with a title, subtitle, and optional settings icon.
50+
@props
51+
- title: string - The main title to display.
52+
- subtitle: string - An optional subtitle to display below the title.
53+
- showSettings: boolean - A flag to determine if the settings icon should be displayed.
54+
- titleClasses: string - Additional classes to apply to the title element.
55+
- children: Snippet - Optional child elements to render within the title.
56+
@slots
57+
- default - Slot for additional content to be rendered within the title.
58+
@usage
59+
```svelte
60+
<Hero
61+
title="Good morning!"
62+
subtitle="Don't forget to drink water."
63+
class="mb-8"
64+
titleClasses="-mb-2"
65+
showSettings
66+
>
67+
</Hero>
68+
```
69+
-->

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ $effect(() => {
4141
});
4242
</script>
4343

44-
<div {...restProps} class="relative {variant === 'eName' ? "bg-black-900" : variant === 'ePassport' ? "bg-primary" : "bg-gray"} rounded-xl w-full min-h-[150px] text-white overflow-hidden">
44+
<div {...restProps} class="relative {variant === 'eName' ? "bg-black-900" : variant === 'ePassport' ? "bg-primary" : "bg-gray"} rounded-3xl w-full min-h-[150px] text-white overflow-hidden">
4545
<div class="w-full h-full pointer-events-none flex gap-13 justify-end absolute right-15 bottom-20">
4646
<div class="w-10 {variant === 'eVault' ? "bg-white/40" : "bg-white/10"} h-[300%] rotate-40"></div>
4747
<div class="w-10 {variant === 'eVault' ? "bg-white/40" : "bg-white/10"} h-[300%] rotate-40"></div>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export { default as Header } from "./Header/Header.svelte";
1+
export { default as Hero } from "./Hero/Hero.svelte";
22
export { default as IdentityCard } from "./IdentityCard/IdentityCard.svelte";
33
export { default as SettingsNavigationBtn } from "./SettingsNavigationBtn/SettingsNavigationBtn.svelte";

infrastructure/eid-wallet/src/routes/(auth)/e-passport/+page.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script lang="ts">
2+
import { Hero } from "$lib/fragments";
23
import IdentityCard from "$lib/fragments/IdentityCard/IdentityCard.svelte";
34
import { ButtonAction } from "$lib/ui";
45
@@ -20,8 +21,11 @@ const handleFinish = async () => {};
2021
}}/>
2122
</section>
2223
<section class="mt-[4vh] mb-[9vh]">
23-
<h4 class="mb-[0.5vh]">Your eVault</h4>
24-
<p class="text-black-700 mb-[3vh]">We’ve also created your eVault—secure cloud storage for your personal data. W3DS platforms access it directly, keeping you in control.</p>
24+
<Hero
25+
title="Your ePassport and eVault are ready"
26+
subtitle="Log into any W3DS platform without passwords. It’s tied to this phone; if lost, you’ll need to revoke and reissue it on a new device."
27+
class="mb-2"
28+
/>
2529
<IdentityCard variant= "eVault"
2630
usedStorage= {15}
2731
totalStorage= {80}/>

infrastructure/eid-wallet/src/routes/(auth)/onboarding/+page.svelte

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts">
22
import { goto } from "$app/navigation";
3+
import { Hero } from "$lib/fragments";
34
import { ButtonAction, Drawer } from "$lib/ui";
45
56
let isPaneOpen = $state(false);
@@ -20,10 +21,15 @@ const handleNext = async () => {
2021
<img class="aspect-square w-full object-cover" src="/images/Onboarding.svg" alt="Infographic card">
2122
</article>
2223
<section class="mb-[9.3vh]">
23-
<h2 class="text-[42px]/[1] font-medium mb-[1vh]">Your <br>
24+
<Hero
25+
subtitle="Store your IDs, verify instantly with QR codes, and manage your digital identity with ease."
26+
class="mb-4"
27+
titleClasses="text-[42px]/[1.1] font-medium"
28+
>
29+
Your <br>
2430
Digital Identity,
25-
Secured</h2>
26-
<p class="text-black-700">Store your IDs, verify instantly with QR codes, and manage your digital identity with ease.</p>
31+
Secured
32+
</Hero>
2733
</section>
2834
<section>
2935
<p class="max-w-[300px] mx-[auto] text-center small text-black-500">By continuing you agree to our <a href="/" class="text-primary underline underline-offset-5">Terms & Conditions </a> and <a href="/" class="text-primary underline underline-offset-5">privacy policy.</a></p>

infrastructure/eid-wallet/src/routes/(auth)/register/+page.svelte

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts">
22
import { goto } from "$app/navigation";
3+
import { Hero } from "$lib/fragments";
34
import { ButtonAction, Drawer, InputPin } from "$lib/ui";
45
import { CircleLock01Icon, FaceIdIcon } from "@hugeicons/core-free-icons";
56
import { HugeiconsIcon } from "@hugeicons/svelte";
@@ -55,17 +56,23 @@ $effect(() => {
5556
{#if firstStep}
5657
<main class="h-screen pt-[5.2vh] px-[5vw] pb-[4.5vh] flex flex-col justify-between">
5758
<section>
58-
<h3 class="mb-[1vh]">Create a pin</h3>
59-
<p class="text-black-700 mb-[14vh]">Enter a 4-digit PIN code</p>
59+
<Hero
60+
title="Create a pin"
61+
subtitle="Enter a 4-digit PIN code"
62+
class="mb-[14vh]"
63+
/>
6064
<InputPin bind:pin/>
6165
</section>
6266
<ButtonAction class="w-full" variant="soft" callback={handleFirstStep}>Confirm</ButtonAction>
6367
</main>
6468
{:else}
6569
<main class="h-screen pt-[5.2vh] px-[5vw] pb-[4.5vh] flex flex-col justify-between">
6670
<section>
67-
<h3 class="mb-[1vh]">Re-enter your pin</h3>
68-
<p class="text-black-700 mb-[14vh]">Confirm by entering pin again</p>
71+
<Hero
72+
title="Re-enter your pin"
73+
subtitle="Confirm by entering pin again"
74+
class="mb-[14vh]"
75+
/>
6976
<InputPin bind:pin={repeatPin} {isError}/>
7077
<p class={`text-danger mt-[3.4vh] ${isError ? "block" : "hidden"}`}>Your PIN does not match, try again.</p>
7178
</section>

0 commit comments

Comments
 (0)