From 077c2aa572db069234560d175014b9a5bbd6565e Mon Sep 17 00:00:00 2001 From: Chanatip Kowsurat <141796254+NhongSun@users.noreply.github.com> Date: Thu, 16 Jan 2025 21:36:05 +0700 Subject: [PATCH] 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 --- apps/web/src/routes/+page.svelte | 7 +++ .../atom/collapsible/collapsible.svelte | 10 +++- .../components/molecule/user-dialog/index.ts | 7 +++ .../user-dialog/user-dialog.stories.svelte | 30 +++++++++++ .../molecule/user-dialog/user-dialog.svelte | 50 +++++++++++++++++++ .../components/organism/navbar/navbar.svelte | 8 +-- packages/utils/src/index.ts | 1 + 7 files changed, 107 insertions(+), 6 deletions(-) create mode 100644 packages/ui/src/components/molecule/user-dialog/index.ts create mode 100644 packages/ui/src/components/molecule/user-dialog/user-dialog.stories.svelte create mode 100644 packages/ui/src/components/molecule/user-dialog/user-dialog.svelte diff --git a/apps/web/src/routes/+page.svelte b/apps/web/src/routes/+page.svelte index 0510cb604..0eb32651a 100644 --- a/apps/web/src/routes/+page.svelte +++ b/apps/web/src/routes/+page.svelte @@ -7,6 +7,7 @@ import { Input } from '@repo/ui/atom/input' import { RecommendedTag } from '@repo/ui/atom/recommended-tag' import { CourseCard } from '@repo/ui/molecule/course-card' + import { UserDialog } from '@repo/ui/molecule/user-dialog' import { Navbar } from '@repo/ui/organism/navbar' let counter = $state(0) @@ -71,4 +72,10 @@ + + Click to go to DB Demo diff --git a/packages/ui/src/components/atom/collapsible/collapsible.svelte b/packages/ui/src/components/atom/collapsible/collapsible.svelte index 9b181f8ed..9bdacc1e7 100644 --- a/packages/ui/src/components/atom/collapsible/collapsible.svelte +++ b/packages/ui/src/components/atom/collapsible/collapsible.svelte @@ -1,9 +1,15 @@ @@ -17,6 +23,6 @@ class="absolute top-8 right-0 w-28 bg-surface-container border-b-neutral-400 rounded-md" transition={slide} > - + {@render children?.()} diff --git a/packages/ui/src/components/molecule/user-dialog/index.ts b/packages/ui/src/components/molecule/user-dialog/index.ts new file mode 100644 index 000000000..e76de75d3 --- /dev/null +++ b/packages/ui/src/components/molecule/user-dialog/index.ts @@ -0,0 +1,7 @@ +import Root from './user-dialog.svelte' + +export { + Root, + // + Root as UserDialog, +} diff --git a/packages/ui/src/components/molecule/user-dialog/user-dialog.stories.svelte b/packages/ui/src/components/molecule/user-dialog/user-dialog.stories.svelte new file mode 100644 index 000000000..f3148a0db --- /dev/null +++ b/packages/ui/src/components/molecule/user-dialog/user-dialog.stories.svelte @@ -0,0 +1,30 @@ + + + diff --git a/packages/ui/src/components/molecule/user-dialog/user-dialog.svelte b/packages/ui/src/components/molecule/user-dialog/user-dialog.svelte new file mode 100644 index 000000000..b85f2c8ad --- /dev/null +++ b/packages/ui/src/components/molecule/user-dialog/user-dialog.svelte @@ -0,0 +1,50 @@ + + +
+
+ Profile +
+

{shortenedName}

+

ID: {id}

+
+
+ {#each items as { icon: Icon, name }} +
+ +

{name}

+
+ {/each} +
diff --git a/packages/ui/src/components/organism/navbar/navbar.svelte b/packages/ui/src/components/organism/navbar/navbar.svelte index 5cdaf9421..01d44be36 100644 --- a/packages/ui/src/components/organism/navbar/navbar.svelte +++ b/packages/ui/src/components/organism/navbar/navbar.svelte @@ -1,7 +1,7 @@