From 7200a8638e4b51e7f50d446429122c5174d64282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fede=20=C3=81lvarez?= <78366796+fedealvarezcampos@users.noreply.github.com> Date: Thu, 30 Jun 2022 13:39:27 +0200 Subject: [PATCH] Work on CMS header, minor changes (#78) * Work on CMS header, minor changes * Fix deploy maybe * Fix animation mobile, fix caret * Fix header color, etc --- .../common/header/header.module.scss | 29 ++++ src/components/common/header/index.tsx | 155 +++++++++++------- src/components/layout/page.tsx | 23 +-- .../sections/community/events/index.tsx | 2 +- .../sections/contact/hero/hero.module.scss | 2 +- src/lib/cms/queries/header.js | 10 ++ src/pages/404.tsx | 13 +- src/pages/about.tsx | 13 +- src/pages/blog/[slug].tsx | 14 +- src/pages/blog/index.tsx | 10 +- src/pages/careers.tsx | 13 +- src/pages/community.tsx | 32 ++-- src/pages/contact.tsx | 23 ++- src/pages/index.tsx | 13 +- src/pages/partners.tsx | 13 +- src/pages/press.tsx | 13 +- src/pages/privacy-policy.tsx | 14 +- src/pages/products.tsx | 13 +- src/pages/terms-of-use.tsx | 9 +- 19 files changed, 279 insertions(+), 135 deletions(-) create mode 100644 src/lib/cms/queries/header.js diff --git a/src/components/common/header/header.module.scss b/src/components/common/header/header.module.scss index f489fbb..d22d6a4 100644 --- a/src/components/common/header/header.module.scss +++ b/src/components/common/header/header.module.scss @@ -41,12 +41,22 @@ align-items: center; justify-content: center; + span { + text-transform: none; + line-height: 1; + letter-spacing: tovw(-0.5px, 'default', -0.5px); + font-family: var(--font-tt-hoves); + font-size: tovw(16px, 'default', 14px); + color: var(--color-white); + } + a.active { font-weight: 600 !important; } .no_content { margin-right: tovw(21px, 'default', 20px); + padding: 0 tovw(3px, 'default', 1px); } .trigger { @@ -56,6 +66,7 @@ background-color: unset; text-transform: none; line-height: 1; + padding: 0 tovw(3px, 'default', 1px); &[data-state='open'] { .caret { @@ -142,6 +153,16 @@ } } + span { + opacity: 0.6; + letter-spacing: tovw(-1px, 'mobile'); + font-size: tovw(50px, 'mobile'); + + @media screen and (max-height: 750px) { + font-size: calc(var(--vh) * 5.2); + } + } + div:first-child { display: flex; align-content: center; @@ -281,6 +302,14 @@ background-color: rgb(255 255 255 / 0.8); } + .list > .item { + .trigger { + .caret { + filter: brightness(20%); + } + } + } + ul li a { color: var(--color-white); } diff --git a/src/components/common/header/index.tsx b/src/components/common/header/index.tsx index 54d85f0..7402858 100644 --- a/src/components/common/header/index.tsx +++ b/src/components/common/header/index.tsx @@ -15,13 +15,23 @@ import { useMeasure } from '~/hooks/use-measure' import { DURATION, gsap } from '~/lib/gsap' import { ConnectLinks } from '../footer/footer' -import { defaultHeaderLinks } from './header' import s from './header.module.scss' +interface Props { + data: { + navMenu: { + href: string + title: string + content: { href: string; title: string }[] + }[] + } +} + const HeaderMobile = React.forwardRef< HTMLDivElement, JSX.IntrinsicElements['div'] ->(({ className, ...props }, ref) => { + // @ts-ignore +>(({ className, data, ...props }, ref) => { const router = useRouter() const { theme, setTheme } = useTheme() @@ -43,47 +53,65 @@ const HeaderMobile = React.forwardRef<
- {defaultHeaderLinks.map((item, i) => ( - - {item.content ? ( - <> -
- - {item.title} - - - - -
- - {item.content.map((contentItem, i) => ( - - {contentItem.title} - - ))} - - - ) : ( - - {item.title} - - )} -
- ))} + { + // @ts-ignore + data?.navMenu.map((item, i) => ( + + {item.content.length >= 1 ? ( + <> +
+ {item.href ? ( + <> + {' '} + + {item.title} + + + + + + ) : ( + <> + {item.title} + + + + + )} +
+ + { + // @ts-ignore + item.content.map((contentItem, i) => ( + + {contentItem.title} + + )) + } + + + ) : ( + + {item.title} + + )} +
+ )) + }
@@ -112,7 +140,7 @@ const HeaderMobile = React.forwardRef< ) }) -export const Header = () => { +export const Header = ({ data }: Props) => { const [isOpen, setIsOpen] = React.useState(false) const headerMobileRef = React.useRef(null) const timelineRef = React.useRef() @@ -154,7 +182,7 @@ export const Header = () => { `.${s.item}` ) const socialItems = headerMobileRef.current.querySelectorAll('.social li') - const button = headerMobileRef.current.querySelector('button') + // const button = headerMobileRef.current.querySelector('button') const text = headerMobileRef.current.querySelector('p') timelineRef.current = gsap.timeline({ @@ -168,8 +196,7 @@ export const Header = () => { }, { xPercent: 0, duration: DURATION } ) - timelineRef.current.fadeIn([navigationItems, button, socialItems, text]), - '>-40%' + timelineRef.current.fadeIn([navigationItems, socialItems, text]), '>-40%' }, []) useIsomorphicLayoutEffect(() => { @@ -192,25 +219,29 @@ export const Header = () => { - {defaultHeaderLinks.map((item, i) => ( + {data?.navMenu.map((item, i) => ( - {item.content ? ( + {item?.content?.length >= 1 ? ( <> - - {item.title} - + {item.href ? ( + + {item.title} + + ) : ( + {item.title} + )} - {item.content.map((contentItem, i) => ( + {item?.content.map((contentItem, i) => ( { /> Menu - + {/* + // @ts-ignore */} +
) diff --git a/src/components/layout/page.tsx b/src/components/layout/page.tsx index 86cb4d9..cd050cb 100644 --- a/src/components/layout/page.tsx +++ b/src/components/layout/page.tsx @@ -10,18 +10,21 @@ type Props = { extras?: React.ReactNode smoothScroll?: boolean footerData?: any + headerData?: any } -const ContentMemo = React.memo(({ children, extras, footerData }: Props) => { - return ( - <> -
- {extras} -
{children}
-