Fit the page header on phones
At 375 px the header's buttons ran past the screen and the page scrolled sideways. Below the sm breakpoint, favourite, attach, history and info now sit at the top of the More menu instead; comments, share and the menu stay in the header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8814293988
commit
34ba3774a6
1 file changed
+32
-1
@@ -584,7 +584,35 @@ const suggestAs = computed(() =>
|
||||
suggesting.value && editable.value && auth.user ? { id: auth.user.id, name: me.value.name } : null,
|
||||
);
|
||||
|
||||
// On phones the header has room for the main buttons only; favourite,
|
||||
// attach, history and info move to the top of the More menu (below sm,
|
||||
// where those buttons are hidden with max-sm:hidden).
|
||||
const phoneQuery = typeof window !== "undefined" ? window.matchMedia("(width < 40rem)") : null;
|
||||
const phone = ref(phoneQuery?.matches ?? false);
|
||||
const onPhoneChange = (e: MediaQueryListEvent) => (phone.value = e.matches);
|
||||
phoneQuery?.addEventListener("change", onPhoneChange);
|
||||
onBeforeUnmount(() => phoneQuery?.removeEventListener("change", onPhoneChange));
|
||||
const phoneItems = computed<MenuItem[]>(() => {
|
||||
if (!phone.value || !page.value) return [];
|
||||
const items: MenuItem[] = [
|
||||
{
|
||||
label: t(page.value.favorite ? "page.unfavorite" : "page.favorite"),
|
||||
icon: "star",
|
||||
onSelect: () => void toggleFavorite(),
|
||||
},
|
||||
];
|
||||
if (editable.value && main.value && mode.value === "page") {
|
||||
items.push({ label: t("page.attach"), icon: "paperclip", onSelect: () => filePicker.value?.click() });
|
||||
}
|
||||
items.push(
|
||||
{ label: t("page.history.title"), icon: "restore", onSelect: () => (historyOpen.value = !historyOpen.value) },
|
||||
{ label: t("properties.info"), icon: "info", onSelect: () => (infoOpen.value = !infoOpen.value) },
|
||||
);
|
||||
return items;
|
||||
});
|
||||
|
||||
const menu = computed<MenuItem[]>(() => [
|
||||
...phoneItems.value,
|
||||
...(mode.value === "page"
|
||||
? [{ label: t("page.find"), icon: "search" as const, onSelect: () => editorRef.value?.openFind() }]
|
||||
: []),
|
||||
@@ -760,7 +788,7 @@ const purge = () =>
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
class="grid size-control-sm shrink-0 cursor-pointer place-items-center rounded-sm hover:bg-surface-hover"
|
||||
class="grid size-control-sm shrink-0 cursor-pointer place-items-center rounded-sm hover:bg-surface-hover max-sm:hidden"
|
||||
:class="page.favorite ? 'text-warning' : 'text-ink-muted hover:text-ink'"
|
||||
:aria-pressed="page.favorite"
|
||||
:aria-label="$t(page.favorite ? 'page.unfavorite' : 'page.favorite')"
|
||||
@@ -777,6 +805,7 @@ const purge = () =>
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
icon="paperclip"
|
||||
class="max-sm:hidden"
|
||||
:aria-label="$t('page.attach')"
|
||||
:title="$t('page.attach')"
|
||||
:disabled="busy"
|
||||
@@ -787,6 +816,7 @@ const purge = () =>
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
icon="restore"
|
||||
class="max-sm:hidden"
|
||||
:class="{ 'bg-surface-hover text-ink': historyOpen }"
|
||||
:aria-pressed="historyOpen"
|
||||
data-testid="history-toggle"
|
||||
@@ -799,6 +829,7 @@ const purge = () =>
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
icon="info"
|
||||
class="max-sm:hidden"
|
||||
:class="{ 'bg-surface-hover text-ink': infoOpen }"
|
||||
:aria-pressed="infoOpen"
|
||||
data-testid="info-toggle"
|
||||
|
||||
Reference in new issue
Block a user