From 1deeb59adbdb8b8a2c21424f716d7789dd8e35dd Mon Sep 17 00:00:00 2001 From: Claudio Wunder Date: Thu, 2 Nov 2023 17:49:51 +0100 Subject: [PATCH] meta: fixed navitems --- components/Sections/Footer/index.module.css | 49 ++++++++++++++++ components/Sections/Footer/index.stories.tsx | 10 ++++ components/Sections/Footer/index.tsx | 58 +++++++++++++++++++ components/Sections/NavItem/index.module.css | 52 +++++++++++++++++ components/Sections/NavItem/index.stories.tsx | 37 ++++++++++++ components/Sections/NavItem/index.tsx | 41 +++++++++++++ 6 files changed, 247 insertions(+) create mode 100644 components/Sections/Footer/index.module.css create mode 100644 components/Sections/Footer/index.stories.tsx create mode 100644 components/Sections/Footer/index.tsx create mode 100644 components/Sections/NavItem/index.module.css create mode 100644 components/Sections/NavItem/index.stories.tsx create mode 100644 components/Sections/NavItem/index.tsx diff --git a/components/Sections/Footer/index.module.css b/components/Sections/Footer/index.module.css new file mode 100644 index 0000000000000..b0cd6da94e0de --- /dev/null +++ b/components/Sections/Footer/index.module.css @@ -0,0 +1,49 @@ +.footer { + @apply flex + flex-col + items-center + gap-6 + px-8 + py-4 + md:flex-row + md:justify-between + md:py-5; + + .sectionPrimary { + @apply flex + flex-wrap + content-start + items-center + justify-center + gap-1 + self-stretch; + + a { + @apply whitespace-nowrap; + } + } + + .sectionSecondary { + @apply flex + flex-col + items-center + gap-1 + md:flex-row; + + .social { + @apply flex + items-center + gap-1; + } + } + + .darkImage { + @apply hidden + dark:block; + } + + .lightImage { + @apply block + dark:hidden; + } +} diff --git a/components/Sections/Footer/index.stories.tsx b/components/Sections/Footer/index.stories.tsx new file mode 100644 index 0000000000000..44dccdfd67a46 --- /dev/null +++ b/components/Sections/Footer/index.stories.tsx @@ -0,0 +1,10 @@ +import type { Meta as MetaObj, StoryObj } from '@storybook/react'; + +import Footer from './index'; + +type Story = StoryObj; +type Meta = MetaObj; + +export const Default: Story = {}; + +export default { component: Footer } as Meta; diff --git a/components/Sections/Footer/index.tsx b/components/Sections/Footer/index.tsx new file mode 100644 index 0000000000000..fca82b9297c53 --- /dev/null +++ b/components/Sections/Footer/index.tsx @@ -0,0 +1,58 @@ +import classNames from 'classnames'; +import Image from 'next/image'; +import type { FC } from 'react'; +import { FormattedMessage } from 'react-intl'; + +import NavItem from '@/components/Sections/NavItem'; +import { useSiteConfig } from '@/hooks/useSiteConfig'; + +import styles from './index.module.css'; + +const Footer: FC = () => { + const { footerLinks, socialLinks } = useSiteConfig(); + + const openJSlink = footerLinks.at(-1)!; + + return ( +
+
+ {footerLinks.slice(0, -1).map(item => ( + + + + ))} +
+
+ + © + +
+ {socialLinks.map(link => { + const navClass = classNames({ + [styles.darkImage]: link.kind === 'dark', + [styles.lightImage]: link.kind === 'light', + }); + + return ( + + {link.alt + + ); + })} +
+
+
+ ); +}; + +export default Footer; diff --git a/components/Sections/NavItem/index.module.css b/components/Sections/NavItem/index.module.css new file mode 100644 index 0000000000000..3a7912bdf08d1 --- /dev/null +++ b/components/Sections/NavItem/index.module.css @@ -0,0 +1,52 @@ +.navItem { + @apply inline-flex + items-center + gap-2 + rounded + px-3 + py-2; + + .label { + @apply text-sm + font-medium + leading-5; + } + + .icon { + @apply h-3 + w-3 + text-neutral-500 + dark:text-neutral-200; + } + + &.nav { + .label { + @apply text-neutral-900 + dark:text-white; + } + + &.active { + @apply bg-green-600; + + .label { + @apply text-white; + } + + .icon { + @apply text-white + opacity-50; + } + } + } + + &.footer { + .label { + @apply text-neutral-800 + dark:text-white; + } + + &:hover { + @apply bg-neutral-100 dark:bg-neutral-900; + } + } +} diff --git a/components/Sections/NavItem/index.stories.tsx b/components/Sections/NavItem/index.stories.tsx new file mode 100644 index 0000000000000..3d1a94ff05b01 --- /dev/null +++ b/components/Sections/NavItem/index.stories.tsx @@ -0,0 +1,37 @@ +import type { Meta as MetaObj, StoryObj } from '@storybook/react'; + +import NavItem from './index'; + +type Story = StoryObj; +type Meta = MetaObj; + +export const Default: Story = { + args: { + href: '/learn', + children: 'Learn', + }, +}; + +export const WithExternalLink: Story = { + args: { + href: 'https://nodejs.org/en', + children: 'Learn', + }, +}; + +export const WithChildren: Story = { + args: { + href: 'https://nodejs.org/en', + children: Learn, + }, +}; + +export const FooterItem: Story = { + args: { + href: '/about', + children: 'Trademark Policy', + type: 'footer', + }, +}; + +export default { component: NavItem } as Meta; diff --git a/components/Sections/NavItem/index.tsx b/components/Sections/NavItem/index.tsx new file mode 100644 index 0000000000000..df4d03059b24e --- /dev/null +++ b/components/Sections/NavItem/index.tsx @@ -0,0 +1,41 @@ +import { ArrowUpRightIcon } from '@heroicons/react/24/solid'; +import classNames from 'classnames'; +import type { FC, PropsWithChildren } from 'react'; +import { useMemo } from 'react'; + +import ActiveLocalizedLink from '@/components/Common/ActiveLocalizedLink'; + +import styles from './index.module.css'; + +type NavItemType = 'nav' | 'footer'; + +type NavItemProps = { + href: string; + type?: NavItemType; + className?: string; +}; + +const NavItem: FC> = ({ + href = '', + type = 'nav', + children, + className, +}) => { + const showIcon = useMemo( + () => type === 'nav' && !href.toString().startsWith('/'), + [href, type] + ); + + return ( + + {children} + {showIcon && } + + ); +}; + +export default NavItem;