-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): user dialog - DEV-33 (#727)
* feat: init component * feat: user dialog * feat: story book * refactor: props * refactor: img & loops * refactor: styling * extract shorten name to another file * fix: image url example * feat: move to util function * fix: circle image profile * fix: use function from utils * fix: handle undefine props * fix: typing and default value * fix: shortenName function --------- Co-authored-by: Nutthapat Pongtanyavichai <contact@leomotors.me>
- Loading branch information
Showing
7 changed files
with
107 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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,7 @@ | ||
import Root from './user-dialog.svelte' | ||
|
||
export { | ||
Root, | ||
// | ||
Root as UserDialog, | ||
} |
30 changes: 30 additions & 0 deletions
30
packages/ui/src/components/molecule/user-dialog/user-dialog.stories.svelte
This file contains 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,30 @@ | ||
<script module lang="ts"> | ||
import { defineMeta } from '@storybook/addon-svelte-csf' | ||
import { UserDialog } from './index' | ||
const { Story } = defineMeta<typeof UserDialog>({ | ||
title: 'Molecule/User Dialog', | ||
component: UserDialog, | ||
tags: ['autodocs'], | ||
argTypes: { | ||
imageUrl: { | ||
control: 'text', | ||
}, | ||
name: { | ||
control: 'text', | ||
}, | ||
id: { | ||
control: 'text', | ||
}, | ||
}, | ||
}) | ||
</script> | ||
|
||
<Story | ||
name="Example" | ||
args={{ | ||
name: 'Wanrudee Kkk', | ||
id: '6XXXXXXXXX', | ||
}} | ||
/> |
50 changes: 50 additions & 0 deletions
50
packages/ui/src/components/molecule/user-dialog/user-dialog.svelte
This file contains 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,50 @@ | ||
<script lang="ts"> | ||
import { DoorOpen, Settings } from 'lucide-svelte' | ||
import { getShortenName } from '@repo/utils' | ||
interface Props { | ||
imageUrl?: string | ||
name?: string | ||
id?: string | ||
} | ||
let { | ||
imageUrl = 'https://upload.wikimedia.org/wikipedia/commons/a/ac/Default_pfp.jpg', | ||
name = '', | ||
id = '', | ||
}: Props = $props() | ||
let shortenedName = $derived(getShortenName(name)) | ||
const items = [ | ||
{ | ||
icon: Settings, | ||
name: 'ตั้งค่า', | ||
}, | ||
{ | ||
icon: DoorOpen, | ||
name: 'ออกจากระบบ', | ||
}, | ||
] | ||
</script> | ||
|
||
<div class="w-60 rounded-xl border-2 border-[#EDEDF1]"> | ||
<div class="flex flex-col justify-center items-center p-4 gap-4"> | ||
<img | ||
src={imageUrl} | ||
alt="Profile" | ||
class="rounded-full w-20 h-20 object-cover" | ||
/> | ||
<div class="flex flex-col gap-2 items-center"> | ||
<p class="text-on-surface text-h3 font-bold">{shortenedName}</p> | ||
<p class="text-on-surface text-body2 font-medium">ID: {id}</p> | ||
</div> | ||
</div> | ||
{#each items as { icon: Icon, name }} | ||
<div class="flex flex-row p-4 gap-3 items-center border-t border-[#EDEDF1]"> | ||
<Icon size="16" color="#353745" strokeWidth="2.5" /> | ||
<p class="text-on-surface font-medium text-button2">{name}</p> | ||
</div> | ||
{/each} | ||
</div> |
This file contains 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
This file contains 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 { getShortenName } from './name.js' | ||
export * from './ui.js' |