@canonical/summon-application 0.48.0 → 0.49.0-experimental.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -26
- package/dist/esm/application/react/index.js +28 -1
- package/dist/esm/application/react/index.js.map +1 -1
- package/dist/esm/application/react/templates/README.md.ejs +5 -0
- package/dist/esm/application/react/templates/src/domains/catalog/ProductCard.tsx.ejs +2 -2
- package/dist/esm/application/react/templates/src/domains/dashboard/InstancesPage.tsx.ejs +1 -1
- package/dist/esm/application/react/templates/src/domains/dashboard/OverviewPage.tsx.ejs +6 -6
- package/dist/esm/application/react/templates/src/i18n/ar.ts.ejs +1 -0
- package/dist/esm/application/react/templates/src/i18n/config.ts +2 -2
- package/dist/esm/application/react/templates/src/i18n/en.ts.ejs +1 -0
- package/dist/esm/application/react/templates/src/i18n/fr.ts.ejs +1 -0
- package/dist/esm/application/react/templates/src/i18n/negotiation.test.ts +5 -5
- package/dist/esm/application/react/templates/src/lib/LocaleSelector/LocaleSelector.test.tsx +10 -0
- package/dist/esm/application/react/templates/src/lib/LocaleSelector/LocaleSelector.tsx.ejs +35 -21
- package/dist/esm/application/react/templates/src/lib/ThemeSelector/ServerThemeContext.ts +13 -0
- package/dist/esm/application/react/templates/src/lib/ThemeSelector/ThemeSelector.ssr.test.tsx.ejs +45 -0
- package/dist/esm/application/react/templates/src/lib/ThemeSelector/ThemeSelector.test.tsx.ejs +67 -0
- package/dist/esm/application/react/templates/src/lib/ThemeSelector/ThemeSelector.tsx.ejs +60 -26
- package/dist/esm/application/react/templates/src/lib/ThemeSelector/index.ts.ejs +4 -0
- package/dist/esm/application/react/templates/src/lib/TopBar/TopBar.test.tsx.ejs +7 -10
- package/dist/esm/application/react/templates/src/lib/TopBar/styles.css +8 -3
- package/dist/esm/application/react/templates/src/server/entry.tsx.ejs +23 -14
- package/dist/esm/application/react/templates/src/server/handlePreferenceForm.test.ts.ejs +63 -0
- package/dist/esm/application/react/templates/src/server/handlePreferenceForm.ts.ejs +158 -0
- package/dist/esm/application/react/templates/src/server/preferenceFormMiddleware.ts +42 -0
- package/dist/esm/application/react/templates/src/server/preview.bun.ts +5 -0
- package/dist/esm/application/react/templates/src/server/preview.express.ts +4 -0
- package/dist/esm/application/react/templates/src/server/resolveReturnTo.ts +18 -0
- package/dist/esm/application/react/templates/src/server/server.bun.ts.ejs +5 -0
- package/dist/esm/application/react/templates/src/server/server.express.ts.ejs +4 -0
- package/dist/esm/application/react/templates/test/e2e/servers.e2e.ts.ejs +56 -0
- package/dist/esm/application/react/templates/vitest.config.ts +4 -0
- package/dist/esm/application/svelte/index.js +226 -80
- package/dist/esm/application/svelte/index.js.map +1 -1
- package/dist/esm/application/svelte/templates/.storybook/{main.ts.ejs → main.ts} +1 -0
- package/dist/esm/application/svelte/templates/.storybook/preview.ts.ejs +20 -2
- package/dist/esm/application/svelte/templates/README.md.ejs +163 -40
- package/dist/esm/application/svelte/templates/biome.json.ejs +12 -0
- package/dist/esm/application/svelte/templates/gitignore.ejs +3 -4
- package/dist/esm/application/svelte/templates/package.json.ejs +54 -18
- package/dist/esm/application/svelte/templates/scripts/copy-icons.js +10 -0
- package/dist/esm/application/svelte/templates/src/app.d.ts.ejs +10 -2
- package/dist/esm/application/svelte/templates/src/app.html.ejs +9 -1
- package/dist/esm/application/svelte/templates/src/domains/account/AccountPage.svelte.ejs +18 -0
- package/dist/esm/application/svelte/templates/src/domains/account/LoginPage.svelte.ejs +32 -0
- package/dist/esm/application/svelte/templates/src/domains/account/getAuthRedirect.test.ts +18 -0
- package/dist/esm/application/svelte/templates/src/domains/account/getAuthRedirect.ts +18 -0
- package/dist/esm/application/svelte/templates/src/domains/account/guardAccount.ts +15 -0
- package/dist/esm/application/svelte/templates/src/domains/catalog/CatalogPage.svelte.ejs +35 -0
- package/dist/esm/application/svelte/templates/src/domains/catalog/ProductCard.svelte.ejs +51 -0
- package/dist/esm/application/svelte/templates/src/domains/catalog/ProductList.stories.svelte.ejs +110 -0
- package/dist/esm/application/svelte/templates/src/domains/catalog/ProductList.svelte.ejs +41 -0
- package/dist/esm/application/svelte/templates/src/domains/catalog/constants.ts +2 -0
- package/dist/esm/application/svelte/templates/src/domains/catalog/data.test.ts +19 -0
- package/dist/esm/application/svelte/templates/src/domains/catalog/data.ts +75 -0
- package/dist/esm/application/svelte/templates/src/domains/catalog/loadCatalog.ts +7 -0
- package/dist/esm/application/svelte/templates/src/domains/catalog/types.ts +25 -0
- package/dist/esm/application/svelte/templates/src/domains/contact/ContactPage.svelte.ejs +86 -0
- package/dist/esm/application/svelte/templates/src/domains/contact/types.ts.ejs +19 -0
- package/dist/esm/application/svelte/templates/src/domains/contact/validateContact.test.ts.ejs +31 -0
- package/dist/esm/application/svelte/templates/src/domains/contact/validateContact.ts.ejs +28 -0
- package/dist/esm/application/svelte/templates/src/domains/dashboard/DashboardBreadcrumbs.svelte.ejs +29 -0
- package/dist/esm/application/svelte/templates/src/domains/dashboard/DashboardLayout.svelte.ejs +35 -0
- package/dist/esm/application/svelte/templates/src/domains/dashboard/InstancesPage.svelte.ejs +245 -0
- package/dist/esm/application/svelte/templates/src/domains/dashboard/OverviewPage.svelte.ejs +180 -0
- package/dist/esm/application/svelte/templates/src/domains/dashboard/SettingsPage.svelte.ejs +103 -0
- package/dist/esm/application/svelte/templates/src/domains/dashboard/constants.ts.ejs +253 -0
- package/dist/esm/application/svelte/templates/src/domains/dashboard/createDashboardNavigation.ts.ejs +103 -0
- package/dist/esm/application/svelte/templates/src/domains/dashboard/createInstance.test.ts +22 -0
- package/dist/esm/application/svelte/templates/src/domains/dashboard/createInstance.ts +28 -0
- package/dist/esm/application/svelte/templates/src/domains/dashboard/projectBreadcrumbs.test.ts +78 -0
- package/dist/esm/application/svelte/templates/src/domains/dashboard/projectBreadcrumbs.ts +47 -0
- package/dist/esm/application/svelte/templates/src/domains/dashboard/selectRelativeTime.test.ts +19 -0
- package/dist/esm/application/svelte/templates/src/domains/dashboard/selectRelativeTime.ts +24 -0
- package/dist/esm/application/svelte/templates/src/domains/dashboard/styles.css +98 -0
- package/dist/esm/application/svelte/templates/src/domains/dashboard/types.ts.ejs +61 -0
- package/dist/esm/application/svelte/templates/src/domains/marketing/GuidePage.svelte.ejs +29 -0
- package/dist/esm/application/svelte/templates/src/domains/marketing/HomePage.svelte.ejs +47 -0
- package/dist/esm/application/svelte/templates/src/domains/marketing/isGuideSlug.ts +8 -0
- package/dist/esm/application/svelte/templates/src/formatDocumentTitle.ts.ejs +9 -0
- package/dist/esm/application/svelte/templates/src/hooks.server.ts.ejs +47 -9
- package/dist/esm/application/svelte/templates/src/i18n/ar.ts.ejs +174 -0
- package/dist/esm/application/svelte/templates/src/i18n/catalogs.ts +14 -0
- package/dist/esm/application/svelte/templates/src/i18n/config.ts +19 -0
- package/dist/esm/application/svelte/templates/src/i18n/en.ts.ejs +173 -0
- package/dist/esm/application/svelte/templates/src/i18n/fr.ts.ejs +171 -0
- package/dist/esm/application/svelte/templates/src/i18n/index.ts +45 -0
- package/dist/esm/application/svelte/templates/src/i18n/negotiation.test.ts +92 -0
- package/dist/esm/application/svelte/templates/src/layouts/ErrorPage.svelte.ejs +40 -0
- package/dist/esm/application/svelte/templates/src/layouts/PublicLayout.svelte +18 -0
- package/dist/esm/application/svelte/templates/src/layouts/RootLayout.svelte.ejs +43 -0
- package/dist/esm/application/svelte/templates/src/layouts/TopBarLayout.svelte +28 -0
- package/dist/esm/application/svelte/templates/src/lib/ApplicationShell/ApplicationShell.stories.svelte +87 -0
- package/dist/esm/application/svelte/templates/src/lib/ApplicationShell/ApplicationShell.svelte.ejs +60 -0
- package/dist/esm/application/svelte/templates/src/lib/ApplicationShell/index.ts +2 -0
- package/dist/esm/application/svelte/templates/src/lib/ApplicationShell/styles.css +43 -0
- package/dist/esm/application/svelte/templates/src/lib/ApplicationShell/types.ts +23 -0
- package/dist/esm/application/svelte/templates/src/lib/CanonicalLogo/CanonicalLogo.svelte.ejs +27 -0
- package/dist/esm/application/svelte/templates/src/lib/CanonicalLogo/index.ts +2 -0
- package/dist/esm/application/svelte/templates/src/lib/CanonicalLogo/styles.css +31 -0
- package/dist/esm/application/svelte/templates/src/lib/CanonicalLogo/types.ts +15 -0
- package/dist/esm/application/svelte/templates/src/lib/CodeMessage/CodeMessage.svelte +18 -0
- package/dist/esm/application/svelte/templates/src/lib/CodeMessage/index.ts +2 -0
- package/dist/esm/application/svelte/templates/src/lib/CodeMessage/types.ts +14 -0
- package/dist/esm/application/svelte/templates/src/lib/ExampleComponent/ExampleComponent.stories.svelte +15 -0
- package/dist/esm/application/svelte/templates/src/lib/ExampleComponent/ExampleComponent.svelte +17 -0
- package/dist/esm/application/svelte/templates/src/lib/ExampleComponent/index.ts +2 -0
- package/dist/esm/application/svelte/templates/src/lib/ExampleComponent/styles.css +17 -0
- package/dist/esm/application/svelte/templates/src/lib/ExampleComponent/types.ts +10 -0
- package/dist/esm/application/svelte/templates/src/lib/Icon/Icon.svelte +16 -0
- package/dist/esm/application/svelte/templates/src/lib/Icon/index.ts +2 -0
- package/dist/esm/application/svelte/templates/src/lib/Icon/types.ts +10 -0
- package/dist/esm/application/svelte/templates/src/lib/LazyComponent/LazyComponent.stories.svelte +19 -0
- package/dist/esm/application/svelte/templates/src/lib/LazyComponent/LazyComponent.svelte.ejs +29 -0
- package/dist/esm/application/svelte/templates/src/lib/LazyComponent/createDelayedData.ts.ejs +24 -0
- package/dist/esm/application/svelte/templates/src/lib/LazyComponent/index.ts +2 -0
- package/dist/esm/application/svelte/templates/src/lib/LazyComponent/types.ts.ejs +19 -0
- package/dist/esm/application/svelte/templates/src/lib/LocaleSelector/LocaleSelector.svelte.ejs +50 -0
- package/dist/esm/application/svelte/templates/src/lib/LocaleSelector/index.ts +2 -0
- package/dist/esm/application/svelte/templates/src/lib/LocaleSelector/types.ts +7 -0
- package/dist/esm/application/svelte/templates/src/lib/Navigation/Navigation.svelte.ejs +42 -0
- package/dist/esm/application/svelte/templates/src/lib/Navigation/index.ts +2 -0
- package/dist/esm/application/svelte/templates/src/lib/Navigation/types.ts +14 -0
- package/dist/esm/application/svelte/templates/src/lib/ThemeSelector/ThemeSelector.svelte.ejs +38 -0
- package/dist/esm/application/svelte/templates/src/lib/ThemeSelector/constants.ts +8 -0
- package/dist/esm/application/svelte/templates/src/lib/ThemeSelector/index.ts +5 -0
- package/dist/esm/application/svelte/templates/src/lib/ThemeSelector/readTheme.test.ts +13 -0
- package/dist/esm/application/svelte/templates/src/lib/ThemeSelector/readTheme.ts +15 -0
- package/dist/esm/application/svelte/templates/src/lib/ThemeSelector/setTheme.ts +27 -0
- package/dist/esm/application/svelte/templates/src/lib/ThemeSelector/types.ts +18 -0
- package/dist/esm/application/svelte/templates/src/lib/TopBar/TopBar.stories.svelte.ejs +24 -0
- package/dist/esm/application/svelte/templates/src/lib/TopBar/TopBar.svelte.ejs +32 -0
- package/dist/esm/application/svelte/templates/src/lib/TopBar/index.ts +2 -0
- package/dist/esm/application/svelte/templates/src/lib/TopBar/styles.css +54 -0
- package/dist/esm/application/svelte/templates/src/lib/TopBar/types.ts +15 -0
- package/dist/esm/application/svelte/templates/src/lib/index.ts.ejs +16 -0
- package/dist/esm/application/svelte/templates/src/params/guide.ts +5 -0
- package/dist/esm/application/svelte/templates/src/resolveReturnTo.test.ts +27 -0
- package/dist/esm/application/svelte/templates/src/resolveReturnTo.ts +13 -0
- package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/+layout.svelte +8 -0
- package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/+page.server.ts +6 -0
- package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/+page.svelte +8 -0
- package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/+page.ts +6 -0
- package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/account/+page.svelte +5 -0
- package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/account/+page.ts +4 -0
- package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/catalog/+page.svelte +8 -0
- package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/catalog/+page.ts +4 -0
- package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/contact/+page.server.ts +25 -0
- package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/contact/+page.svelte.ejs +30 -0
- package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/guides/[slug=guide]/+page.svelte +6 -0
- package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/login/+page.svelte +6 -0
- package/dist/esm/application/svelte/templates/src/routes/(top-bar)/+layout.svelte +9 -0
- package/dist/esm/application/svelte/templates/src/routes/(top-bar)/dashboard/+layout.svelte +9 -0
- package/dist/esm/application/svelte/templates/src/routes/(top-bar)/dashboard/+page.svelte +5 -0
- package/dist/esm/application/svelte/templates/src/routes/(top-bar)/dashboard/instances/+page.server.ts.ejs +28 -0
- package/dist/esm/application/svelte/templates/src/routes/(top-bar)/dashboard/instances/+page.svelte.ejs +19 -0
- package/dist/esm/application/svelte/templates/src/routes/(top-bar)/dashboard/settings/+page.server.ts +9 -0
- package/dist/esm/application/svelte/templates/src/routes/(top-bar)/dashboard/settings/+page.svelte +5 -0
- package/dist/esm/application/svelte/templates/src/routes/+error.svelte +6 -0
- package/dist/esm/application/svelte/templates/src/routes/+layout.server.ts.ejs +7 -1
- package/dist/esm/application/svelte/templates/src/routes/+layout.svelte.ejs +18 -82
- package/dist/esm/application/svelte/templates/src/routes/+layout.ts.ejs +29 -0
- package/dist/esm/application/svelte/templates/src/routes/home/+page.ts +4 -0
- package/dist/esm/application/svelte/templates/src/routes/home/{+server.ts.ejs → +server.ts} +1 -0
- package/dist/esm/application/svelte/templates/src/routes/icons/[icon]/+server.ts +37 -0
- package/dist/esm/application/svelte/templates/src/routes/language/+server.ts +30 -0
- package/dist/esm/application/svelte/templates/src/routes/preferences/+server.ts +32 -0
- package/dist/esm/application/svelte/templates/src/routes/sitemap.xml/+server.ts.ejs +44 -4
- package/dist/esm/application/svelte/templates/src/storybook/I18nDecorator.svelte +28 -0
- package/dist/esm/application/svelte/templates/src/storybook/decorators.ts +12 -0
- package/dist/esm/application/svelte/templates/src/styles/app.css +38 -0
- package/dist/esm/application/svelte/templates/src/styles/index.css.ejs +25 -0
- package/dist/esm/application/svelte/templates/src/styles/standins/Card.css +198 -0
- package/dist/esm/application/svelte/templates/src/styles/standins/Icon.css +32 -0
- package/dist/esm/application/svelte/templates/src/styles/standins/InlineCode.css +30 -0
- package/dist/esm/application/svelte/templates/src/styles/standins/SidePanel.css +462 -0
- package/dist/esm/application/svelte/templates/src/styles/standins/Tile.css +108 -0
- package/dist/esm/application/svelte/templates/src/styles/standins/Timeline.css +171 -0
- package/dist/esm/application/svelte/templates/src/styles/standins.css.ejs +17 -0
- package/dist/esm/application/svelte/templates/svelte.config.js.ejs +12 -2
- package/dist/esm/application/svelte/templates/test/app.test.js.ejs +739 -123
- package/dist/esm/application/svelte/templates/test/spa.test.js.ejs +224 -0
- package/dist/esm/application/svelte/templates/{tsconfig.json.ejs → tsconfig.json} +2 -2
- package/dist/esm/application/svelte/templates/{vite.config.ts.ejs → vite.config.ts} +1 -1
- package/dist/esm/application/svelte/templates/vitest.config.ts +10 -0
- package/dist/esm/application/svelte/textHelpers.js +20 -0
- package/dist/esm/application/svelte/textHelpers.js.map +1 -0
- package/dist/esm/shared/versions.js +10 -8
- package/dist/esm/shared/versions.js.map +1 -1
- package/dist/types/application/react/index.d.ts.map +1 -1
- package/dist/types/application/svelte/index.d.ts.map +1 -1
- package/dist/types/application/svelte/textHelpers.d.ts +21 -0
- package/dist/types/application/svelte/textHelpers.d.ts.map +1 -0
- package/dist/types/shared/versions.d.ts +11 -9
- package/dist/types/shared/versions.d.ts.map +1 -1
- package/package.json +6 -6
- package/dist/esm/application/react/templates/src/lib/ThemeSelector/index.ts +0 -1
- package/dist/esm/application/svelte/templates/scripts/copy-icons.js.ejs +0 -9
- package/dist/esm/application/svelte/templates/src/lib/ContactExample.stories.svelte.ejs +0 -11
- package/dist/esm/application/svelte/templates/src/lib/ContactExample.svelte.ejs +0 -19
- package/dist/esm/application/svelte/templates/src/lib/DashboardNavigation.svelte.ejs +0 -17
- package/dist/esm/application/svelte/templates/src/lib/ProjectDanger.svelte.ejs +0 -18
- package/dist/esm/application/svelte/templates/src/lib/Welcome.stories.svelte.ejs +0 -5
- package/dist/esm/application/svelte/templates/src/lib/catalog.ts.ejs +0 -5
- package/dist/esm/application/svelte/templates/src/lib/contact.ts.ejs +0 -19
- package/dist/esm/application/svelte/templates/src/lib/i18n.ts.ejs +0 -351
- package/dist/esm/application/svelte/templates/src/lib/instances.ts.ejs +0 -16
- package/dist/esm/application/svelte/templates/src/lib/resolveReturnTo.ts.ejs +0 -11
- package/dist/esm/application/svelte/templates/src/lib/settings.ts.ejs +0 -28
- package/dist/esm/application/svelte/templates/src/routes/+error.svelte.ejs +0 -9
- package/dist/esm/application/svelte/templates/src/routes/+page.svelte.ejs +0 -9
- package/dist/esm/application/svelte/templates/src/routes/account/+page.server.ts.ejs +0 -13
- package/dist/esm/application/svelte/templates/src/routes/account/+page.svelte.ejs +0 -20
- package/dist/esm/application/svelte/templates/src/routes/catalog/+page.svelte.ejs +0 -12
- package/dist/esm/application/svelte/templates/src/routes/catalog/[id]/+page.server.ts.ejs +0 -8
- package/dist/esm/application/svelte/templates/src/routes/catalog/[id]/+page.svelte.ejs +0 -13
- package/dist/esm/application/svelte/templates/src/routes/catalog/[id]/+page.ts.ejs +0 -8
- package/dist/esm/application/svelte/templates/src/routes/contact/+page.server.ts.ejs +0 -11
- package/dist/esm/application/svelte/templates/src/routes/contact/+page.svelte.ejs +0 -85
- package/dist/esm/application/svelte/templates/src/routes/dashboard/+layout.svelte.ejs +0 -15
- package/dist/esm/application/svelte/templates/src/routes/dashboard/+page.server.ts.ejs +0 -5
- package/dist/esm/application/svelte/templates/src/routes/dashboard/+page.svelte.ejs +0 -33
- package/dist/esm/application/svelte/templates/src/routes/dashboard/instances/+page.server.ts.ejs +0 -23
- package/dist/esm/application/svelte/templates/src/routes/dashboard/instances/+page.svelte.ejs +0 -101
- package/dist/esm/application/svelte/templates/src/routes/dashboard/instances/remove/+page.server.ts.ejs +0 -19
- package/dist/esm/application/svelte/templates/src/routes/dashboard/instances/remove/+page.svelte.ejs +0 -11
- package/dist/esm/application/svelte/templates/src/routes/dashboard/settings/+page.server.ts.ejs +0 -13
- package/dist/esm/application/svelte/templates/src/routes/dashboard/settings/+page.svelte.ejs +0 -52
- package/dist/esm/application/svelte/templates/src/routes/dashboard/settings/confirm/+page.server.ts.ejs +0 -2
- package/dist/esm/application/svelte/templates/src/routes/dashboard/settings/confirm/+page.svelte.ejs +0 -13
- package/dist/esm/application/svelte/templates/src/routes/language/+server.ts.ejs +0 -12
- package/dist/esm/application/svelte/templates/src/routes/login/+page.server.ts.ejs +0 -8
- package/dist/esm/application/svelte/templates/src/routes/login/+page.svelte.ejs +0 -11
- package/dist/esm/application/svelte/templates/src/routes/preferences/+server.ts.ejs +0 -10
- package/dist/esm/application/svelte/templates/src/styles.css.ejs +0 -28
- package/dist/esm/application/svelte/templates/test/contact.browser.test.js.ejs +0 -279
package/dist/esm/application/svelte/templates/src/domains/catalog/ProductList.stories.svelte.ejs
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { defineMeta } from "@storybook/addon-svelte-csf";
|
|
3
|
+
import { expect } from "storybook/test";
|
|
4
|
+
<% if (intl) { -%>
|
|
5
|
+
import { catalogs } from "../../i18n/index.js";
|
|
6
|
+
<% } -%>
|
|
7
|
+
import Component from "./ProductList.svelte";
|
|
8
|
+
<% if (intl) { -%>
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The locale toolbar rerenders every story in the selected locale, so play
|
|
12
|
+
* assertions never hard-code English copy: translated chrome is asserted
|
|
13
|
+
* against the active locale's own catalog, and counts structurally.
|
|
14
|
+
*/
|
|
15
|
+
const messagesFor = (locale: unknown): Record<string, unknown> =>
|
|
16
|
+
catalogs[
|
|
17
|
+
(typeof locale === "string" && locale in catalogs
|
|
18
|
+
? locale
|
|
19
|
+
: "en") as keyof typeof catalogs
|
|
20
|
+
];
|
|
21
|
+
<% } -%>
|
|
22
|
+
|
|
23
|
+
const { Story } = defineMeta({
|
|
24
|
+
title: "Catalog/ProductList",
|
|
25
|
+
component: Component,
|
|
26
|
+
});
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<Story
|
|
30
|
+
name="Default"
|
|
31
|
+
args={{
|
|
32
|
+
catalog: {
|
|
33
|
+
viewerName: "Ada Lovelace",
|
|
34
|
+
totalCount: 5,
|
|
35
|
+
hasNextPage: true,
|
|
36
|
+
products: [
|
|
37
|
+
{
|
|
38
|
+
id: "Product:story-1",
|
|
39
|
+
name: "Aurora Dev Board",
|
|
40
|
+
tagline: "A hackable single-board computer for prototyping",
|
|
41
|
+
priceCents: 14_900,
|
|
42
|
+
currency: "USD",
|
|
43
|
+
rating: 4.6,
|
|
44
|
+
inStock: true,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: "Product:story-2",
|
|
48
|
+
name: "Polar Sensor Kit",
|
|
49
|
+
tagline: "Twelve calibrated sensors in a rugged case",
|
|
50
|
+
priceCents: 8_900,
|
|
51
|
+
currency: "USD",
|
|
52
|
+
rating: 4.2,
|
|
53
|
+
inStock: false,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
}}
|
|
58
|
+
<% if (intl) { -%>
|
|
59
|
+
play={async ({ canvas, globals }) => {
|
|
60
|
+
const messages = messagesFor(globals.locale);
|
|
61
|
+
|
|
62
|
+
await expect(await canvas.findByText("Aurora Dev Board")).toBeInTheDocument();
|
|
63
|
+
await expect(canvas.getByText("Ada Lovelace")).toBeInTheDocument();
|
|
64
|
+
await expect(canvas.getAllByRole("article")).toHaveLength(2);
|
|
65
|
+
await expect(
|
|
66
|
+
canvas.getByText(String(messages["catalog.outOfStock"]), { exact: false }),
|
|
67
|
+
).toBeInTheDocument();
|
|
68
|
+
await expect(
|
|
69
|
+
canvas.getByText(String(messages["catalog.more"])),
|
|
70
|
+
).toBeInTheDocument();
|
|
71
|
+
}}
|
|
72
|
+
<% } else { -%>
|
|
73
|
+
play={async ({ canvas }) => {
|
|
74
|
+
await expect(await canvas.findByText("Aurora Dev Board")).toBeInTheDocument();
|
|
75
|
+
await expect(canvas.getByText("Ada Lovelace")).toBeInTheDocument();
|
|
76
|
+
await expect(canvas.getAllByRole("article")).toHaveLength(2);
|
|
77
|
+
await expect(canvas.getByText(/out of stock/)).toBeInTheDocument();
|
|
78
|
+
await expect(
|
|
79
|
+
canvas.getByText("More products are available."),
|
|
80
|
+
).toBeInTheDocument();
|
|
81
|
+
}}
|
|
82
|
+
<% } -%>
|
|
83
|
+
/>
|
|
84
|
+
|
|
85
|
+
<Story
|
|
86
|
+
name="EmptyCatalog"
|
|
87
|
+
args={{
|
|
88
|
+
catalog: {
|
|
89
|
+
viewerName: "Ada Lovelace",
|
|
90
|
+
totalCount: 0,
|
|
91
|
+
hasNextPage: false,
|
|
92
|
+
products: [],
|
|
93
|
+
},
|
|
94
|
+
}}
|
|
95
|
+
<% if (intl) { -%>
|
|
96
|
+
play={async ({ canvas, globals }) => {
|
|
97
|
+
const messages = messagesFor(globals.locale);
|
|
98
|
+
|
|
99
|
+
await expect(
|
|
100
|
+
await canvas.findByLabelText(String(messages["catalog.listLabel"])),
|
|
101
|
+
).toBeInTheDocument();
|
|
102
|
+
<% } else { -%>
|
|
103
|
+
play={async ({ canvas }) => {
|
|
104
|
+
await expect(
|
|
105
|
+
await canvas.findByLabelText("Product catalog"),
|
|
106
|
+
).toBeInTheDocument();
|
|
107
|
+
<% } -%>
|
|
108
|
+
await expect(canvas.queryByRole("article")).not.toBeInTheDocument();
|
|
109
|
+
}}
|
|
110
|
+
/>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
<% if (intl) { -%>
|
|
3
|
+
import { createAppTranslator, getLocaleSource } from "../../i18n/index.js";
|
|
4
|
+
<% } -%>
|
|
5
|
+
import ProductCard from "./ProductCard.svelte";
|
|
6
|
+
import type { ProductPage } from "./types.js";
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
catalog,
|
|
10
|
+
}: {
|
|
11
|
+
/** The page of products to render. */
|
|
12
|
+
catalog: ProductPage;
|
|
13
|
+
} = $props();
|
|
14
|
+
<% if (intl) { -%>
|
|
15
|
+
|
|
16
|
+
const locale = getLocaleSource();
|
|
17
|
+
const t = $derived(createAppTranslator($locale));
|
|
18
|
+
<% } -%>
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<section aria-label=<%- attr("catalog.listLabel", "Product catalog") %>>
|
|
22
|
+
<% if (intl) { -%>
|
|
23
|
+
<!-- `catalog.showing` is a plural entry: `count` (the total) selects the
|
|
24
|
+
CLDR category through Intl.PluralRules. The viewer name stays a separate
|
|
25
|
+
element so it can carry emphasis. -->
|
|
26
|
+
<p>{t("catalog.signedInAs")} <strong>{catalog.viewerName}</strong> {t("catalog.showing", { shown: catalog.products.length, count: catalog.totalCount })}</p>
|
|
27
|
+
<% } else { -%>
|
|
28
|
+
<p>Signed in as <strong>{catalog.viewerName}</strong> — showing {catalog.products.length} of {catalog.totalCount} products.</p>
|
|
29
|
+
<% } -%>
|
|
30
|
+
<ul>
|
|
31
|
+
{#each catalog.products as product (product.id)}
|
|
32
|
+
<li><ProductCard {product} /></li>
|
|
33
|
+
{/each}
|
|
34
|
+
</ul>
|
|
35
|
+
{#if catalog.hasNextPage}<p><%- msg("catalog.more", "More products are available.") %></p>{/if}
|
|
36
|
+
</section>
|
|
37
|
+
|
|
38
|
+
<!-- @component
|
|
39
|
+
Renders a page of the product catalog: who is signed in, how many products
|
|
40
|
+
show of how many, and a `ProductCard` per product.
|
|
41
|
+
-->
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { CATALOG_PRODUCTS, selectProductPage } from "./data.js";
|
|
3
|
+
|
|
4
|
+
describe("selectProductPage", () => {
|
|
5
|
+
it("reads the first page with the catalog's totals", () => {
|
|
6
|
+
const page = selectProductPage(4);
|
|
7
|
+
|
|
8
|
+
expect(page.viewerName).toBe("Ada Lovelace");
|
|
9
|
+
expect(page.products.map((product) => product.name)).toEqual(
|
|
10
|
+
CATALOG_PRODUCTS.slice(0, 4).map((product) => product.name),
|
|
11
|
+
);
|
|
12
|
+
expect(page.totalCount).toBe(6);
|
|
13
|
+
expect(page.hasNextPage).toBe(true);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("reports the end of the catalog", () => {
|
|
17
|
+
expect(selectProductPage(6).hasNextPage).toBe(false);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { Product, ProductPage } from "./types.js";
|
|
2
|
+
|
|
3
|
+
/** The signed-in demo viewer, whose name the list shows. */
|
|
4
|
+
export const VIEWER_NAME = "Ada Lovelace";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The local product data the catalog reads. Replace this module with a call
|
|
8
|
+
* to a real endpoint.
|
|
9
|
+
*/
|
|
10
|
+
export const CATALOG_PRODUCTS: readonly Product[] = [
|
|
11
|
+
{
|
|
12
|
+
id: "Product:1",
|
|
13
|
+
name: "Vanguard Workstation",
|
|
14
|
+
tagline: "A certified Ubuntu desktop for heavy compilation workloads",
|
|
15
|
+
priceCents: 189_900,
|
|
16
|
+
currency: "USD",
|
|
17
|
+
rating: 4.7,
|
|
18
|
+
inStock: true,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: "Product:2",
|
|
22
|
+
name: "Meridian Laptop 14",
|
|
23
|
+
tagline: "Thin, quiet, and pre-loaded with your team's golden image",
|
|
24
|
+
priceCents: 129_900,
|
|
25
|
+
currency: "USD",
|
|
26
|
+
rating: 4.5,
|
|
27
|
+
inStock: true,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "Product:3",
|
|
31
|
+
name: "Beacon Micro Server",
|
|
32
|
+
tagline: "A fanless edge node that fits in a network cabinet",
|
|
33
|
+
priceCents: 64_900,
|
|
34
|
+
currency: "USD",
|
|
35
|
+
rating: 4.2,
|
|
36
|
+
inStock: false,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: "Product:4",
|
|
40
|
+
name: "Atlas Rack Server",
|
|
41
|
+
tagline: "Dense compute for private-cloud deployments",
|
|
42
|
+
priceCents: 449_900,
|
|
43
|
+
currency: "USD",
|
|
44
|
+
rating: 4.8,
|
|
45
|
+
inStock: true,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: "Product:5",
|
|
49
|
+
name: "Harbor NAS Enclosure",
|
|
50
|
+
tagline: "Four bays of quiet, snapshot-friendly storage",
|
|
51
|
+
priceCents: 89_900,
|
|
52
|
+
currency: "USD",
|
|
53
|
+
rating: 4.1,
|
|
54
|
+
inStock: true,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: "Product:6",
|
|
58
|
+
name: "Relay IoT Gateway",
|
|
59
|
+
tagline: "Bridges field sensors onto your message bus securely",
|
|
60
|
+
priceCents: 29_900,
|
|
61
|
+
currency: "USD",
|
|
62
|
+
rating: 3.9,
|
|
63
|
+
inStock: false,
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
/** Reads the first `count` products, with the totals the list shows. */
|
|
68
|
+
export function selectProductPage(count: number): ProductPage {
|
|
69
|
+
return {
|
|
70
|
+
viewerName: VIEWER_NAME,
|
|
71
|
+
totalCount: CATALOG_PRODUCTS.length,
|
|
72
|
+
hasNextPage: count < CATALOG_PRODUCTS.length,
|
|
73
|
+
products: CATALOG_PRODUCTS.slice(0, count),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** A product of the catalog. */
|
|
2
|
+
export interface Product {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
/** The product name, which is data and stays untranslated. */
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly tagline: string;
|
|
7
|
+
/** The price in the currency's minor unit. */
|
|
8
|
+
readonly priceCents: number;
|
|
9
|
+
/** An ISO 4217 currency code. */
|
|
10
|
+
readonly currency: string;
|
|
11
|
+
/** Out of five. */
|
|
12
|
+
readonly rating: number;
|
|
13
|
+
readonly inStock: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** One page of the catalog, as the product list renders it. */
|
|
17
|
+
export interface ProductPage {
|
|
18
|
+
/** The signed-in viewer's name. */
|
|
19
|
+
readonly viewerName: string;
|
|
20
|
+
/** How many products the catalog holds in all. */
|
|
21
|
+
readonly totalCount: number;
|
|
22
|
+
/** Whether products beyond this page exist. */
|
|
23
|
+
readonly hasNextPage: boolean;
|
|
24
|
+
readonly products: readonly Product[];
|
|
25
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Button } from "@canonical/svelte-ds-global";
|
|
3
|
+
import {
|
|
4
|
+
createFormState,
|
|
5
|
+
Field,
|
|
6
|
+
Form,
|
|
7
|
+
} from "@canonical/svelte-ds-global-form";
|
|
8
|
+
import type { Attachment } from "svelte/attachments";
|
|
9
|
+
import formatDocumentTitle from "../../formatDocumentTitle.js";
|
|
10
|
+
<% if (intl) { -%>
|
|
11
|
+
import { createAppTranslator, getLocaleSource } from "../../i18n/index.js";
|
|
12
|
+
<% } -%>
|
|
13
|
+
import type { ContactErrors, ContactValues } from "./types.js";
|
|
14
|
+
import { validateContact } from "./validateContact.js";
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
form,
|
|
18
|
+
post,
|
|
19
|
+
onSubmit,
|
|
20
|
+
}: {
|
|
21
|
+
/** The action's answer to the last post: the values and their errors. */
|
|
22
|
+
form?: { values?: ContactValues; errors?: ContactErrors } | null;
|
|
23
|
+
/** Posts a valid form to the page's action in place, such as `enhance`. */
|
|
24
|
+
post?: Attachment<HTMLFormElement>;
|
|
25
|
+
/** Handles a valid submit instead of posting, where there is no action. */
|
|
26
|
+
onSubmit?: (values: ContactValues) => void;
|
|
27
|
+
} = $props();
|
|
28
|
+
<% if (intl) { -%>
|
|
29
|
+
|
|
30
|
+
const locale = getLocaleSource();
|
|
31
|
+
const t = $derived(createAppTranslator($locale));
|
|
32
|
+
<% } -%>
|
|
33
|
+
const subjects = $derived([
|
|
34
|
+
{ value: "general", label: <%- str("contact.subjectGeneral", "General enquiry") %> },
|
|
35
|
+
{ value: "support", label: <%- str("contact.subjectSupport", "Support") %> },
|
|
36
|
+
{ value: "feedback", label: <%- str("contact.subjectFeedback", "Feedback") %> },
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
// Each answer of the action seeds a fresh owner, so the server's values and
|
|
40
|
+
// errors show with JavaScript or without it. The owner validates with the
|
|
41
|
+
// action's own rules before the form posts.
|
|
42
|
+
const owner = $derived(
|
|
43
|
+
createFormState<ContactValues>({
|
|
44
|
+
defaultValues: form?.values ?? {
|
|
45
|
+
name: "",
|
|
46
|
+
email: "",
|
|
47
|
+
subject: "general",
|
|
48
|
+
message: "",
|
|
49
|
+
},
|
|
50
|
+
errors: form?.errors,
|
|
51
|
+
validate: validateContact,
|
|
52
|
+
onSubmit,
|
|
53
|
+
}),
|
|
54
|
+
);
|
|
55
|
+
<% if (intl) { -%>
|
|
56
|
+
|
|
57
|
+
/** Translates a field's error, which holds a catalog key. */
|
|
58
|
+
const translateError = (name: keyof ContactValues) => {
|
|
59
|
+
const key = (owner.errors as ContactErrors)[name];
|
|
60
|
+
return key ? t(key) : undefined;
|
|
61
|
+
};
|
|
62
|
+
<% } -%>
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<svelte:head><title>{formatDocumentTitle(<%- str("contact.title", "Contact") %>)}</title></svelte:head>
|
|
66
|
+
|
|
67
|
+
<section aria-labelledby="contact-title">
|
|
68
|
+
<h1 id="contact-title"><%- msg("contact.heading", "Contact") %></h1>
|
|
69
|
+
<Form method="post" {owner} {@attach post}>
|
|
70
|
+
<Field inputType="text" label=<%- attr("contact.name", "Full name") %> name="name" />
|
|
71
|
+
<Field error=<%- intl ? '{translateError("email")}' : "{owner.errors.email}" %> inputType="text" label=<%- attr("contact.email", "Email address") %> name="email" />
|
|
72
|
+
<Field inputType="select" label=<%- attr("contact.subject", "Subject") %> name="subject" options={subjects} />
|
|
73
|
+
<Field description=<%- attr("contact.messageHint", "Maximum 500 characters") %> inputType="textarea" label=<%- attr("contact.message", "Message") %> name="message" />
|
|
74
|
+
<Button type="submit"><%- msg("contact.send", "Send message") %></Button>
|
|
75
|
+
</Form>
|
|
76
|
+
</section>
|
|
77
|
+
|
|
78
|
+
<!-- @component
|
|
79
|
+
The contact form. Its owner validates the email before the form posts, with
|
|
80
|
+
the rules the page's action uses, and is seeded from the action's answer, so
|
|
81
|
+
the action's values and errors show with JavaScript or without it. With `post`
|
|
82
|
+
(SvelteKit's `enhance`), a valid form posts to the action in place; with
|
|
83
|
+
`onSubmit`, a valid submit is handled instead of posted, as in the client-only
|
|
84
|
+
build, which has no action. Without JavaScript the form posts natively and the
|
|
85
|
+
action validates the same way.
|
|
86
|
+
-->
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<% if (intl) { -%>
|
|
2
|
+
import type { MessageKey } from "../../i18n/index.js";
|
|
3
|
+
|
|
4
|
+
<% } -%>
|
|
5
|
+
/** The contact form's fields, as posted. */
|
|
6
|
+
export type ContactValues = {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly email: string;
|
|
9
|
+
readonly subject: string;
|
|
10
|
+
readonly message: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
<% if (intl) { -%>
|
|
14
|
+
/** The catalog key of each invalid field's message. */
|
|
15
|
+
export type ContactErrors = Partial<Record<keyof ContactValues, MessageKey>>;
|
|
16
|
+
<% } else { -%>
|
|
17
|
+
/** Each invalid field's message. */
|
|
18
|
+
export type ContactErrors = Partial<Record<keyof ContactValues, string>>;
|
|
19
|
+
<% } -%>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { readContact, validateContact } from "./validateContact.js";
|
|
3
|
+
|
|
4
|
+
const formData = (entries: Record<string, string>) => {
|
|
5
|
+
const data = new FormData();
|
|
6
|
+
for (const [name, value] of Object.entries(entries)) data.set(name, value);
|
|
7
|
+
return data;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
describe("validateContact", () => {
|
|
11
|
+
it("requires the email", () => {
|
|
12
|
+
expect(validateContact(readContact(formData({ email: " " })))).toEqual({
|
|
13
|
+
email: <%- intl ? '"contact.emailRequired"' : '"Email is required"' %>,
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("accepts a form with an email", () => {
|
|
18
|
+
expect(
|
|
19
|
+
validateContact(readContact(formData({ email: "ada@example.com" }))),
|
|
20
|
+
).toEqual({});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("reads every field, empty when absent", () => {
|
|
24
|
+
expect(readContact(formData({ name: "Ada" }))).toEqual({
|
|
25
|
+
name: "Ada",
|
|
26
|
+
email: "",
|
|
27
|
+
subject: "",
|
|
28
|
+
message: "",
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ContactErrors, ContactValues } from "./types.js";
|
|
2
|
+
|
|
3
|
+
/** Reads the contact fields from a submitted form. */
|
|
4
|
+
export function readContact(formData: FormData): ContactValues {
|
|
5
|
+
const text = (name: keyof ContactValues) => {
|
|
6
|
+
const value = formData.get(name);
|
|
7
|
+
return typeof value === "string" ? value : "";
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
name: text("name"),
|
|
12
|
+
email: text("email"),
|
|
13
|
+
subject: text("subject"),
|
|
14
|
+
message: text("message"),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
<% if (intl) { -%>
|
|
20
|
+
* Returns the catalog key of each invalid field: the email is required, as
|
|
21
|
+
<% } else { -%>
|
|
22
|
+
* Returns the message of each invalid field: the email is required, as
|
|
23
|
+
<% } -%>
|
|
24
|
+
* the only rule the form has.
|
|
25
|
+
*/
|
|
26
|
+
export function validateContact(values: ContactValues): ContactErrors {
|
|
27
|
+
return values.email.trim() ? {} : { email: <%- intl ? '"contact.emailRequired"' : '"Email is required"' %> };
|
|
28
|
+
}
|
package/dist/esm/application/svelte/templates/src/domains/dashboard/DashboardBreadcrumbs.svelte.ejs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Breadcrumbs } from "@canonical/svelte-ds-global";
|
|
3
|
+
import { page } from "$app/state";
|
|
4
|
+
<% if (intl) { -%>
|
|
5
|
+
import { createAppTranslator, getLocaleSource } from "../../i18n/index.js";
|
|
6
|
+
<% } -%>
|
|
7
|
+
import { LEGAL_URL, PROJECT_NAME } from "./constants.js";
|
|
8
|
+
import createDashboardNavigation from "./createDashboardNavigation.js";
|
|
9
|
+
import projectBreadcrumbs from "./projectBreadcrumbs.js";
|
|
10
|
+
|
|
11
|
+
<% if (intl) { -%>
|
|
12
|
+
const locale = getLocaleSource();
|
|
13
|
+
const t = $derived(createAppTranslator($locale));
|
|
14
|
+
const { root } = $derived(
|
|
15
|
+
createDashboardNavigation({ legalUrl: LEGAL_URL, t }),
|
|
16
|
+
);
|
|
17
|
+
<% } else { -%>
|
|
18
|
+
const { root } = $derived(createDashboardNavigation({ legalUrl: LEGAL_URL }));
|
|
19
|
+
<% } -%>
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<Breadcrumbs aria-label=<%- attr("dashboard.breadcrumbs", "Breadcrumb") %> items={[{ label: PROJECT_NAME, url: "/dashboard" }, ...projectBreadcrumbs(root, page.url.pathname)]} />
|
|
23
|
+
|
|
24
|
+
<!-- @component
|
|
25
|
+
The breadcrumb trail of the current dashboard page: the project, then the
|
|
26
|
+
page's path in the side navigation's tree. The trail is projected from the
|
|
27
|
+
same navigation items the side navigation renders, so a page never states its
|
|
28
|
+
own position and the two cannot disagree.
|
|
29
|
+
-->
|
package/dist/esm/application/svelte/templates/src/domains/dashboard/DashboardLayout.svelte.ejs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
<% if (intl) { -%>
|
|
4
|
+
import { createAppTranslator, getLocaleSource } from "../../i18n/index.js";
|
|
5
|
+
<% } -%>
|
|
6
|
+
import { ApplicationShell } from "../../lib/index.js";
|
|
7
|
+
import { LEGAL_URL } from "./constants.js";
|
|
8
|
+
import createDashboardNavigation from "./createDashboardNavigation.js";
|
|
9
|
+
|
|
10
|
+
let {
|
|
11
|
+
currentUrl,
|
|
12
|
+
children,
|
|
13
|
+
}: {
|
|
14
|
+
/** The current page's pathname. */
|
|
15
|
+
currentUrl: string;
|
|
16
|
+
/** The dashboard page. */
|
|
17
|
+
children?: Snippet;
|
|
18
|
+
} = $props();
|
|
19
|
+
<% if (intl) { -%>
|
|
20
|
+
|
|
21
|
+
const locale = getLocaleSource();
|
|
22
|
+
const t = $derived(createAppTranslator($locale));
|
|
23
|
+
<% } -%>
|
|
24
|
+
const navigation = $derived(
|
|
25
|
+
createDashboardNavigation({ legalUrl: LEGAL_URL<%= intl ? ", t" : "" %> }),
|
|
26
|
+
);
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<ApplicationShell {currentUrl} footerRoot={navigation.footerRoot} label=<%- attr("dashboard.nav.label", "Dashboard") %> root={navigation.root}>{@render children?.()}</ApplicationShell>
|
|
30
|
+
|
|
31
|
+
<!-- @component
|
|
32
|
+
The frame of every dashboard page: the application shell, with the
|
|
33
|
+
dashboard's side navigation. The dashboard's route layout renders it beneath
|
|
34
|
+
the top bar.
|
|
35
|
+
-->
|