Given better default for how to close opened menus when url or hash change
This commit is contained in:
parent
311d91c370
commit
2b3ecc665c
|
@ -9,7 +9,7 @@ import { useMediaMobile } from "hooks/useMediaQuery";
|
||||||
import { AnchorIds } from "hooks/useScrollTopOnChange";
|
import { AnchorIds } from "hooks/useScrollTopOnChange";
|
||||||
import Head from "next/head";
|
import Head from "next/head";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
import { useSwipeable } from "react-swipeable";
|
import { useSwipeable } from "react-swipeable";
|
||||||
import { OrderableList } from "./Inputs/OrderableList";
|
import { OrderableList } from "./Inputs/OrderableList";
|
||||||
import { Select } from "./Inputs/Select";
|
import { Select } from "./Inputs/Select";
|
||||||
|
@ -45,6 +45,17 @@ export function AppLayout(props: Immutable<Props>): JSX.Element {
|
||||||
|
|
||||||
const sensibilitySwipe = 1.1;
|
const sensibilitySwipe = 1.1;
|
||||||
|
|
||||||
|
useMemo(() => {
|
||||||
|
router.events?.on("routeChangeStart", () => {
|
||||||
|
appLayout.setConfigPanelOpen(false);
|
||||||
|
appLayout.setMainPanelOpen(false);
|
||||||
|
appLayout.setSubPanelOpen(false);
|
||||||
|
});
|
||||||
|
router.events?.on("hashChangeStart", () => {
|
||||||
|
appLayout.setSubPanelOpen(false);
|
||||||
|
});
|
||||||
|
}, [appLayout, router.events]);
|
||||||
|
|
||||||
const handlers = useSwipeable({
|
const handlers = useSwipeable({
|
||||||
onSwipedLeft: (SwipeEventData) => {
|
onSwipedLeft: (SwipeEventData) => {
|
||||||
if (appLayout.menuGestures) {
|
if (appLayout.menuGestures) {
|
||||||
|
|
|
@ -43,7 +43,6 @@ export function MainPanel(props: Immutable<Props>): JSX.Element {
|
||||||
<div className="grid place-items-center">
|
<div className="grid place-items-center">
|
||||||
<Link href="/" passHref>
|
<Link href="/" passHref>
|
||||||
<div
|
<div
|
||||||
onClick={() => appLayout.setMainPanelOpen(false)}
|
|
||||||
className={`${
|
className={`${
|
||||||
appLayout.mainPanelReduced && isDesktop ? "w-12" : "w-1/2"
|
appLayout.mainPanelReduced && isDesktop ? "w-12" : "w-1/2"
|
||||||
} aspect-square cursor-pointer transition-colors [mask:url('/icons/accords.svg')]
|
} aspect-square cursor-pointer transition-colors [mask:url('/icons/accords.svg')]
|
||||||
|
@ -114,7 +113,6 @@ export function MainPanel(props: Immutable<Props>): JSX.Element {
|
||||||
title={langui.library}
|
title={langui.library}
|
||||||
subtitle={langui.library_short_description}
|
subtitle={langui.library_short_description}
|
||||||
reduced={appLayout.mainPanelReduced && isDesktop}
|
reduced={appLayout.mainPanelReduced && isDesktop}
|
||||||
onClick={() => appLayout.setMainPanelOpen(false)}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<NavOption
|
<NavOption
|
||||||
|
@ -123,7 +121,6 @@ export function MainPanel(props: Immutable<Props>): JSX.Element {
|
||||||
title={langui.contents}
|
title={langui.contents}
|
||||||
subtitle={langui.contents_short_description}
|
subtitle={langui.contents_short_description}
|
||||||
reduced={appLayout.mainPanelReduced && isDesktop}
|
reduced={appLayout.mainPanelReduced && isDesktop}
|
||||||
onClick={() => appLayout.setMainPanelOpen(false)}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<NavOption
|
<NavOption
|
||||||
|
@ -132,7 +129,6 @@ export function MainPanel(props: Immutable<Props>): JSX.Element {
|
||||||
title={langui.wiki}
|
title={langui.wiki}
|
||||||
subtitle={langui.wiki_short_description}
|
subtitle={langui.wiki_short_description}
|
||||||
reduced={appLayout.mainPanelReduced && isDesktop}
|
reduced={appLayout.mainPanelReduced && isDesktop}
|
||||||
onClick={() => appLayout.setMainPanelOpen(false)}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/*
|
{/*
|
||||||
|
@ -144,7 +140,7 @@ export function MainPanel(props: Immutable<Props>): JSX.Element {
|
||||||
subtitle={langui.chronicles_short_description}
|
subtitle={langui.chronicles_short_description}
|
||||||
|
|
||||||
reduced={appLayout.mainPanelReduced && isDesktop}
|
reduced={appLayout.mainPanelReduced && isDesktop}
|
||||||
onClick={() => appLayout.setMainPanelOpen(false)}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
*/}
|
*/}
|
||||||
|
@ -156,7 +152,6 @@ export function MainPanel(props: Immutable<Props>): JSX.Element {
|
||||||
icon="feed"
|
icon="feed"
|
||||||
title={langui.news}
|
title={langui.news}
|
||||||
reduced={appLayout.mainPanelReduced && isDesktop}
|
reduced={appLayout.mainPanelReduced && isDesktop}
|
||||||
onClick={() => appLayout.setMainPanelOpen(false)}
|
|
||||||
/>
|
/>
|
||||||
{/*
|
{/*
|
||||||
<NavOption
|
<NavOption
|
||||||
|
@ -165,7 +160,7 @@ export function MainPanel(props: Immutable<Props>): JSX.Element {
|
||||||
title={langui.merch}
|
title={langui.merch}
|
||||||
|
|
||||||
reduced={appLayout.mainPanelReduced && isDesktop}
|
reduced={appLayout.mainPanelReduced && isDesktop}
|
||||||
onClick={() => appLayout.setMainPanelOpen(false)}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
*/}
|
*/}
|
||||||
|
@ -175,7 +170,6 @@ export function MainPanel(props: Immutable<Props>): JSX.Element {
|
||||||
icon="collections"
|
icon="collections"
|
||||||
title={langui.gallery}
|
title={langui.gallery}
|
||||||
reduced={appLayout.mainPanelReduced && isDesktop}
|
reduced={appLayout.mainPanelReduced && isDesktop}
|
||||||
onClick={() => appLayout.setMainPanelOpen(false)}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<NavOption
|
<NavOption
|
||||||
|
@ -183,7 +177,6 @@ export function MainPanel(props: Immutable<Props>): JSX.Element {
|
||||||
icon="inventory"
|
icon="inventory"
|
||||||
title={langui.archives}
|
title={langui.archives}
|
||||||
reduced={appLayout.mainPanelReduced && isDesktop}
|
reduced={appLayout.mainPanelReduced && isDesktop}
|
||||||
onClick={() => appLayout.setMainPanelOpen(false)}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<NavOption
|
<NavOption
|
||||||
|
@ -191,7 +184,6 @@ export function MainPanel(props: Immutable<Props>): JSX.Element {
|
||||||
icon="info"
|
icon="info"
|
||||||
title={langui.about_us}
|
title={langui.about_us}
|
||||||
reduced={appLayout.mainPanelReduced && isDesktop}
|
reduced={appLayout.mainPanelReduced && isDesktop}
|
||||||
onClick={() => appLayout.setMainPanelOpen(false)}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{appLayout.mainPanelReduced && isDesktop ? "" : <HorizontalLine />}
|
{appLayout.mainPanelReduced && isDesktop ? "" : <HorizontalLine />}
|
||||||
|
|
|
@ -90,45 +90,24 @@ export default function LibrarySlug(props: Immutable<Props>): JSX.Element {
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="grid gap-4">
|
<div className="grid gap-4">
|
||||||
<NavOption
|
<NavOption title={langui.summary} url="#summary" border />
|
||||||
title={langui.summary}
|
|
||||||
url="#summary"
|
|
||||||
border
|
|
||||||
onClick={() => appLayout.setSubPanelOpen(false)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{item?.gallery && item.gallery.data.length > 0 && (
|
{item?.gallery && item.gallery.data.length > 0 && (
|
||||||
<NavOption
|
<NavOption title={langui.gallery} url="#gallery" border />
|
||||||
title={langui.gallery}
|
|
||||||
url="#gallery"
|
|
||||||
border
|
|
||||||
onClick={() => appLayout.setSubPanelOpen(false)}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<NavOption
|
<NavOption title={langui.details} url="#details" border />
|
||||||
title={langui.details}
|
|
||||||
url="#details"
|
|
||||||
border
|
|
||||||
onClick={() => appLayout.setSubPanelOpen(false)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{item?.subitems && item.subitems.data.length > 0 && (
|
{item?.subitems && item.subitems.data.length > 0 && (
|
||||||
<NavOption
|
<NavOption
|
||||||
title={isVariantSet ? langui.variants : langui.subitems}
|
title={isVariantSet ? langui.variants : langui.subitems}
|
||||||
url={isVariantSet ? "#variants" : "#subitems"}
|
url={isVariantSet ? "#variants" : "#subitems"}
|
||||||
border
|
border
|
||||||
onClick={() => appLayout.setSubPanelOpen(false)}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{item?.contents && item.contents.data.length > 0 && (
|
{item?.contents && item.contents.data.length > 0 && (
|
||||||
<NavOption
|
<NavOption title={langui.contents} url="#contents" border />
|
||||||
title={langui.contents}
|
|
||||||
url="#contents"
|
|
||||||
border
|
|
||||||
onClick={() => appLayout.setSubPanelOpen(false)}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</SubPanel>
|
</SubPanel>
|
||||||
|
|
|
@ -11,7 +11,6 @@ import {
|
||||||
ContentPanelWidthSizes,
|
ContentPanelWidthSizes,
|
||||||
} from "components/Panels/ContentPanel";
|
} from "components/Panels/ContentPanel";
|
||||||
import { SubPanel } from "components/Panels/SubPanel";
|
import { SubPanel } from "components/Panels/SubPanel";
|
||||||
import { useAppLayout } from "contexts/AppLayoutContext";
|
|
||||||
import { GetLibraryItemScansQuery } from "graphql/generated";
|
import { GetLibraryItemScansQuery } from "graphql/generated";
|
||||||
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { getReadySdk } from "graphql/sdk";
|
import { getReadySdk } from "graphql/sdk";
|
||||||
|
@ -36,11 +35,8 @@ interface Props extends AppStaticProps {
|
||||||
|
|
||||||
export default function LibrarySlug(props: Immutable<Props>): JSX.Element {
|
export default function LibrarySlug(props: Immutable<Props>): JSX.Element {
|
||||||
const { item, langui, languages } = props;
|
const { item, langui, languages } = props;
|
||||||
const appLayout = useAppLayout();
|
|
||||||
|
|
||||||
sortContent(item?.contents);
|
|
||||||
|
|
||||||
const [openLightBox, LightBox] = useLightBox();
|
const [openLightBox, LightBox] = useLightBox();
|
||||||
|
sortContent(item?.contents);
|
||||||
|
|
||||||
const subPanel = (
|
const subPanel = (
|
||||||
<SubPanel>
|
<SubPanel>
|
||||||
|
@ -65,7 +61,6 @@ export default function LibrarySlug(props: Immutable<Props>): JSX.Element {
|
||||||
`${content.attributes.range[0].ending_page}`
|
`${content.attributes.range[0].ending_page}`
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
onClick={() => appLayout.setSubPanelOpen(false)}
|
|
||||||
border
|
border
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|
|
@ -85,7 +85,6 @@ export default function Chronology(props: Props): JSX.Element {
|
||||||
}
|
}
|
||||||
subtitle={`${era.attributes.starting_year} → ${era.attributes.ending_year}`}
|
subtitle={`${era.attributes.starting_year} → ${era.attributes.ending_year}`}
|
||||||
border
|
border
|
||||||
onClick={() => appLayout.setSubPanelOpen(false)}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|
Loading…
Reference in New Issue