diff --git a/.storybook/decorators/OrgContextDecorator.svelte b/.storybook/decorators/OrgContextDecorator.svelte new file mode 100644 index 000000000..92fe35cdd --- /dev/null +++ b/.storybook/decorators/OrgContextDecorator.svelte @@ -0,0 +1,11 @@ + + + diff --git a/.storybook/decorators/UserContextDecorator.svelte b/.storybook/decorators/UserContextDecorator.svelte index 509d82ee6..1baf0b4a4 100644 --- a/.storybook/decorators/UserContextDecorator.svelte +++ b/.storybook/decorators/UserContextDecorator.svelte @@ -2,7 +2,7 @@ import { setContext } from "svelte"; import { writable, type Writable } from "svelte/store"; import type { User } from "@/api/types"; - import { me } from "@/api/fixtures/orgAndUser.fixtures"; + import { me } from "@/test/fixtures/accounts"; const userStore: Writable = writable(null); $: userStore.set(me as User); setContext("me", userStore); diff --git a/.storybook/preview.ts b/.storybook/preview.ts index 1af76b7d0..003515698 100644 --- a/.storybook/preview.ts +++ b/.storybook/preview.ts @@ -2,6 +2,7 @@ import type { Preview } from "@storybook/svelte"; import { initialize, mswLoader } from "msw-storybook-addon"; import { mockDateDecorator } from "storybook-mock-date-decorator"; import UserContextDecorator from "./decorators/UserContextDecorator.svelte"; +import OrgContextDecorator from "./decorators/OrgContextDecorator.svelte"; import "@/style/kit.css"; import "../src/lib/i18n/index.js"; @@ -30,6 +31,10 @@ const preview: Preview = { // Provide the MSW addon loader globally export const loaders = [mswLoader]; -export let decorators = [mockDateDecorator, () => UserContextDecorator]; +export let decorators = [ + mockDateDecorator, + () => UserContextDecorator, + () => OrgContextDecorator, +]; export default preview; diff --git a/src/common/Dropdown2.svelte b/src/common/Dropdown2.svelte index c6ae14619..d34e9134a 100644 --- a/src/common/Dropdown2.svelte +++ b/src/common/Dropdown2.svelte @@ -133,8 +133,9 @@ .title { display: block; cursor: pointer; - padding: 0.5rem; - border-radius: var(--radius); + padding: 0.25rem; + color: var(--gray-5); + fill: var(--gray-4); } .title.border { border: 1px solid rgba(0, 0, 0, 0.1); diff --git a/src/common/Menu.svelte b/src/common/Menu.svelte index 8947bdd3f..62a1e2d76 100644 --- a/src/common/Menu.svelte +++ b/src/common/Menu.svelte @@ -2,18 +2,22 @@ Define some menu items - diff --git a/src/common/MenuTitle.svelte b/src/common/MenuTitle.svelte index 971aad4bf..add474c21 100644 --- a/src/common/MenuTitle.svelte +++ b/src/common/MenuTitle.svelte @@ -1,17 +1,20 @@ {#if $$slots.icon}{/if} {label} - + diff --git a/src/lib/components/accounts/UserMenu.svelte b/src/lib/components/accounts/UserMenu.svelte new file mode 100644 index 000000000..0b78089cb --- /dev/null +++ b/src/lib/components/accounts/UserMenu.svelte @@ -0,0 +1,67 @@ + + + + + Avatar + {user.name} + + + + + + {$_("authSection.user.acctSettings")} + + + + + {$_("authSection.user.uploadEmail")} + + + + {$_("authSection.user.signOut")} + + + + + diff --git a/src/lib/components/stories/OrgMenu.stories.svelte b/src/lib/components/accounts/stories/OrgMenu.stories.svelte similarity index 77% rename from src/lib/components/stories/OrgMenu.stories.svelte rename to src/lib/components/accounts/stories/OrgMenu.stories.svelte index 28aecbb30..2443f68c5 100644 --- a/src/lib/components/stories/OrgMenu.stories.svelte +++ b/src/lib/components/accounts/stories/OrgMenu.stories.svelte @@ -2,6 +2,8 @@ import { Story } from "@storybook/addon-svelte-csf"; import OrgMenu from "../OrgMenu.svelte"; + import { organization } from "@/test/fixtures/accounts"; + export const meta = { title: "Components / Org Menu", component: OrgMenu, @@ -10,5 +12,5 @@ - + diff --git a/src/lib/components/documents/DocumentListItem.svelte b/src/lib/components/documents/DocumentListItem.svelte index 9e0cbb237..e9a475867 100644 --- a/src/lib/components/documents/DocumentListItem.svelte +++ b/src/lib/components/documents/DocumentListItem.svelte @@ -130,6 +130,7 @@ It's deliberately minimal and can be wrapped in other components to add addition text-overflow: ellipsis; white-space: nowrap; max-width: 100ch; + width: 100%; } .actions { diff --git a/src/lib/components/sidebar/SidebarItem.svelte b/src/lib/components/sidebar/SidebarItem.svelte index a827d775b..4ca2eeb1d 100644 --- a/src/lib/components/sidebar/SidebarItem.svelte +++ b/src/lib/components/sidebar/SidebarItem.svelte @@ -39,14 +39,16 @@ border-radius: 0.25rem; border: none; - color: var(--gray-5, #233944); - fill: var(--gray-5, #233944); + color: inherit; + fill: inherit; background: transparent; font-family: var(--font-sans, "Source Sans Pro"); font-size: var(--font-m, 1rem); font-weight: var(--font-semibold, 600); text-decoration: none; + white-space: nowrap; + text-overflow: ellipsis; } /* Hover */ diff --git a/src/lib/components/stories/MainLayout.stories.svelte b/src/lib/components/stories/MainLayout.stories.svelte index 21a3e8cac..54523f9f9 100644 --- a/src/lib/components/stories/MainLayout.stories.svelte +++ b/src/lib/components/stories/MainLayout.stories.svelte @@ -29,7 +29,7 @@ import PageToolbar from "../common/PageToolbar.svelte"; import Search from "../Search.svelte"; - import { addons } from "@/addons/browser/stories/mockData"; + import { addons } from "@/test/handlers/addons"; let results = documents as DocumentResults; @@ -41,6 +41,13 @@ msw: { handlers: [addons.data], }, + sveltekit_experimental: { + stores: { + page: { + url: "/", + }, + }, + }, }, }; @@ -92,7 +99,7 @@ - + diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index f7821ac7d..02758e22c 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -1,19 +1,22 @@ diff --git a/src/routes/+layout.js b/src/routes/+layout.ts similarity index 69% rename from src/routes/+layout.js rename to src/routes/+layout.ts index 1c9dd4185..90708bf8a 100644 --- a/src/routes/+layout.js +++ b/src/routes/+layout.ts @@ -1,12 +1,11 @@ import { locale, waitLocale } from "svelte-i18n"; import { browser } from "$app/environment"; -import { getMe } from "$lib/api/users.js"; +import { getMe, getOrg } from "$lib/api/accounts"; import "$lib/i18n/index.js"; // Import to initialize. Important :) export const trailingSlash = "always"; -/** @type {import('./$types').LayoutLoad} */ export async function load({ fetch, url }) { if (browser) { locale.set(window.navigator.language); @@ -18,6 +17,12 @@ export async function load({ fetch, url }) { // todo: ensure this doesn't load for embeds const me = await getMe(fetch); + let org; + if (typeof me.organization === "number") { + org = await getOrg(fetch, me.organization); + } else { + org = me.organization; + } - return { me, embed }; + return { me, org, embed }; }