diff --git a/apps/blueprints/src/components/Panel.tsx b/apps/blueprints/src/components/Panel.tsx index 84b2af6..4f7e919 100644 --- a/apps/blueprints/src/components/Panel.tsx +++ b/apps/blueprints/src/components/Panel.tsx @@ -23,16 +23,16 @@ const StyledPanel = styled(Box)` display: flex; align-items: center; } +`; - .panel-content { - color: white; - height: 100%; - padding: 12px; - background: #414040; - box-shadow: inset 0 0 3px 0 #000, 0 -2px 2px -1px #000, -2px 0 2px -2px #28221f, - -2px 0 2px -2px #28221f, 2px 0 2px -2px #28221f, 2px 0 2px -2px #28221f, - 0 3px 3px -3px #8f8c8b, 0 2px 2px -2px #8f8c8b, 0 1px 1px -1px #8f8c8b; - } +const StyledPanelContent = styled.div` + color: white; + height: 100%; + padding: 12px; + background: #414040; + box-shadow: inset 0 0 3px 0 #000, 0 -2px 2px -1px #000, -2px 0 2px -2px #28221f, + -2px 0 2px -2px #28221f, 2px 0 2px -2px #28221f, 2px 0 2px -2px #28221f, 0 3px 3px -3px #8f8c8b, + 0 2px 2px -2px #8f8c8b, 0 1px 1px -1px #8f8c8b; `; interface PanelProps extends Omit { @@ -43,7 +43,7 @@ interface PanelProps extends Omit { export const Panel: React.FC = ({ title, bottom, children, className, ...props }) => ( {title &&

{title}

} -
{children}
+ {children} {bottom &&
{bottom}
}
); diff --git a/apps/blueprints/src/components/blueprint/Blueprint.tsx b/apps/blueprints/src/components/blueprint/Blueprint.tsx index 2524621..6b44921 100644 --- a/apps/blueprints/src/components/blueprint/Blueprint.tsx +++ b/apps/blueprints/src/components/blueprint/Blueprint.tsx @@ -151,12 +151,7 @@ export const BlueprintSubPage: React.FC = ({ - Components for{" "} - {data?.blueprint?.label ? : "blueprint"} - - } + title={Components} > {data && } diff --git a/apps/blueprints/src/components/blueprint/BlueprintBook.tsx b/apps/blueprints/src/components/blueprint/BlueprintBook.tsx index 6c778d6..82749ca 100644 --- a/apps/blueprints/src/components/blueprint/BlueprintBook.tsx +++ b/apps/blueprints/src/components/blueprint/BlueprintBook.tsx @@ -223,16 +223,7 @@ export const BlueprintBookSubPage: React.FC = ({ - Components for{" "} - {selectedData?.blueprint?.label ? ( - - ) : ( - "blueprint" - )} - - } + title={Components} > {selectedData && } @@ -241,7 +232,15 @@ export const BlueprintBookSubPage: React.FC = ({ + {`data for ${selected.type.replace( + "_", + " " + )}`} + {selectedData?.blueprint?.label && } + + } > {selectedBlueprintString && ( = ({ blueprint_page }) => { + const router = useRouter(); + const routerQueryToHref = useRouterQueryToHref(); + return ( {blueprint_page.tags.length ? ( blueprint_page.tags.map((tag) => ( - + router.push(routerQueryToHref({ tags: [tag] }, true))} + > {TAGS_BY_KEY[tag].category}: {TAGS_BY_KEY[tag].label} )) diff --git a/apps/blueprints/src/hooks/query.hook.ts b/apps/blueprints/src/hooks/query.hook.ts index 279053e..acc3f41 100644 --- a/apps/blueprints/src/hooks/query.hook.ts +++ b/apps/blueprints/src/hooks/query.hook.ts @@ -1,20 +1,13 @@ import { useRouter } from "next/router"; import { useCallback } from "react"; +import { stringifyQuery } from "../utils/query.utils"; export const useRouterQueryToHref = () => { const router = useRouter(); return useCallback( - (override: Record) => { - const query = { ...router.query, ...override }; - const keys = Object.keys(query).filter((key) => query[key] !== null); - const href = keys.length - ? "/?" + - Object.keys(query) - .filter((key) => query[key] !== null) - .map((key) => `${key}=${query[key]}`) - .join("&") - : "/"; - return href; + (override: Record, overrideAll = false) => { + const query = overrideAll ? override : { ...router.query, ...override }; + return stringifyQuery(query); }, [router] ); diff --git a/apps/blueprints/src/utils/query.utils.ts b/apps/blueprints/src/utils/query.utils.ts index 2be2c1b..346b370 100644 --- a/apps/blueprints/src/utils/query.utils.ts +++ b/apps/blueprints/src/utils/query.utils.ts @@ -7,3 +7,15 @@ export const queryValueAsArray = (value: string | string[] | undefined) => { } return []; }; + +export const stringifyQuery = (query: Record) => { + const keys = Object.keys(query).filter((key) => query[key] !== null); + const href = keys.length + ? "/?" + + Object.keys(query) + .filter((key) => query[key] !== null) + .map((key) => `${key}=${query[key]}`) + .join("&") + : "/"; + return href; +};