Moved things around as Content is now separate from library
This commit is contained in:
parent
044dd5b265
commit
3ce7cd487c
|
@ -5,7 +5,7 @@ import { useSwipeable } from "react-swipeable";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import Button from "components/Button";
|
import Button from "components/Button";
|
||||||
import { prettyLanguage } from "queries/helpers";
|
import { prettyLanguage } from "queries/helpers";
|
||||||
import { useMediaMobile } from "hooks/useMediaQuery";
|
import { useMediaCoarse, useMediaMobile } from "hooks/useMediaQuery";
|
||||||
|
|
||||||
import { useSelector, useDispatch } from "react-redux";
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
import {
|
import {
|
||||||
|
@ -28,6 +28,9 @@ type AppLayoutProps = {
|
||||||
export default function AppLayout(props: AppLayoutProps): JSX.Element {
|
export default function AppLayout(props: AppLayoutProps): JSX.Element {
|
||||||
const titlePrefix = "Accord’s Library";
|
const titlePrefix = "Accord’s Library";
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
const isMobile = useMediaMobile();
|
||||||
|
const isCoarse = useMediaCoarse();
|
||||||
|
|
||||||
const languagePanelOpen = useSelector(
|
const languagePanelOpen = useSelector(
|
||||||
(state: RootState) => state.appLayout.languagePanelOpen
|
(state: RootState) => state.appLayout.languagePanelOpen
|
||||||
|
@ -41,10 +44,7 @@ export default function AppLayout(props: AppLayoutProps): JSX.Element {
|
||||||
const subPanelOpen = useSelector(
|
const subPanelOpen = useSelector(
|
||||||
(state: RootState) => state.appLayout.subPanelOpen
|
(state: RootState) => state.appLayout.subPanelOpen
|
||||||
);
|
);
|
||||||
|
|
||||||
const dispatch = useDispatch();
|
|
||||||
|
|
||||||
const isMobile = useMediaMobile();
|
|
||||||
const sensibilitySwipe = 1.1;
|
const sensibilitySwipe = 1.1;
|
||||||
|
|
||||||
const handlers = useSwipeable({
|
const handlers = useSwipeable({
|
||||||
|
@ -225,7 +225,7 @@ export default function AppLayout(props: AppLayoutProps): JSX.Element {
|
||||||
effect="solid"
|
effect="solid"
|
||||||
delayShow={300}
|
delayShow={300}
|
||||||
delayHide={100}
|
delayHide={100}
|
||||||
disable={!mainPanelReduced || isMobile}
|
disable={!mainPanelReduced || isMobile || isCoarse}
|
||||||
className="drop-shadow-dark-xl !opacity-100 !bg-light !rounded-lg after:!border-r-light text-left"
|
className="drop-shadow-dark-xl !opacity-100 !bg-light !rounded-lg after:!border-r-light text-left"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -28,6 +28,7 @@ export default function NavOption(props: NavOptionProps): JSX.Element {
|
||||||
<div
|
<div
|
||||||
onClick={props.onClick}
|
onClick={props.onClick}
|
||||||
data-html
|
data-html
|
||||||
|
data-multiline
|
||||||
data-tip={`
|
data-tip={`
|
||||||
<div class="px-4 py-3">
|
<div class="px-4 py-3">
|
||||||
<h3 class="text-2xl">${props.title}</h3>
|
<h3 class="text-2xl">${props.title}</h3>
|
||||||
|
@ -39,7 +40,6 @@ export default function NavOption(props: NavOptionProps): JSX.Element {
|
||||||
</div>
|
</div>
|
||||||
`}
|
`}
|
||||||
data-for={props.tooltipId}
|
data-for={props.tooltipId}
|
||||||
data-multiline
|
|
||||||
className={`grid grid-flow-col grid-cols-[auto] auto-cols-fr justify-center ${
|
className={`grid grid-flow-col grid-cols-[auto] auto-cols-fr justify-center ${
|
||||||
props.icon ? "text-left" : "text-center"
|
props.icon ? "text-left" : "text-center"
|
||||||
} ${divCommon}`}
|
} ${divCommon}`}
|
||||||
|
|
|
@ -91,6 +91,16 @@ export default function MainPanel(props: MainPanelProps): JSX.Element {
|
||||||
onClick={() => dispatch(setMainPanelOpen(false))}
|
onClick={() => dispatch(setMainPanelOpen(false))}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<NavOption
|
||||||
|
url="/contents"
|
||||||
|
icon="workspaces"
|
||||||
|
title="Contents"
|
||||||
|
subtitle="Explore all content and filter by type or category"
|
||||||
|
tooltipId="MainPanelTooltip"
|
||||||
|
reduced={mainPanelReduced && isDesktop}
|
||||||
|
onClick={() => dispatch(setMainPanelOpen(false))}
|
||||||
|
/>
|
||||||
|
|
||||||
<NavOption
|
<NavOption
|
||||||
url="/wiki"
|
url="/wiki"
|
||||||
icon="travel_explore"
|
icon="travel_explore"
|
||||||
|
|
|
@ -45,3 +45,10 @@ export function useMediaDesktop() {
|
||||||
return useMediaQuery("(min-width: 60rem)");
|
return useMediaQuery("(min-width: 60rem)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useMediaCoarse() {
|
||||||
|
return useMediaQuery("(pointer: coarse)");
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useMediaFine() {
|
||||||
|
return useMediaQuery("(pointer: fine)");
|
||||||
|
}
|
||||||
|
|
|
@ -1,12 +1,24 @@
|
||||||
import { GetStaticProps } from "next";
|
import { GetStaticProps } from "next";
|
||||||
import SubPanel from "components/Panels/SubPanel";
|
import SubPanel from "components/Panels/SubPanel";
|
||||||
import { GetWebsiteInterfaceQuery } from "graphql/operations-types";
|
import ContentPanel, {
|
||||||
import { getWebsiteInterface } from "graphql/operations";
|
ContentPanelWidthSizes,
|
||||||
|
} from "components/Panels/ContentPanel";
|
||||||
|
import {
|
||||||
|
GetLibraryItemsPreviewQuery,
|
||||||
|
GetWebsiteInterfaceQuery,
|
||||||
|
} from "graphql/operations-types";
|
||||||
|
import {
|
||||||
|
getLibraryItemsPreview,
|
||||||
|
getWebsiteInterface,
|
||||||
|
} from "graphql/operations";
|
||||||
import PanelHeader from "components/PanelComponents/PanelHeader";
|
import PanelHeader from "components/PanelComponents/PanelHeader";
|
||||||
import AppLayout from "components/AppLayout";
|
import AppLayout from "components/AppLayout";
|
||||||
import NavOption from "components/PanelComponents/NavOption";
|
import ReturnButton from "components/PanelComponents/ReturnButton";
|
||||||
|
import HorizontalLine from "components/HorizontalLine";
|
||||||
|
import LibraryItemsPreview from "components/Library/LibraryItemsPreview";
|
||||||
|
|
||||||
type LibraryProps = {
|
type LibraryProps = {
|
||||||
|
libraryItems: GetLibraryItemsPreviewQuery;
|
||||||
langui: GetWebsiteInterfaceQuery;
|
langui: GetWebsiteInterfaceQuery;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,31 +26,34 @@ export default function Library(props: LibraryProps): JSX.Element {
|
||||||
const langui = props.langui.websiteInterfaces.data[0].attributes;
|
const langui = props.langui.websiteInterfaces.data[0].attributes;
|
||||||
const subPanel = (
|
const subPanel = (
|
||||||
<SubPanel>
|
<SubPanel>
|
||||||
|
<ReturnButton
|
||||||
|
href="/library"
|
||||||
|
title={langui.main_library}
|
||||||
|
langui={langui}
|
||||||
|
/>
|
||||||
|
<HorizontalLine />
|
||||||
<PanelHeader
|
<PanelHeader
|
||||||
icon="library_books"
|
icon="library_books"
|
||||||
title={langui.main_library}
|
|
||||||
description={langui.library_description}
|
|
||||||
/>
|
|
||||||
<NavOption
|
|
||||||
url="/library/items"
|
|
||||||
title={langui.library_items}
|
title={langui.library_items}
|
||||||
subtitle={langui.library_items_description}
|
description={langui.library_items_description}
|
||||||
border
|
|
||||||
/>
|
|
||||||
<NavOption
|
|
||||||
url="/library/content"
|
|
||||||
title={langui.library_content}
|
|
||||||
subtitle={langui.library_content_description}
|
|
||||||
border
|
|
||||||
/>
|
/>
|
||||||
</SubPanel>
|
</SubPanel>
|
||||||
);
|
);
|
||||||
|
const contentPanel = (
|
||||||
|
<ContentPanel width={ContentPanelWidthSizes.large}>
|
||||||
|
<div className="grid gap-8 items-end mobile:grid-cols-2 desktop:grid-cols-[repeat(auto-fill,_minmax(13rem,1fr))]">
|
||||||
|
{props.libraryItems.libraryItems.data.map((item) => (
|
||||||
|
<LibraryItemsPreview key={item.id} item={item.attributes} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</ContentPanel>
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<AppLayout
|
<AppLayout
|
||||||
title={langui.main_library}
|
title={langui.library_items}
|
||||||
langui={langui}
|
langui={langui}
|
||||||
subPanel={subPanel}
|
subPanel={subPanel}
|
||||||
|
contentPanel={contentPanel}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -46,6 +61,9 @@ export default function Library(props: LibraryProps): JSX.Element {
|
||||||
export const getStaticProps: GetStaticProps = async (context) => {
|
export const getStaticProps: GetStaticProps = async (context) => {
|
||||||
if (context.locale) {
|
if (context.locale) {
|
||||||
const props: LibraryProps = {
|
const props: LibraryProps = {
|
||||||
|
libraryItems: await getLibraryItemsPreview({
|
||||||
|
language_code: context.locale,
|
||||||
|
}),
|
||||||
langui: await getWebsiteInterface({
|
langui: await getWebsiteInterface({
|
||||||
language_code: context.locale,
|
language_code: context.locale,
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -1,77 +0,0 @@
|
||||||
import { GetStaticProps } from "next";
|
|
||||||
import SubPanel from "components/Panels/SubPanel";
|
|
||||||
import ContentPanel, {
|
|
||||||
ContentPanelWidthSizes,
|
|
||||||
} from "components/Panels/ContentPanel";
|
|
||||||
import {
|
|
||||||
GetLibraryItemsPreviewQuery,
|
|
||||||
GetWebsiteInterfaceQuery,
|
|
||||||
} from "graphql/operations-types";
|
|
||||||
import {
|
|
||||||
getLibraryItemsPreview,
|
|
||||||
getWebsiteInterface,
|
|
||||||
} from "graphql/operations";
|
|
||||||
import PanelHeader from "components/PanelComponents/PanelHeader";
|
|
||||||
import AppLayout from "components/AppLayout";
|
|
||||||
import ReturnButton from "components/PanelComponents/ReturnButton";
|
|
||||||
import HorizontalLine from "components/HorizontalLine";
|
|
||||||
import LibraryItemsPreview from "components/Library/LibraryItemsPreview";
|
|
||||||
|
|
||||||
type LibraryProps = {
|
|
||||||
libraryItems: GetLibraryItemsPreviewQuery;
|
|
||||||
langui: GetWebsiteInterfaceQuery;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function Library(props: LibraryProps): JSX.Element {
|
|
||||||
const langui = props.langui.websiteInterfaces.data[0].attributes;
|
|
||||||
const subPanel = (
|
|
||||||
<SubPanel>
|
|
||||||
<ReturnButton
|
|
||||||
href="/library"
|
|
||||||
title={langui.main_library}
|
|
||||||
langui={langui}
|
|
||||||
/>
|
|
||||||
<HorizontalLine />
|
|
||||||
<PanelHeader
|
|
||||||
icon="library_books"
|
|
||||||
title={langui.library_items}
|
|
||||||
description={langui.library_items_description}
|
|
||||||
/>
|
|
||||||
</SubPanel>
|
|
||||||
);
|
|
||||||
const contentPanel = (
|
|
||||||
<ContentPanel width={ContentPanelWidthSizes.large}>
|
|
||||||
<div className="grid gap-8 items-end mobile:grid-cols-2 desktop:grid-cols-[repeat(auto-fill,_minmax(13rem,1fr))]">
|
|
||||||
{props.libraryItems.libraryItems.data.map((item) => (
|
|
||||||
<LibraryItemsPreview key={item.id} item={item.attributes} />
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</ContentPanel>
|
|
||||||
);
|
|
||||||
return (
|
|
||||||
<AppLayout
|
|
||||||
title={langui.library_items}
|
|
||||||
langui={langui}
|
|
||||||
subPanel={subPanel}
|
|
||||||
contentPanel={contentPanel}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getStaticProps: GetStaticProps = async (context) => {
|
|
||||||
if (context.locale) {
|
|
||||||
const props: LibraryProps = {
|
|
||||||
libraryItems: await getLibraryItemsPreview({
|
|
||||||
language_code: context.locale,
|
|
||||||
}),
|
|
||||||
langui: await getWebsiteInterface({
|
|
||||||
language_code: context.locale,
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
return {
|
|
||||||
props: props,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return { props: {} };
|
|
||||||
}
|
|
||||||
};
|
|
Loading…
Reference in New Issue