From 5246db4ccf769cc9ade6028f5facf91e490905ab Mon Sep 17 00:00:00 2001 From: Hunter Johnston Date: Sat, 24 Feb 2024 21:34:36 -0500 Subject: [PATCH] could be simpler but it works --- .../mail/(components)/account-switcher.svelte | 49 +++++++++---------- .../mail/(components)/icons/gmail.svelte | 15 ++++++ .../mail/(components)/icons/icloud.svelte | 15 ++++++ .../mail/(components)/icons/vercel.svelte | 12 +++++ apps/www/src/routes/examples/mail/data.ts | 25 ++++++---- 5 files changed, 81 insertions(+), 35 deletions(-) create mode 100644 apps/www/src/routes/examples/mail/(components)/icons/gmail.svelte create mode 100644 apps/www/src/routes/examples/mail/(components)/icons/icloud.svelte create mode 100644 apps/www/src/routes/examples/mail/(components)/icons/vercel.svelte diff --git a/apps/www/src/routes/examples/mail/(components)/account-switcher.svelte b/apps/www/src/routes/examples/mail/(components)/account-switcher.svelte index 776e1400e..8b5bd1871 100644 --- a/apps/www/src/routes/examples/mail/(components)/account-switcher.svelte +++ b/apps/www/src/routes/examples/mail/(components)/account-switcher.svelte @@ -17,37 +17,34 @@ }} > div>svg]:hidden": isCollapsed, - })} + class={cn( + "flex items-center gap-2 [&>span]:line-clamp-1 [&>span]:flex [&>span]:w-full [&>span]:items-center [&>span]:gap-1 [&>span]:truncate [&_svg]:h-4 [&_svg]:w-4 [&_svg]:shrink-0", + isCollapsed && + "flex h-9 w-9 shrink-0 items-center justify-center p-0 [&>div>svg]:hidden [&>span]:w-auto" + )} aria-label="Select account" > - account.email === selectedAccount.email)?.icon} - aria-hidden="true" - class={cn("size-4 shrink-0")} - /> - + + + + {selectedAccount.label} + + - + {#each accounts as account} - span]:hidden": isCollapsed })} - > - diff --git a/apps/www/src/routes/examples/mail/(components)/icons/gmail.svelte b/apps/www/src/routes/examples/mail/(components)/icons/gmail.svelte new file mode 100644 index 000000000..efd3608e7 --- /dev/null +++ b/apps/www/src/routes/examples/mail/(components)/icons/gmail.svelte @@ -0,0 +1,15 @@ + + + + Gmail + + diff --git a/apps/www/src/routes/examples/mail/(components)/icons/icloud.svelte b/apps/www/src/routes/examples/mail/(components)/icons/icloud.svelte new file mode 100644 index 000000000..3c8d8c663 --- /dev/null +++ b/apps/www/src/routes/examples/mail/(components)/icons/icloud.svelte @@ -0,0 +1,15 @@ + + + + iCloud + + diff --git a/apps/www/src/routes/examples/mail/(components)/icons/vercel.svelte b/apps/www/src/routes/examples/mail/(components)/icons/vercel.svelte new file mode 100644 index 000000000..ecda38ea9 --- /dev/null +++ b/apps/www/src/routes/examples/mail/(components)/icons/vercel.svelte @@ -0,0 +1,12 @@ + + + + Vercel + + diff --git a/apps/www/src/routes/examples/mail/data.ts b/apps/www/src/routes/examples/mail/data.ts index b6e70e726..40902e5c7 100644 --- a/apps/www/src/routes/examples/mail/data.ts +++ b/apps/www/src/routes/examples/mail/data.ts @@ -1,6 +1,9 @@ -import Cloud from "lucide-svelte/icons/cloud"; -import { Mail as Mail_Icon } from "lucide-svelte"; -import Triangle from "lucide-svelte/icons/triangle"; +import Vercel from "./(components)/icons/vercel.svelte"; +import ICloud from "./(components)/icons/icloud.svelte"; +import Gmail from "./(components)/icons/gmail.svelte"; + +import type { ComponentType } from "svelte"; +import type { Icon } from "lucide-svelte"; export const mails = [ { @@ -177,26 +180,30 @@ export const mails = [ export type Mail = (typeof mails)[number]; -export const accounts = [ +export type Account = { + label: string; + email: string; + icon: ComponentType; +}; + +export const accounts: Account[] = [ { label: "Alicia Koch", email: "alicia@example.com", - icon: Triangle, + icon: Vercel, }, { label: "Alicia Koch", email: "alicia@gmail.com", - icon: Mail_Icon, + icon: Gmail, }, { label: "Alicia Koch", email: "alicia@me.com", - icon: Cloud, + icon: ICloud, }, ]; -export type Account = (typeof accounts)[number]; - export const contacts = [ { name: "Emma Johnson",