-
Notifications
You must be signed in to change notification settings - Fork 4
Feat/#32 identity card fragment #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c3f8c13
identity card
ananyayaya129 a6648a1
identity card
ananyayaya129 a4ebe16
identity card
ananyayaya129 408125b
identity cards created for main page
ananyayaya129 ed4cf16
identity cards created for main page
ananyayaya129 47a4768
lint fixski
ananyayaya129 bc9931e
lint fixski
ananyayaya129 40ab0a1
lint fixski
ananyayaya129 76d5bdd
fixed the font weight
ananyayaya129 499aa0c
added component to index.ts
ananyayaya129 d16a888
changed span to buttton
ananyayaya129 68e63e9
changed span to buttton
ananyayaya129 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
infrastructure/eid-wallet/src/lib/fragments/IdentityCard/IdentityCard.stories.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import IdentityCard from "./IdentityCard.svelte"; | ||
|
||
interface userData { | ||
[fieldName: string]: string; | ||
} | ||
|
||
export default { | ||
title: "UI/IdentityCard", | ||
component: IdentityCard, | ||
tags: ["autodocs"], | ||
render: (args: { | ||
variant: string; | ||
userId: string; | ||
shareBtn: () => void; | ||
viewBtn: () => void; | ||
userData: userData; | ||
usedStorage: number; | ||
totalStorage: number; | ||
}) => ({ | ||
Component: IdentityCard, | ||
props: args, | ||
}), | ||
}; | ||
|
||
export const eName = { | ||
args: { | ||
variant: "eName", | ||
userId: "ananyayayayaya", | ||
shareBtn: () => alert("Share"), | ||
viewBtn: () => alert("View"), | ||
}, | ||
}; | ||
|
||
export const ePassport = { | ||
args: { | ||
variant: "ePassport", | ||
viewBtn: () => alert("View"), | ||
userData: { | ||
Name: "Ananya", | ||
Dob: "29 Nov 2003", | ||
Nationality: "Indian", | ||
Passport: "234dfvgsdfg", | ||
}, | ||
}, | ||
}; | ||
|
||
export const eVault = { | ||
args: { | ||
variant: "eVault", | ||
usedStorage: "15", | ||
totalStorage: "80", | ||
}, | ||
}; |
108 changes: 108 additions & 0 deletions
108
infrastructure/eid-wallet/src/lib/fragments/IdentityCard/IdentityCard.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<script lang="ts"> | ||
import { | ||
CheckmarkBadge02Icon, | ||
Upload03Icon, | ||
ViewIcon, | ||
} from "@hugeicons/core-free-icons"; | ||
import { HugeiconsIcon } from "@hugeicons/svelte"; | ||
import type { HTMLAttributes } from "svelte/elements"; | ||
|
||
interface userData { | ||
[fieldName: string]: string; | ||
} | ||
interface IIdentityCard extends HTMLAttributes<HTMLElement> { | ||
variant?: "eName" | "ePassport" | "eVault"; | ||
userId?: string; | ||
viewBtn?: () => void; | ||
shareBtn?: () => void; | ||
userData?: userData; | ||
totalStorage?: number; | ||
usedStorage?: number; | ||
} | ||
|
||
let { | ||
variant = "eName", | ||
userId, | ||
viewBtn, | ||
shareBtn, | ||
userData, | ||
totalStorage = 0, | ||
usedStorage = 0, | ||
...restProps | ||
}: IIdentityCard = $props(); | ||
const state = $state({ | ||
progressWidth: "0%", | ||
}); | ||
|
||
$effect(() => { | ||
state.progressWidth = | ||
usedStorage > 0 ? `${(usedStorage / totalStorage) * 100}%` : "0%"; | ||
}); | ||
</script> | ||
|
||
<div {...restProps} class="relative {variant === 'eName' ? "bg-black-900" : variant === 'ePassport' ? "bg-primary" : "bg-gray"} rounded-xl w-full min-h-[150px] text-white shadow-lg overflow-hidden"> | ||
<div class="w-full h-full pointer-events-none flex gap-13 justify-end absolute right-15 bottom-20"> | ||
<div class="w-10 {variant === 'eVault' ? "bg-white/40" : "bg-white/10"} h-[300%] rotate-40"></div> | ||
<div class="w-10 {variant === 'eVault' ? "bg-white/40" : "bg-white/10"} h-[300%] rotate-40"></div> | ||
</div> | ||
<div class="p-5 flex flex-col gap-2"> | ||
<div class="flex justify-between"> | ||
{#if variant === 'eName'} | ||
<HugeiconsIcon size={30} strokeWidth={2} color="var(--color-secondary)" icon={CheckmarkBadge02Icon} /> | ||
<!-- svelte-ignore a11y_click_events_have_key_events --> | ||
<div class="flex gap-3 items-center"> | ||
<!-- svelte-ignore a11y_click_events_have_key_events --> | ||
<!-- svelte-ignore a11y_no_static_element_interactions --> | ||
<span class="flex justify-start" onclick={shareBtn}> | ||
<HugeiconsIcon size={30} strokeWidth={2} color="white" icon={Upload03Icon} /> | ||
</span> | ||
<!-- svelte-ignore a11y_click_events_have_key_events --> | ||
<!-- svelte-ignore a11y_no_static_element_interactions --> | ||
<span class="flex justify-start" onclick={viewBtn}> | ||
<HugeiconsIcon size={30} strokeWidth={2} color="white" icon={ViewIcon} /> | ||
</span> | ||
</div> | ||
{:else if variant === 'ePassport'} | ||
<p class="bg-white text-black flex items-center rounded-4xl px-5 py-2 text-xs font-semibold">HIGH SECURITY</p> | ||
<!-- svelte-ignore a11y_click_events_have_key_events --> | ||
<!-- svelte-ignore a11y_no_static_element_interactions --> | ||
<span class="flex justify-start" onclick={viewBtn}> | ||
<HugeiconsIcon size={30} strokeWidth={2} color="white" icon={ViewIcon} /> | ||
</span> | ||
{:else if variant === 'eVault'} | ||
<div class="text-black-300 text-3xl mb-3">{state.progressWidth} Used</div> | ||
{/if} | ||
</div> | ||
<div> | ||
{#if variant === "eName"} | ||
<h2 class="text-md text-gray font-light">Your eName</h2> | ||
<div class="flex items-center justify-between w-full"> | ||
<p class="text-white w-[60%] font-medium">@{userId}</p> | ||
</div> | ||
{:else if variant === "ePassport"} | ||
<div class="flex gap-2 flex-col"> | ||
{#if userData} | ||
{#each Object.entries(userData) as [fieldName, value] } | ||
<div class="flex justify-between"> | ||
<div class="text-md font-normal text-gray">{fieldName}</div> | ||
<div class="text-md font-medium text-white">{value}</div> | ||
</div> | ||
{/each} | ||
{/if} | ||
</div> | ||
{:else if variant === "eVault"} | ||
<div> | ||
<div class="flex justify-between text-black mb-1"> | ||
<div>{usedStorage}GB Used</div> | ||
<div>{totalStorage}GB Used</div> | ||
</div> | ||
<div class="relative w-full h-3 rounded-full overflow-hidden bg-primary-400"> | ||
<div class="h-full bg-secondary rounded-full" style={`width: calc(${state.progressWidth})`}></div> | ||
</div> | ||
</div> | ||
{/if} | ||
</div> | ||
</div> | ||
</div> | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { default as Header } from "./Header/Header.svelte"; | ||
export { default as IdentityCard } from "./IdentityCard/IdentityCard.svelte"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.