mirror of
https://github.com/vercel/flags.git
synced 2026-09-19 03:49:23 +08:00
97c8060917
* Sync docs template with @vercel/geistdocs 1.2.0 + 1.2.1 Pulls in template updates via `@vercel/geistdocs@1.2.1 update --sync`: - 1.2.0: new NavbarLogo (oss product switcher variant), geist theme tokens + icons, updated docs layout, MobileDocsBar, redesigned navbar and mobile menu - 1.2.1: CommandPrompt UI component, IconCheck / IconCopy fallback icons, supporting CSS tokens and @utility rules (material-small, text-label-13, text-label-14-mono, text-label-16-mono, --ds-shadow-border-small light/dark) Home page intentionally left untouched because flags-sdk uses a custom home/[code] routing structure. package.json left untouched to preserve workspace/catalog references and app-specific deps (flags, @vercel/toolbar, newer Next). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Cap footer max-w and use LogoFlagsSdk in navbar - Cap the footer inner row at max-w-[1448px] so it aligns with the navbar on very wide screens - Render the Flags SDK wordmark (LogoFlagsSdk) directly in the navbar via the oss NavbarLogo trigger; drop the duplicate entry from the product switcher dropdown Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Use bg-background-200 for docs container Matches the navbar background so docs pages (principles, frameworks, providers, etc.) no longer sit on a lighter surface than the header. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Use CommandPrompt humans/agents switcher in hero CTA Replaces the Get Started button + CopySnippet in the home hero with the CommandPrompt switcher. Triggers and surface are aligned to the left via `items-start` on the root so they line up with the hero heading instead of being centered. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Use full npm install command in hero CommandPrompt Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Default hero CommandPrompt to the agents tab Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Bump navbar Flags SDK logo to height 22 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Use MobileDocsBar for docs mobile navigation Disables the default Fumadocs TOC popover and renders the MobileDocsBar (sidebar trigger + TOC sheet) above the docs title, matching the geistdocs template. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Override fumadocs primary at :root so prose links render gray-1000 Matches the workflow docs tweak — broadens the fd-primary override from #nd-toc to :root so in-content links pick up the design-system foreground color instead of the default blue. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Use new --ds-shadow-menu on hero "Try the Flags SDK" card - Update --ds-shadow-menu to the 4-layer geist menu shadow - Apply it to the flags-toggle card via `shadow-(--ds-shadow-menu)`; drop the stock `shadow-md` and redundant border Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Use LogoFlagsSdk as the app Logo; add AI SDK to product switcher - Replace the inline triangle SVG + "Flags SDK" text in geistdocs.tsx with `<LogoFlagsSdk height={22} />`, so navbar & template consumers get the real wordmark - Revert navbar.tsx to import `Logo` from `@/geistdocs` (single source of truth) — the direct LogoFlagsSdk import is no longer needed - Add `LogoAiSdk` to OSS_PRODUCT_LINKS at the top of the list (`ai-sdk.dev`) - Give LogoAiSdk the same `color` prop pattern as the other SDK logos - Formatter cleanup in app/[lang]/layout.tsx Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Restore FrameworkSwitcher and theme the Next.js icon - Re-mount <FrameworkSwitcher /> at the top of the desktop sidebar and the mobile Sheet (lost during the 1.2.x template sync) - Rewrite the Next.js icon to mirror LogoIconNextSvg from @vercel/geistcn-assets: circle uses currentColor + text-gray-1000 so it auto-inverts per theme; gradient stops for the "N" use var(--ds-background-100) so the highlight stays readable in light and dark Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Docs: active nav state, geist shadow, restored framework icon + TOC offset - DesktopMenu: mark nav items active when pathname falls under the item's section (match on first three path segments, ignore locale prefix); add `data-[active]:text-gray-1000` to the selector - CodeBlock: restore the `#next` / `#svelte` title-suffix parser so framework icons render in code block headers again - FrameworkSwitcher: apply `--ds-shadow-menu` to the popover content - geistdocs.css: push `#nd-toc` over with `md:pl-8` Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
193 lines
6.6 KiB
TypeScript
193 lines
6.6 KiB
TypeScript
import * as React from "react"
|
|
import { NavigationMenu as NavigationMenuPrimitive } from "radix-ui"
|
|
import { cva } from "class-variance-authority"
|
|
import { IconChevronDownSmall } from "@/components/geistcn-fallbacks/geistcn-assets/icons/icon-chevron-down-small"
|
|
|
|
import { cn } from "@/lib/utils"
|
|
|
|
function isTouchDevice() {
|
|
return "ontouchstart" in window || navigator.maxTouchPoints > 0;
|
|
}
|
|
|
|
function isKeyboardClick(event: React.MouseEvent) {
|
|
return event.detail === 0;
|
|
}
|
|
|
|
function NavigationMenu({
|
|
className,
|
|
children,
|
|
viewport = true,
|
|
viewportClassName,
|
|
...props
|
|
}: React.ComponentProps<typeof NavigationMenuPrimitive.Root> & {
|
|
viewport?: boolean
|
|
viewportClassName?: string
|
|
}) {
|
|
return (
|
|
<NavigationMenuPrimitive.Root
|
|
data-slot="navigation-menu"
|
|
data-viewport={viewport}
|
|
className={cn(
|
|
"group/navigation-menu relative z-10 flex max-w-max flex-1 items-center justify-center",
|
|
className
|
|
)}
|
|
{...props}
|
|
>
|
|
{children}
|
|
{viewport && <NavigationMenuViewport wrapperClassName={viewportClassName} />}
|
|
</NavigationMenuPrimitive.Root>
|
|
)
|
|
}
|
|
|
|
function NavigationMenuList({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<typeof NavigationMenuPrimitive.List>) {
|
|
return (
|
|
<NavigationMenuPrimitive.List
|
|
data-slot="navigation-menu-list"
|
|
className={cn(
|
|
"group flex flex-1 list-none items-center justify-center gap-1",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function NavigationMenuItem({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<typeof NavigationMenuPrimitive.Item>) {
|
|
return (
|
|
<NavigationMenuPrimitive.Item
|
|
data-slot="navigation-menu-item"
|
|
className={cn("relative", className)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
const navigationMenuTriggerStyle = cva(
|
|
"group inline-flex relative px-3 gap-1 w-max items-center justify-center text-sm transition-colors text-gray-900 hover:text-gray-1000 focus:text-gray-1000 focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:text-gray-1000 data-[state=open]:text-gray-1000"
|
|
)
|
|
|
|
function NavigationMenuTrigger({
|
|
className,
|
|
children,
|
|
onClick,
|
|
...props
|
|
}: React.ComponentProps<typeof NavigationMenuPrimitive.Trigger>) {
|
|
return (
|
|
<NavigationMenuPrimitive.Trigger
|
|
data-slot="navigation-menu-trigger"
|
|
className={cn(navigationMenuTriggerStyle(), "group", className)}
|
|
// Prevent the trigger from closing the menu when clicked on non-touch
|
|
// devices. Touch and keyboard users retain default toggle behavior.
|
|
onClick={(event) => {
|
|
if (!isTouchDevice() && !isKeyboardClick(event)) {
|
|
event.preventDefault();
|
|
}
|
|
onClick?.(event);
|
|
}}
|
|
{...props}
|
|
>
|
|
{children}
|
|
<IconChevronDownSmall
|
|
className="relative top-px size-3.5 text-gray-900 transition-all duration-200 ease group-hover:text-gray-1000 group-data-[state=open]:rotate-180"
|
|
aria-hidden="true"
|
|
/>
|
|
<div className="absolute -mx-12 inset-x-0 bottom-0 z-50 hidden h-[18px] group-data-[state=open]:flex" />
|
|
</NavigationMenuPrimitive.Trigger>
|
|
)
|
|
}
|
|
|
|
function NavigationMenuContent({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<typeof NavigationMenuPrimitive.Content>) {
|
|
return (
|
|
<NavigationMenuPrimitive.Content
|
|
data-slot="navigation-menu-content"
|
|
className={cn(
|
|
"left-0 top-0 w-full data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out md:absolute md:w-auto",
|
|
"group-data-[viewport=false]/navigation-menu:bg-popover group-data-[viewport=false]/navigation-menu:text-popover-foreground group-data-[viewport=false]/navigation-menu:data-[state=open]:animate-in group-data-[viewport=false]/navigation-menu:data-[state=closed]:animate-out group-data-[viewport=false]/navigation-menu:data-[state=closed]:zoom-out-95 group-data-[viewport=false]/navigation-menu:data-[state=open]:zoom-in-95 group-data-[viewport=false]/navigation-menu:data-[state=open]:fade-in-0 group-data-[viewport=false]/navigation-menu:data-[state=closed]:fade-out-0 group-data-[viewport=false]/navigation-menu:top-full group-data-[viewport=false]/navigation-menu:mt-1.5 group-data-[viewport=false]/navigation-menu:overflow-hidden group-data-[viewport=false]/navigation-menu:rounded-lg group-data-[viewport=false]/navigation-menu:shadow group-data-[viewport=false]/navigation-menu:duration-200 **:data-[slot=navigation-menu-link]:focus:ring-0 **:data-[slot=navigation-menu-link]:focus:outline-none",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function NavigationMenuViewport({
|
|
className,
|
|
wrapperClassName,
|
|
...props
|
|
}: React.ComponentProps<typeof NavigationMenuPrimitive.Viewport> & {
|
|
wrapperClassName?: string
|
|
}) {
|
|
return (
|
|
<div
|
|
className={cn(
|
|
"absolute left-0 top-[70%] flex justify-center",
|
|
wrapperClassName
|
|
)}
|
|
>
|
|
<NavigationMenuPrimitive.Viewport
|
|
data-slot="navigation-menu-viewport"
|
|
className={cn(
|
|
"origin-top-center relative mt-3.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-lg bg-background-100 text-gray-950 [box-shadow:var(--ds-shadow-menu)] data-[state=closed]:animate-out data-[state=open]:animate-in data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)]",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function NavigationMenuLink({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<typeof NavigationMenuPrimitive.Link>) {
|
|
return (
|
|
<NavigationMenuPrimitive.Link
|
|
data-slot="navigation-menu-link"
|
|
className={cn(
|
|
"block w-full text-sm outline-none transition-colors",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function NavigationMenuIndicator({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<typeof NavigationMenuPrimitive.Indicator>) {
|
|
return (
|
|
<NavigationMenuPrimitive.Indicator
|
|
data-slot="navigation-menu-indicator"
|
|
className={cn(
|
|
"data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in top-[70%] z-[1] flex items-end justify-center overflow-hidden transition-all duration-200",
|
|
className
|
|
)}
|
|
{...props}
|
|
>
|
|
<div className="relative top-[6.5px] size-4 rotate-45 rounded-tl-sm border border-r-0 border-b-0 border-gray-200 bg-white" />
|
|
</NavigationMenuPrimitive.Indicator>
|
|
)
|
|
}
|
|
|
|
export {
|
|
NavigationMenu,
|
|
NavigationMenuList,
|
|
NavigationMenuItem,
|
|
NavigationMenuContent,
|
|
NavigationMenuTrigger,
|
|
NavigationMenuLink,
|
|
NavigationMenuIndicator,
|
|
NavigationMenuViewport,
|
|
navigationMenuTriggerStyle,
|
|
}
|