|
| 1 | +import NextLink from "next/link" |
| 2 | +import { useConfig, useThemeConfig } from "nextra-theme-docs" |
| 3 | + |
| 4 | +import { GraphQLWordmarkLogo } from "@/icons" |
| 5 | +import { SocialIcons } from "@/app/conf/_components/social-icons" |
| 6 | +import { StripesDecoration } from "@/app/conf/_design-system/stripes-decoration" |
| 7 | +import blurBean from "@/app/conf/2025/components/footer/blur-bean.webp" |
| 8 | + |
| 9 | +import { renderComponent } from "../utils" |
| 10 | +import { Anchor } from "@/app/conf/_design-system/anchor" |
| 11 | +import type { ReactNode } from "react" |
| 12 | +import { ConferenceFooterBox } from "./conference-footer-box" |
| 13 | + |
| 14 | +interface FooterLink { |
| 15 | + title: ReactNode |
| 16 | + route: string |
| 17 | +} |
| 18 | + |
| 19 | +interface FooterSection { |
| 20 | + title?: ReactNode |
| 21 | + route?: string |
| 22 | + links: FooterLink[] |
| 23 | +} |
| 24 | + |
| 25 | +const FOOTER_SECTIONS_COUNT = 4 |
| 26 | +const MAX_LINKS_PER_SECTION = 5 |
| 27 | +const CONFERENCE_YEAR = 2025 |
| 28 | + |
| 29 | +export function Footer({ extraLinks }: { extraLinks: FooterLink[] }) { |
| 30 | + const { sections, hasConferenceBox } = useFooterSections(extraLinks) |
| 31 | + const themeConfig = useThemeConfig() |
| 32 | + |
| 33 | + return ( |
| 34 | + <footer className="relative !bg-neu-100 text-neu-900 dark:!bg-neu-0 max-md:px-0 max-md:pt-0"> |
| 35 | + <Stripes /> |
| 36 | + |
| 37 | + <div className="mx-auto max-w-[120rem] border-neu-400 dark:border-neu-100 3xl:border-x"> |
| 38 | + <div className="flex flex-wrap justify-between gap-4 p-4 max-md:w-full md:p-6 2xl:px-10"> |
| 39 | + <NextLink href="/" className="nextra-logo flex items-center"> |
| 40 | + <GraphQLWordmarkLogo className="h-6" title="GraphQL" /> |
| 41 | + </NextLink> |
| 42 | + </div> |
| 43 | + |
| 44 | + <div className="grid grid-cols-2 gap-px bg-neu-400 py-px dark:bg-neu-100 lg:grid-cols-5"> |
| 45 | + {sections.map((section, i) => ( |
| 46 | + <div |
| 47 | + className="typography-menu relative bg-neu-100 py-4 dark:bg-neu-0 lg:py-6 3xl:py-10" |
| 48 | + key={i} |
| 49 | + > |
| 50 | + {section.title && ( |
| 51 | + <h3 className="font-bold lg:mb-4 3xl:mb-10"> |
| 52 | + {section.route ? ( |
| 53 | + <Anchor |
| 54 | + className="gql-focus-visible block p-4 underline-offset-4 hover:underline md:px-6 2xl:px-10" |
| 55 | + href={section.route} |
| 56 | + > |
| 57 | + {section.title} |
| 58 | + </Anchor> |
| 59 | + ) : ( |
| 60 | + <span className="block p-4 3xl:px-10">{section.title}</span> |
| 61 | + )} |
| 62 | + </h3> |
| 63 | + )} |
| 64 | + {section.links.map(link => ( |
| 65 | + <Anchor |
| 66 | + key={link.route} |
| 67 | + href={link.route} |
| 68 | + className="gql-focus-visible block p-4 underline-offset-4 hover:underline md:px-6 2xl:px-10" |
| 69 | + > |
| 70 | + {link.title} |
| 71 | + </Anchor> |
| 72 | + ))} |
| 73 | + </div> |
| 74 | + ))} |
| 75 | + <div className="flex flex-col max-lg:contents"> |
| 76 | + {hasConferenceBox && ( |
| 77 | + <ConferenceFooterBox |
| 78 | + href={`/conf/${CONFERENCE_YEAR}`} |
| 79 | + className="z-[2] col-span-full flex-1 max-lg:row-start-1" |
| 80 | + /> |
| 81 | + )} |
| 82 | + <SocialIcons |
| 83 | + count={4} |
| 84 | + className="col-span-full gap-px text-pri-base *:flex *:flex-1 *:items-center *:justify-center *:bg-neu-100 *:dark:bg-neu-0 max-sm:*:aspect-square lg:*:aspect-square [&>a:focus]:text-current [&>a:focus]:ring-transparent [&>a:hover]:bg-neu-0/90 [&>a:hover]:text-current [&_svg]:!h-8" |
| 85 | + /> |
| 86 | + </div> |
| 87 | + </div> |
| 88 | + |
| 89 | + <div className="relative flex items-center justify-between gap-4 p-4 md:px-6 2xl:px-10"> |
| 90 | + {themeConfig.darkMode && ( |
| 91 | + // todo: new theme switch component |
| 92 | + <div className="typography-menu flex items-center *:rounded-none dark:*:text-neu-900"> |
| 93 | + {renderComponent(themeConfig.themeSwitch.component)} |
| 94 | + </div> |
| 95 | + )} |
| 96 | + <p className="typography-body-xs flex flex-col text-pretty max-md:gap-5"> |
| 97 | + {renderComponent(themeConfig.footer.content)} |
| 98 | + </p> |
| 99 | + </div> |
| 100 | + </div> |
| 101 | + </footer> |
| 102 | + ) |
| 103 | +} |
| 104 | + |
| 105 | +function Stripes() { |
| 106 | + return ( |
| 107 | + <div |
| 108 | + role="presentation" |
| 109 | + // prettier-ignore |
| 110 | + // false positive |
| 111 | + // eslint-disable-next-line tailwindcss/no-contradicting-classname |
| 112 | + className="pointer-events-none absolute inset-0 z-[1] |
| 113 | + [--start-1:rgba(255,204,239,.05)] |
| 114 | + [--end-1:hsl(var(--color-pri-base)/.8)] |
| 115 | + dark:[--start-1:hsl(var(--color-pri-darker))] |
| 116 | + dark:[--end-1:hsl(var(--color-pri-base)/.9)] |
| 117 | +
|
| 118 | + [--start-2:transparent] |
| 119 | + [--end-2:hsl(var(--color-pri-base)/.6)] |
| 120 | + dark:[--start-2:rgba(255,204,239,.1)] |
| 121 | + dark:[--end-2:hsl(var(--color-pri-base)/.8)] |
| 122 | +
|
| 123 | + mix-blend-darken |
| 124 | + dark:mix-blend-lighten |
| 125 | +
|
| 126 | + max-sm:![mask-size:300vw_200px] |
| 127 | + max-sm:![mask-position:center_calc(100%-100px)] |
| 128 | +
|
| 129 | + sm:max-lg:![mask-origin:bottom] |
| 130 | + sm:max-lg:![mask-size:250%_300px] |
| 131 | + sm:max-lg:![mask-position:center_calc(100%-30px)] |
| 132 | +
|
| 133 | + max-lg:rotate-180 |
| 134 | + " |
| 135 | + style={{ |
| 136 | + maskImage: `url(${blurBean.src})`, |
| 137 | + WebkitMaskImage: `url(${blurBean.src})`, |
| 138 | + maskPosition: "center 260px", |
| 139 | + WebkitMaskPosition: "center 260px", |
| 140 | + maskSize: "200% 100%", |
| 141 | + WebkitMaskSize: "200% 100%", |
| 142 | + maskRepeat: "no-repeat", |
| 143 | + WebkitMaskRepeat: "no-repeat", |
| 144 | + maskOrigin: "top", |
| 145 | + }} |
| 146 | + > |
| 147 | + <StripesDecoration |
| 148 | + evenClassName="bg-[linear-gradient(180deg,var(--start-1)_0%,var(--end-1)_200%)]" |
| 149 | + oddClassName="bg-[linear-gradient(180deg,var(--start-2)_0%,var(--end-2)_200%)]" |
| 150 | + /> |
| 151 | + </div> |
| 152 | + ) |
| 153 | +} |
| 154 | + |
| 155 | +function useFooterSections(extraLinks: FooterLink[]): { |
| 156 | + sections: FooterSection[] |
| 157 | + hasConferenceBox: boolean |
| 158 | +} { |
| 159 | + const { normalizePagesResult } = useConfig() |
| 160 | + |
| 161 | + const sections: FooterSection[] = [] |
| 162 | + const singleLinks: FooterLink[] = [] |
| 163 | + let hasConferenceBox = false |
| 164 | + |
| 165 | + for (const item of normalizePagesResult.topLevelNavbarItems) { |
| 166 | + if ( |
| 167 | + (item.type === "page" || item.type === "menu") && |
| 168 | + item.children?.length && |
| 169 | + sections.length < FOOTER_SECTIONS_COUNT - 1 |
| 170 | + ) { |
| 171 | + sections.push({ |
| 172 | + title: item.title, |
| 173 | + route: item.route, |
| 174 | + links: (item.children || []) |
| 175 | + .filter(child => child.route) |
| 176 | + .slice(0, MAX_LINKS_PER_SECTION) |
| 177 | + .map(child => ({ title: child.title, route: child.route })), |
| 178 | + }) |
| 179 | + } else if (singleLinks.length < MAX_LINKS_PER_SECTION) { |
| 180 | + if (item.route && item.route.startsWith("/conf/")) { |
| 181 | + hasConferenceBox = true |
| 182 | + } else { |
| 183 | + singleLinks.push({ title: item.title, route: item.route }) |
| 184 | + } |
| 185 | + } |
| 186 | + } |
| 187 | + |
| 188 | + singleLinks.push(...extraLinks) |
| 189 | + sections.push({ links: singleLinks }) |
| 190 | + |
| 191 | + return { sections, hasConferenceBox } |
| 192 | +} |
0 commit comments