From 2dbda6ecff358ddf7197334c09fd0db1806b71c7 Mon Sep 17 00:00:00 2001 From: konfig-bot Date: Fri, 20 Oct 2023 18:13:33 -0700 Subject: [PATCH] improved menu on website --- .../components/HeaderSimple/HeaderSimple.tsx | 212 ++++++++++-------- konfigthis.com/src/components/OurProducts.tsx | 15 +- konfigthis.com/src/utils/scroll-into-view.ts | 13 ++ 3 files changed, 138 insertions(+), 102 deletions(-) create mode 100644 konfigthis.com/src/utils/scroll-into-view.ts diff --git a/konfigthis.com/src/components/HeaderSimple/HeaderSimple.tsx b/konfigthis.com/src/components/HeaderSimple/HeaderSimple.tsx index 18089873b..4a6ec3d94 100644 --- a/konfigthis.com/src/components/HeaderSimple/HeaderSimple.tsx +++ b/konfigthis.com/src/components/HeaderSimple/HeaderSimple.tsx @@ -1,108 +1,144 @@ import { - createStyles, - Container, - rem, Group, Button, - Menu, Burger, MediaQuery, + clsx, + NavLink, + Transition, + MantineTransition, } from "@mantine/core"; import logo from "../../../public/portal-logo-light.png"; import Image from "@/components/Image"; -import { IconCalendar, IconCalendarEvent } from "@tabler/icons-react"; -import { useState } from "react"; +import { IconCalendarEvent, IconExternalLink } from "@tabler/icons-react"; +import { useDisclosure } from "@mantine/hooks"; +import { scrollIntoView } from "@/utils/scroll-into-view"; -const useStyles = createStyles((theme) => ({ - header: { - display: "flex", - justifyContent: "space-between", - alignItems: "center", - height: "100%", +const scaleY: MantineTransition = { + in: { + // remove y translation + transform: "translateY(0)", + opacity: 1, + filter: "blur(0)", }, - - links: { - [theme.fn.smallerThan("xs")]: { - display: "none", - }, - }, - - burger: { - [theme.fn.largerThan("xs")]: { - display: "none", - }, + out: { + // add small Y translation + transform: "translateY(16px)", + opacity: 0, + filter: "blur(12px)", }, + transitionProperty: "transform, opacity, filter", +}; - link: { - display: "block", - lineHeight: 1, - padding: `${rem(8)} ${rem(12)}`, - borderRadius: theme.radius.sm, - textDecoration: "none", - color: - theme.colorScheme === "dark" - ? theme.colors.dark[0] - : theme.colors.gray[7], - fontSize: theme.fontSizes.sm, - fontWeight: 500, +export function HeaderSimple() { + const [opened, handlers] = useDisclosure(false); - "&:hover": { - backgroundColor: - theme.colorScheme === "dark" - ? theme.colors.dark[6] - : theme.colors.gray[0], - }, - }, + const close = () => { + handlers.close(); + document.body && document.body.classList.remove("overflow-hidden"); + }; - linkActive: { - "&, &:hover": { - backgroundColor: theme.fn.variant({ - variant: "light", - color: theme.primaryColor, - }).background, - color: theme.fn.variant({ variant: "light", color: theme.primaryColor }) - .color, - }, - }, -})); - -export function HeaderSimple() { - const { classes } = useStyles(); - const [opened, setOpened] = useState(false); + const open = () => { + handlers.open(); + document.body && document.body.classList.add("overflow-hidden"); + }; return (
- - Konfig Logo - + - - - - - - - - } - > - Book a Demo - - - - Documentation - - - Blog - - - + {(styles) => ( +
+ { + close(); + scrollIntoView("sdks"); + }} + /> + { + close(); + scrollIntoView("docs"); + }} + /> + { + close(); + scrollIntoView("demos"); + }} + /> + } + component="a" + /> + } + target="_blank" + href="/blog" + component="a" + /> + } + /> +
+ )} + + +
+ Konfig Logo + + { + if (opened) { + close(); + } else { + open(); + } + }} + opened={opened} + /> + + + {/* + + }> + Book a Demo + + + + Documentation + + + Blog + + */}
@@ -133,7 +169,7 @@ export function HeaderSimple() {
- +
); } diff --git a/konfigthis.com/src/components/OurProducts.tsx b/konfigthis.com/src/components/OurProducts.tsx index 4a301f9cf..348daea50 100644 --- a/konfigthis.com/src/components/OurProducts.tsx +++ b/konfigthis.com/src/components/OurProducts.tsx @@ -1,3 +1,4 @@ +import { scrollIntoView } from "@/utils/scroll-into-view"; import { useGraphicStyles } from "@/utils/use-graphic-styles"; import { UnstyledButton, clsx } from "@mantine/core"; import { @@ -87,17 +88,3 @@ function Product({ ); } - -/** - * Finds the element with the given id and scrolls it into view. - * @param id - */ -function scrollIntoView(id: string) { - const element = document.getElementById(id); - - if (element) { - // set URL to include hash - window.history.pushState({}, "", `#${id}`); - element.scrollIntoView({ behavior: "smooth", block: "start" }); - } -} diff --git a/konfigthis.com/src/utils/scroll-into-view.ts b/konfigthis.com/src/utils/scroll-into-view.ts new file mode 100644 index 000000000..8bb7d6855 --- /dev/null +++ b/konfigthis.com/src/utils/scroll-into-view.ts @@ -0,0 +1,13 @@ +/** + * Finds the element with the given id and scrolls it into view. + * @param id + */ +export function scrollIntoView(id: string) { + const element = document.getElementById(id); + + if (element) { + // set URL to include hash + window.history.pushState({}, "", `#${id}`); + element.scrollIntoView({ behavior: "smooth", block: "start" }); + } +}