@morphemecms/cms 0.13.0-next-20261106213045 → 0.13.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/CHANGELOG.md +11 -1
- package/defaults/collections.ts +39 -52
- package/defaults/company.ts +5 -1
- package/defaults/editor.ts +27 -14
- package/defaults/i18n/da-DK/collections.ts +11 -8
- package/defaults/i18n/da-DK/editor.ts +1 -1
- package/defaults/i18n/da-DK/rules.ts +1 -0
- package/defaults/rules.ts +13 -1
- package/lib/focusTrap.d.mts +20 -0
- package/lib/focusTrap.mjs +28 -0
- package/lib/focusTrap.test.mjs +41 -0
- package/lib/folderChanges.mjs +1 -1
- package/lib/licenses.d.mts +1 -1
- package/lib/licenses.imports.test.mjs +33 -0
- package/lib/licenses.mjs +7 -4
- package/lib/menu.mjs +9 -4
- package/lib/menu.test.mjs +45 -18
- package/lib/storeEntries.d.mts +0 -1
- package/lib/storeEntries.mjs +2 -4
- package/lib/storeEntries.test.mjs +1 -6
- package/package.json +1 -1
- package/scripts/starter-gitattributes.test.mjs +22 -0
- package/site/header.d.mts +2 -1
- package/site/header.mjs +7 -4
- package/site/header.test.mjs +8 -2
- package/site/social.d.mts +65 -8
- package/site/social.mjs +132 -14
- package/site/social.test.mjs +109 -5
- package/src/App.tsx +29 -7
- package/src/AppList.tsx +46 -200
- package/src/BrandForm.tsx +2 -2
- package/src/CompanyForm.tsx +7 -2
- package/src/HeaderSettings.tsx +4 -4
- package/src/Library.tsx +20 -13
- package/src/LinkList.tsx +165 -0
- package/src/MainMenu.tsx +24 -4
- package/src/MoveButtons.tsx +15 -0
- package/src/StoreSearchRow.tsx +67 -0
- package/src/StoreStatus.tsx +67 -0
- package/src/ThemeStore.tsx +16 -37
- package/src/ThemeStoreScreen.tsx +62 -0
- package/src/checkSite.ts +3 -2
- package/src/cmsNotice.d.mts +7 -0
- package/src/cmsNotice.mjs +11 -0
- package/src/cmsNotice.test.mjs +50 -0
- package/src/fields.tsx +38 -13
- package/src/headerPreview.d.mts +14 -4
- package/src/headerPreview.mjs +10 -8
- package/src/headerPreview.test.mjs +12 -4
- package/src/headerTheme.tsx +19 -26
- package/src/i18n/da-DK/common.ts +1 -0
- package/src/i18n/da-DK/forms.ts +12 -0
- package/src/i18n/en-US/common.ts +2 -0
- package/src/i18n/en-US/forms.ts +15 -0
- package/src/levelStep.d.mts +10 -0
- package/src/levelStep.mjs +66 -0
- package/src/levelStep.test.mjs +119 -0
- package/src/linkAddress.d.mts +21 -0
- package/src/linkAddress.mjs +50 -0
- package/src/linkAddress.test.mjs +57 -0
- package/src/moveItem.d.mts +9 -0
- package/src/moveItem.mjs +17 -0
- package/src/moveItem.test.mjs +16 -0
- package/src/movedRoutes.mjs +8 -3
- package/src/movedRoutes.test.mjs +11 -2
- package/src/schema.ts +11 -0
- package/src/site.ts +1 -0
- package/src/store.ts +5 -33
- package/src/storeSort.tsx +39 -0
- package/src/themeFilter.d.mts +17 -0
- package/src/themeFilter.mjs +16 -0
- package/src/themeFilter.test.mjs +24 -0
- package/src/themeUi.ts +1 -0
- package/src/ui.tsx +2 -1
- package/starter/.gitattributes +2 -0
- package/starter/package.json +1 -1
- package/starter/src/data/social.json +1 -7
- package/theme/blocks/buttons/Buttons.tsx +12 -2
- package/theme/components/Header.astro +21 -31
- package/theme/components/HeaderCta.tsx +21 -0
- package/theme/components/HeaderPhoneButton.tsx +28 -0
- package/theme/components/MobileMenu.tsx +56 -43
- package/theme/components/headerParts.ts +5 -4
- package/theme/styles/global.css +22 -5
- package/theme/styles/ui.css +110 -7
- package/theme/ui/NavigationDrawer.tsx +6 -1
- package/src/legacyMove.test.mjs +0 -137
- package/src/legacyMove.ts +0 -131
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Tests themeFilter.mjs: search words, the installed filter and the order.
|
|
2
|
+
import { test } from 'node:test';
|
|
3
|
+
import assert from 'node:assert/strict';
|
|
4
|
+
import { filterThemes } from './themeFilter.mjs';
|
|
5
|
+
|
|
6
|
+
const list = [
|
|
7
|
+
{ id: 'b', name: 'Beta', words: 'beta calm' },
|
|
8
|
+
{ id: 'a', name: 'Alpha', words: 'alpha bold' },
|
|
9
|
+
];
|
|
10
|
+
const compare = (a, b) => a.localeCompare(b);
|
|
11
|
+
const base = { query: '', state: '', sort: 'az', installed: () => false, compare };
|
|
12
|
+
const ids = (x) => x.map((t) => t.id);
|
|
13
|
+
|
|
14
|
+
test('words must all be found, and the order is A-Z or Z-A', () => {
|
|
15
|
+
assert.deepEqual(ids(filterThemes(list, base)), ['a', 'b']);
|
|
16
|
+
assert.deepEqual(ids(filterThemes(list, { ...base, sort: 'za' })), ['b', 'a']);
|
|
17
|
+
assert.deepEqual(ids(filterThemes(list, { ...base, query: 'calm be' })), ['b']);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('the installed filter keeps installed or not installed themes', () => {
|
|
21
|
+
const installed = (id) => id === 'a';
|
|
22
|
+
assert.deepEqual(ids(filterThemes(list, { ...base, state: 'installed', installed })), ['a']);
|
|
23
|
+
assert.deepEqual(ids(filterThemes(list, { ...base, state: 'notInstalled', installed })), ['b']);
|
|
24
|
+
});
|
package/src/themeUi.ts
CHANGED
|
@@ -52,6 +52,7 @@ export {
|
|
|
52
52
|
NavigationDrawerBack as SiteNavigationDrawerBack,
|
|
53
53
|
focusNavigationDrawerItem as siteFocusNavigationDrawerItem,
|
|
54
54
|
navigationDrawerDialogClass as siteNavigationDrawerDialogClass,
|
|
55
|
+
navigationDrawerBleedClass as siteNavigationDrawerBleedClass,
|
|
55
56
|
navigationDrawerKeys as siteNavigationDrawerKeys,
|
|
56
57
|
NavigationDrawerItem as SiteNavigationDrawerItem,
|
|
57
58
|
NavigationDrawerRow as SiteNavigationDrawerRow,
|
package/src/ui.tsx
CHANGED
|
@@ -87,6 +87,7 @@ import {
|
|
|
87
87
|
SiteNavigationDrawerSection,
|
|
88
88
|
SiteNavigationDrawerSubitem,
|
|
89
89
|
SiteNavigationDrawerToggle,
|
|
90
|
+
siteNavigationDrawerBleedClass,
|
|
90
91
|
siteNavigationDrawerDialogClass,
|
|
91
92
|
siteFocusNavigationDrawerItem,
|
|
92
93
|
SiteSegmentedButton,
|
|
@@ -2857,7 +2858,7 @@ function ModalMainDrawer({
|
|
|
2857
2858
|
<dialog
|
|
2858
2859
|
ref={dialog}
|
|
2859
2860
|
aria-label={label}
|
|
2860
|
-
className={`${siteNavigationDrawerDialogClass} editor-main-drawer`}
|
|
2861
|
+
className={`${siteNavigationDrawerDialogClass} ${siteNavigationDrawerBleedClass} editor-main-drawer`}
|
|
2861
2862
|
onClose={() => onOpenChange(false)}
|
|
2862
2863
|
onCancel={(e) => {
|
|
2863
2864
|
if (escaped.current) e.preventDefault();
|
package/starter/package.json
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@material-symbols/svg-400": "0.48.2",
|
|
33
33
|
"@material/material-color-utilities": "^0.3.0",
|
|
34
34
|
"@milkdown/kit": "^7.22.3",
|
|
35
|
-
"@morphemecms/cms": "0.
|
|
35
|
+
"@morphemecms/cms": "0.13.0",
|
|
36
36
|
"@phosphor-icons/core": "^2.1.1",
|
|
37
37
|
"@phosphor-icons/react": "^2.1.10",
|
|
38
38
|
"@tailwindcss/typography": "^0.5.20",
|
|
@@ -2,11 +2,20 @@
|
|
|
2
2
|
// front page, the price cards, the action bar). Only the buttons: the caller lays them out (.block-buttons in a row).
|
|
3
3
|
// What each shows is made by the contract (@morphemecms/cms/src/standard/buttons/view.ts: buttonsOf in the editor,
|
|
4
4
|
// loadButtons on the site), its kind too. `className`: the site's own classes on each button, e.g. its width. The arrow
|
|
5
|
-
// goes after the text (Button's trailingIcon), the other icons before it.
|
|
5
|
+
// goes after the text (Button's trailingIcon), the other icons before it. `onClick`: what each button does when clicked.
|
|
6
6
|
import Button from '@theme/ui/Button';
|
|
7
7
|
import type { ButtonView } from '@morphemecms/cms/src/standard/buttons/view';
|
|
8
8
|
|
|
9
|
-
export default function Buttons({
|
|
9
|
+
export default function Buttons({
|
|
10
|
+
buttons,
|
|
11
|
+
className,
|
|
12
|
+
onClick,
|
|
13
|
+
}: {
|
|
14
|
+
buttons: ButtonView[];
|
|
15
|
+
className?: string;
|
|
16
|
+
/** Called when a button is clicked (the navigation drawer closes). */
|
|
17
|
+
onClick?: () => void;
|
|
18
|
+
}) {
|
|
10
19
|
return (
|
|
11
20
|
<>
|
|
12
21
|
{buttons.map((b, i) => (
|
|
@@ -19,6 +28,7 @@ export default function Buttons({ buttons, className }: { buttons: ButtonView[];
|
|
|
19
28
|
data-open={b.open}
|
|
20
29
|
className={className}
|
|
21
30
|
aria-label={b.label}
|
|
31
|
+
onClick={onClick}
|
|
22
32
|
>
|
|
23
33
|
{b.text}
|
|
24
34
|
</Button>
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
// The header in Material: a small top app bar (ui/TopAppBar.tsx, m3.material.io/components/top-app-bar) with the navigation drawer's
|
|
3
3
|
// button first (MobileMenu.tsx) on a phone, a tablet and when the menu does not fit, the logo, the menu's items with
|
|
4
4
|
// the open page in an active indicator on a computer (an item with sub-pages has a button with a caret that opens them
|
|
5
|
-
// in a menu (ui/Menu.tsx), also on hover), and
|
|
6
|
-
//
|
|
7
|
-
// as an extended FAB at the bottom right of
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
// button
|
|
11
|
-
//
|
|
12
|
-
//
|
|
5
|
+
// in a menu (ui/Menu.tsx), also on hover), and the call to action at the end (HeaderCta.tsx): the phone number as a text
|
|
6
|
+
// button and the header's button after it; without the menu and its button when "Hovedmenu" is turned off. Under it the
|
|
7
|
+
// bar of "Mobilmenu" (MobileNav.astro), when it is on. Under it, "Book en tid" as an extended FAB at the bottom right of
|
|
8
|
+
// the screen (ui/Fab.tsx, m3.material.io/components/extended-fab), which shows only its icon while the page scrolls down.
|
|
9
|
+
// Not on the booking page and the thank-you page; on a phone with a bar at the bottom of the screen, the bar's first
|
|
10
|
+
// button is the FAB instead (global.css). header.json (optional, site/header.mjs) turns the call to action's button and
|
|
11
|
+
// phone number on and off (they are at the bottom of the navigation drawer too) and puts the menu button at the end (the
|
|
12
|
+
// drawer then opens from that side); data-editor marks the header, the menu button, the menu's items (header-nav) and
|
|
13
|
+
// the call to action (header-cta) for the editor's preview; their classes are in headerParts.ts, which the preview shares.
|
|
13
14
|
import Icon from '@theme/components/Icon.astro';
|
|
14
15
|
import MobileMenu from '@theme/components/MobileMenu.tsx';
|
|
15
16
|
import Logo from '@theme/components/Logo.astro';
|
|
@@ -18,27 +19,30 @@ import MobileNav from '@theme/components/MobileNav.astro';
|
|
|
18
19
|
import { topAppBarClass } from '@theme/ui/TopAppBar';
|
|
19
20
|
import { menuClass, menuItemClass } from '@theme/ui/Menu';
|
|
20
21
|
import { extendedFabClass } from '@theme/ui/Fab';
|
|
21
|
-
import
|
|
22
|
-
import {
|
|
22
|
+
import HeaderCta from '@theme/components/HeaderCta';
|
|
23
|
+
import { headerMenuClass } from '@theme/components/headerParts';
|
|
23
24
|
import { loadButtons } from '@morphemecms/cms/src/standard/buttons/load';
|
|
24
25
|
import { site, nav, navShown, header } from '@morphemecms/cms/site/site';
|
|
25
26
|
import { siteT } from '@morphemecms/cms/src/i18n';
|
|
26
27
|
|
|
27
28
|
const current = Astro.url.pathname;
|
|
28
29
|
const isActive = (href: string) => current === href || (href !== '/' && current.startsWith(href));
|
|
29
|
-
// The
|
|
30
|
+
// The call to action (header.json): the header's button (none when it is off) and the phone number (when it is on).
|
|
30
31
|
const button = header.button ? (await loadButtons([{ ...header.button, kind: 'filled' }]))[0] : undefined;
|
|
32
|
+
// The phone number (Business › Contact): it calls on a phone, and leads to the contact page (Default pages) on a computer.
|
|
33
|
+
const phone =
|
|
34
|
+
header.phone && site.phone
|
|
35
|
+
? { number: site.phone, href: site.phoneHref, label: `${site.labels.call} ${site.phone}`, page: site.contactPath || undefined }
|
|
36
|
+
: undefined;
|
|
31
37
|
const menuEnd = header.menuSide === 'end';
|
|
32
38
|
const menuProps = {
|
|
33
39
|
items: nav,
|
|
34
40
|
current,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
side: header.menuSide,
|
|
42
|
+
button,
|
|
43
|
+
phone,
|
|
38
44
|
name: site.name,
|
|
39
45
|
role: site.role,
|
|
40
|
-
book: site.labels.book,
|
|
41
|
-
call: site.labels.call,
|
|
42
46
|
texts: {
|
|
43
47
|
open: siteT.theme.openMenu,
|
|
44
48
|
close: siteT.theme.closeMenu,
|
|
@@ -115,21 +119,7 @@ const fab = !current.startsWith(site.bookingPath) && current !== '/tak/';
|
|
|
115
119
|
</nav>
|
|
116
120
|
)}
|
|
117
121
|
|
|
118
|
-
{button
|
|
119
|
-
<div data-editor="header-cta" class={headerCtaClass}>
|
|
120
|
-
<Buttons buttons={[button]} />
|
|
121
|
-
</div>
|
|
122
|
-
) : (
|
|
123
|
-
<a
|
|
124
|
-
href={site.phoneHref}
|
|
125
|
-
data-editor="header-cta"
|
|
126
|
-
class:list={['icon-button icon-button-standard', headerEdge.end]}
|
|
127
|
-
aria-label={`${site.labels.call} ${site.phone}`}
|
|
128
|
-
title={site.phone}
|
|
129
|
-
>
|
|
130
|
-
<Icon name="phone" size={24} />
|
|
131
|
-
</a>
|
|
132
|
-
)}
|
|
122
|
+
<HeaderCta button={button} phone={phone} />
|
|
133
123
|
{navShown && menuEnd && (
|
|
134
124
|
<div data-editor="header-menu" class={headerMenuClass('end')}>
|
|
135
125
|
<MobileMenu client:interact {...menuProps} />
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// The header's call to action (header.json's "Call to action", site/header.mjs): the site's phone number (Business ›
|
|
2
|
+
// Contact) as a text button and the header's button (filled) after it, both from the medium window size up only: on a
|
|
3
|
+
// phone both are at the bottom of the navigation drawer (MobileMenu.tsx), where the number calls (tel:). Here, where a
|
|
4
|
+
// computer cannot call, the number leads to the contact page (Default pages), when the site has one, else it calls. Drawn by Header.astro and by the editor's preview of the header (src/headerTheme.tsx), so both draw it
|
|
5
|
+
// the same; data-editor="header-cta" marks it for the preview. Nothing when both are off.
|
|
6
|
+
import Buttons from '@theme/blocks/buttons/Buttons';
|
|
7
|
+
import HeaderPhoneButton, { type HeaderPhone } from '@theme/components/HeaderPhoneButton';
|
|
8
|
+
import type { ButtonView } from '@morphemecms/cms/src/standard/buttons/view';
|
|
9
|
+
import { headerCtaClass } from '@theme/components/headerParts';
|
|
10
|
+
|
|
11
|
+
export type { HeaderPhone };
|
|
12
|
+
|
|
13
|
+
export default function HeaderCta({ button, phone }: { button?: ButtonView; phone?: HeaderPhone }) {
|
|
14
|
+
if (!button && !phone) return <span data-editor="header-cta" hidden />;
|
|
15
|
+
return (
|
|
16
|
+
<div data-editor="header-cta" className={headerCtaClass}>
|
|
17
|
+
{phone && <HeaderPhoneButton phone={phone} kind="text" page />}
|
|
18
|
+
{button && <Buttons buttons={[button]} />}
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// The site's phone number as a button with a phone icon (Button.tsx), in the header (HeaderCta.tsx) and at the bottom of the
|
|
2
|
+
// navigation drawer (MobileMenu.tsx). Exposes HeaderPhone and HeaderPhoneButton; `page` makes it lead to the contact page
|
|
3
|
+
// (phone.page) instead of calling (tel:), and only a call has the screen reader label ("Ring 12 34 56 78").
|
|
4
|
+
import Button from '@theme/ui/Button';
|
|
5
|
+
|
|
6
|
+
/** The phone number as the header shows it: the number, its tel: address, what a screen reader says of that link ("Ring 12
|
|
7
|
+
* 34 56 78") and the contact page (`page`, where it leads from the medium window size up; without one, it calls there too). */
|
|
8
|
+
export type HeaderPhone = { number: string; href: string; label: string; page?: string };
|
|
9
|
+
|
|
10
|
+
export default function HeaderPhoneButton({
|
|
11
|
+
phone,
|
|
12
|
+
kind,
|
|
13
|
+
page,
|
|
14
|
+
onClick,
|
|
15
|
+
}: {
|
|
16
|
+
phone: HeaderPhone;
|
|
17
|
+
kind: 'text' | 'outlined';
|
|
18
|
+
/** Lead to the contact page, not call (needs phone.page). */
|
|
19
|
+
page?: boolean;
|
|
20
|
+
onClick?: () => void;
|
|
21
|
+
}) {
|
|
22
|
+
const to = page && phone.page ? phone.page : undefined;
|
|
23
|
+
return (
|
|
24
|
+
<Button href={to ?? phone.href} kind={kind} icon="phone" aria-label={to ? undefined : phone.label} onClick={onClick}>
|
|
25
|
+
{phone.number}
|
|
26
|
+
</Button>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
// The menu in Material: the theme's modal navigation drawer (ui/NavigationDrawer.tsx, m3.material.io/components/navigation-drawer), opened by the
|
|
2
|
-
// navigation icon
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
2
|
+
// navigation icon in the top app bar (Header.astro). It comes in over a scrim from the side its button is on (`side`:
|
|
3
|
+
// the start, left, or the end, right; mirrored in right-to-left languages), with the site's name, the menu's items with
|
|
4
|
+
// the open page in an active indicator, and at its bottom the header's call to action (header.json), each part when it
|
|
5
|
+
// is on: the phone number (a tel: link on a phone, the contact page from the medium window size up) and the button after
|
|
6
|
+
// it in one row, sharing the drawer's width (the button on top of the number when they do not fit side by side). Items with sub-pages unfold
|
|
7
|
+
// with the caret at the end of their row (inside the active indicator); the one with the open page starts open.
|
|
6
8
|
// Rendered through a portal into <body>, so nothing on the page can clip it. It moves with the site's motion scheme
|
|
7
9
|
// (motionSpring, @morphemecms/cms/lib/motion.ts: Material 3's springs, the expressive ones unless the owner chose
|
|
8
|
-
// another under "Bevægelse"); with reduced motion it appears at once.
|
|
10
|
+
// another under "Bevægelse"); with reduced motion it appears at once. A spring that overshoots carries the drawer a little
|
|
11
|
+
// past its place, so it is wider than it looks by a strip off the screen at its edge (navigationDrawerBleedClass): no gap
|
|
12
|
+
// opens at the edge while it settles.
|
|
9
13
|
import { useEffect, useRef, useState } from 'react';
|
|
10
14
|
import { createPortal } from 'react-dom';
|
|
11
15
|
import { AnimatePresence, motion, useReducedMotion } from 'motion/react';
|
|
12
16
|
import { motionSpring } from '@morphemecms/cms/lib/motion';
|
|
17
|
+
import { trapTarget, visibleElements } from '@morphemecms/cms/lib/focusTrap.mjs';
|
|
13
18
|
import IconButton from '@theme/ui/IconButton';
|
|
14
|
-
import
|
|
19
|
+
import Buttons from '@theme/blocks/buttons/Buttons';
|
|
20
|
+
import HeaderPhoneButton, { type HeaderPhone } from '@theme/components/HeaderPhoneButton';
|
|
21
|
+
import type { ButtonView } from '@morphemecms/cms/src/standard/buttons/view';
|
|
15
22
|
import {
|
|
16
23
|
NavigationDrawerItem,
|
|
17
24
|
NavigationDrawerRow,
|
|
@@ -19,7 +26,9 @@ import {
|
|
|
19
26
|
NavigationDrawerSubitem,
|
|
20
27
|
NavigationDrawerToggle,
|
|
21
28
|
focusNavigationDrawerItem,
|
|
29
|
+
navigationDrawerBleedClass,
|
|
22
30
|
navigationDrawerClass,
|
|
31
|
+
navigationDrawerEndClass,
|
|
23
32
|
navigationDrawerKeys,
|
|
24
33
|
navigationDrawerScrimClass,
|
|
25
34
|
} from '@theme/ui/NavigationDrawer';
|
|
@@ -30,25 +39,22 @@ type Item = Link & { children?: Link[] };
|
|
|
30
39
|
export default function MobileMenu({
|
|
31
40
|
items,
|
|
32
41
|
current,
|
|
33
|
-
|
|
42
|
+
side = 'start',
|
|
43
|
+
button,
|
|
34
44
|
phone,
|
|
35
|
-
phoneHref,
|
|
36
45
|
name,
|
|
37
46
|
role,
|
|
38
|
-
book,
|
|
39
|
-
call,
|
|
40
47
|
texts,
|
|
41
48
|
}: {
|
|
42
49
|
items: Item[];
|
|
43
50
|
current: string;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
/** The side of the screen it opens from: its button's (header.json's menuSide). */
|
|
52
|
+
side?: 'start' | 'end';
|
|
53
|
+
/** The header's call to action (header.json), at the bottom: its button, and the phone number; each when it is on. */
|
|
54
|
+
button?: ButtonView;
|
|
55
|
+
phone?: HeaderPhone;
|
|
47
56
|
name: string;
|
|
48
57
|
role: string;
|
|
49
|
-
/** The site's own labels of "Book en tid" and "Ring". */
|
|
50
|
-
book: string;
|
|
51
|
-
call: string;
|
|
52
58
|
/** Its texts in the site's language (Header.astro has them, so the editor's dictionaries stay out of the browser). */
|
|
53
59
|
texts: { open: string; close: string; menu: string; drawer: string; subpages: string[] };
|
|
54
60
|
}) {
|
|
@@ -66,12 +72,14 @@ export default function MobileMenu({
|
|
|
66
72
|
fadeOut: motionSpring('effects', 'fast'),
|
|
67
73
|
}));
|
|
68
74
|
|
|
69
|
-
// The edge it comes from is the start edge
|
|
70
|
-
|
|
75
|
+
// The edge it comes from is its side's: the start edge slides it in from the left (from the right in right-to-left
|
|
76
|
+
// languages), the end edge from the right (the left).
|
|
77
|
+
const [away, setAway] = useState(side === 'end' ? '100%' : '-100%');
|
|
71
78
|
useEffect(() => {
|
|
72
79
|
setMounted(true);
|
|
73
|
-
|
|
74
|
-
|
|
80
|
+
const rtl = getComputedStyle(document.documentElement).direction === 'rtl';
|
|
81
|
+
setAway(rtl === (side === 'end') ? '-100%' : '100%');
|
|
82
|
+
}, [side]);
|
|
75
83
|
|
|
76
84
|
useEffect(() => {
|
|
77
85
|
if (!open) return;
|
|
@@ -86,15 +94,11 @@ export default function MobileMenu({
|
|
|
86
94
|
if (e.key === 'Escape') setOpen(false);
|
|
87
95
|
// Keep keyboard focus inside the drawer while it is open.
|
|
88
96
|
if (e.key === 'Tab' && drawer.current) {
|
|
89
|
-
const focusable = drawer.current.querySelectorAll<HTMLElement>('a[href], button');
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
if (e.shiftKey && document.activeElement === first) {
|
|
97
|
+
const focusable = visibleElements(drawer.current.querySelectorAll<HTMLElement>('a[href], button'));
|
|
98
|
+
const target = trapTarget(e.shiftKey, focusable.indexOf(document.activeElement as HTMLElement), focusable.length);
|
|
99
|
+
if (target !== null) {
|
|
93
100
|
e.preventDefault();
|
|
94
|
-
|
|
95
|
-
} else if (!e.shiftKey && document.activeElement === last) {
|
|
96
|
-
e.preventDefault();
|
|
97
|
-
first.focus();
|
|
101
|
+
focusable[target].focus();
|
|
98
102
|
}
|
|
99
103
|
}
|
|
100
104
|
};
|
|
@@ -144,7 +148,12 @@ export default function MobileMenu({
|
|
|
144
148
|
role="dialog"
|
|
145
149
|
aria-modal="true"
|
|
146
150
|
aria-label={texts.drawer}
|
|
147
|
-
className={
|
|
151
|
+
className={[
|
|
152
|
+
navigationDrawerClass,
|
|
153
|
+
navigationDrawerBleedClass,
|
|
154
|
+
side === 'end' ? `${navigationDrawerEndClass} end-0` : 'start-0',
|
|
155
|
+
'absolute inset-y-0',
|
|
156
|
+
].join(' ')}
|
|
148
157
|
initial={reduce ? false : { x: away }}
|
|
149
158
|
animate={{ x: 0, transition: reduce ? { duration: 0 } : spring.enter }}
|
|
150
159
|
exit={reduce ? undefined : { x: away, transition: spring.leave }}
|
|
@@ -158,15 +167,6 @@ export default function MobileMenu({
|
|
|
158
167
|
<IconButton icon="x" label={texts.close} onClick={() => setOpen(false)} />
|
|
159
168
|
</div>
|
|
160
169
|
|
|
161
|
-
<ExtendedFab
|
|
162
|
-
href={bookingPath}
|
|
163
|
-
icon="calendar-blank"
|
|
164
|
-
label={book}
|
|
165
|
-
kind="secondary-container"
|
|
166
|
-
data-open="booking"
|
|
167
|
-
onClick={() => setOpen(false)}
|
|
168
|
-
/>
|
|
169
|
-
|
|
170
170
|
<NavigationDrawerSection>
|
|
171
171
|
<nav aria-label={texts.menu}>
|
|
172
172
|
<ul>
|
|
@@ -219,11 +219,24 @@ export default function MobileMenu({
|
|
|
219
219
|
</nav>
|
|
220
220
|
</NavigationDrawerSection>
|
|
221
221
|
|
|
222
|
-
|
|
223
|
-
<
|
|
224
|
-
{
|
|
225
|
-
|
|
226
|
-
|
|
222
|
+
{(button || phone) && (
|
|
223
|
+
<div className="md-drawer-actions">
|
|
224
|
+
{phone && (
|
|
225
|
+
// On a phone it calls; from the medium window size up it leads to the contact page, when there is one.
|
|
226
|
+
<>
|
|
227
|
+
<span className={phone.page ? 'contents medium:hidden' : 'contents'}>
|
|
228
|
+
<HeaderPhoneButton phone={phone} kind="outlined" />
|
|
229
|
+
</span>
|
|
230
|
+
{phone.page && (
|
|
231
|
+
<span className="hidden medium:contents">
|
|
232
|
+
<HeaderPhoneButton phone={phone} kind="outlined" page onClick={() => setOpen(false)} />
|
|
233
|
+
</span>
|
|
234
|
+
)}
|
|
235
|
+
</>
|
|
236
|
+
)}
|
|
237
|
+
{button && <Buttons buttons={[button]} onClick={() => setOpen(false)} />}
|
|
238
|
+
</div>
|
|
239
|
+
)}
|
|
227
240
|
</motion.div>
|
|
228
241
|
</div>
|
|
229
242
|
)}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
// The classes of the header's parts that its settings move or put in (Header.astro, MobileNav.astro), shared with the
|
|
2
2
|
// editor's preview of the header (src/headerTheme.tsx), so both draw them the same.
|
|
3
|
-
// Exposes headerEdge, headerMenuClass, headerCtaClass, mobileNavClass and mobileNavListClass. Uses ui/Tabs.tsx.
|
|
3
|
+
// Exposes headerEdge, headerMenuClass, headerCtaClass (HeaderCta.tsx), mobileNavClass and mobileNavListClass. Uses ui/Tabs.tsx.
|
|
4
4
|
import { tabsClass } from '@theme/ui/Tabs';
|
|
5
5
|
|
|
6
|
-
/** The place of a part at the start of the row
|
|
6
|
+
/** The place of a part at the start of the row and at its end (the menu button). */
|
|
7
7
|
export const headerEdge = { start: '-ml-2 mr-1', end: '-mr-2 ml-1' } as const;
|
|
8
8
|
|
|
9
9
|
/** The menu button's box at either side: shown where the menu's items are not (below large, or when they do not fit). */
|
|
10
10
|
export const headerMenuClass = (side: 'start' | 'end') => `${headerEdge[side]} large:hidden large:group-data-crowded/header:block`;
|
|
11
11
|
|
|
12
|
-
/** The header's
|
|
13
|
-
|
|
12
|
+
/** The box of the header's call to action (header.json, HeaderCta.tsx): the phone and the button in a row, from the
|
|
13
|
+
* medium window size up (on a phone they are in the navigation drawer). */
|
|
14
|
+
export const headerCtaClass = 'ml-1 hidden shrink-0 items-center gap-2 medium:flex';
|
|
14
15
|
|
|
15
16
|
/** The bar of "Mobilmenu" under the header, where the menu's items are not, and its row of tabs. */
|
|
16
17
|
export const mobileNavClass = 'large:hidden large:group-data-crowded/header:block';
|
package/theme/styles/global.css
CHANGED
|
@@ -216,11 +216,14 @@
|
|
|
216
216
|
--list-item-gap: 0.75rem;
|
|
217
217
|
--list-item-radius: var(--md-shape-extra-small);
|
|
218
218
|
--list-item-hover-radius: var(--md-shape-medium);
|
|
219
|
-
--list-item-pressed-radius: var(--md-shape-
|
|
220
|
-
--list-item-selected-radius: var(--md-shape-
|
|
219
|
+
--list-item-pressed-radius: var(--md-shape-medium);
|
|
220
|
+
--list-item-selected-radius: var(--md-shape-medium);
|
|
221
221
|
--list-item-icon-size: 1.25rem;
|
|
222
222
|
--list-item-hover-surface: var(--md-hover);
|
|
223
223
|
--list-item-pressed-surface: var(--md-pressed);
|
|
224
|
+
--list-item-hover-icon-color: var(--muted);
|
|
225
|
+
--list-item-focus-surface: var(--md-pressed);
|
|
226
|
+
--list-item-focus-indicator-color: var(--secondary);
|
|
224
227
|
--list-item-hover-text: var(--ink);
|
|
225
228
|
--list-item-hover-trailing-shift: 0;
|
|
226
229
|
--list-item-selected-surface: var(--secondary-container);
|
|
@@ -229,11 +232,11 @@
|
|
|
229
232
|
--list-item-leading-icon-selected-color: var(--accent);
|
|
230
233
|
--list-item-disabled-opacity: 0.38;
|
|
231
234
|
--list-segmented-gap: 0.125rem;
|
|
232
|
-
--list-segmented-radius: var(--md-shape-
|
|
235
|
+
--list-segmented-radius: var(--md-shape-medium);
|
|
233
236
|
--list-segmented-inner-radius: var(--md-shape-extra-small);
|
|
234
237
|
--list-segmented-hover-radius: var(--md-shape-medium);
|
|
235
|
-
--list-segmented-pressed-radius: var(--md-shape-
|
|
236
|
-
--list-segmented-selected-radius: var(--md-shape-
|
|
238
|
+
--list-segmented-pressed-radius: var(--md-shape-medium);
|
|
239
|
+
--list-segmented-selected-radius: var(--md-shape-medium);
|
|
237
240
|
--list-segmented-padding-inline: 1rem;
|
|
238
241
|
--list-segmented-surface: var(--md-surface-container);
|
|
239
242
|
--list-segmented-hover-surface: var(--md-hover);
|
|
@@ -1133,6 +1136,20 @@
|
|
|
1133
1136
|
font-weight: var(--type-title-medium-weight);
|
|
1134
1137
|
letter-spacing: var(--type-title-medium-tracking);
|
|
1135
1138
|
}
|
|
1139
|
+
/* Its bottom: the header's call to action (header.json), the phone number and the button in one row sharing the
|
|
1140
|
+
drawer's width, as in the header; when they do not fit side by side, the button over the number (wrap-reverse), each
|
|
1141
|
+
as wide as the drawer. At the bottom of the drawer when its items leave room, else after them. */
|
|
1142
|
+
.md-drawer-actions {
|
|
1143
|
+
display: flex;
|
|
1144
|
+
flex-wrap: wrap-reverse;
|
|
1145
|
+
gap: 0.75rem;
|
|
1146
|
+
margin-top: auto;
|
|
1147
|
+
padding: 1.5rem 0.25rem 0;
|
|
1148
|
+
}
|
|
1149
|
+
.md-drawer-actions .button {
|
|
1150
|
+
flex: 1 1 auto;
|
|
1151
|
+
white-space: nowrap;
|
|
1152
|
+
}
|
|
1136
1153
|
.md-drawer-role {
|
|
1137
1154
|
color: var(--muted);
|
|
1138
1155
|
font-size: var(--type-body-medium-size);
|