Skip to content

Commit

Permalink
feat(nx-dev): update website header components (#21833)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcabanes authored Feb 15, 2024
1 parent 97e60f3 commit 27cf308
Show file tree
Hide file tree
Showing 9 changed files with 189 additions and 117 deletions.
9 changes: 4 additions & 5 deletions nx-dev/feature-search/src/lib/algolia-search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function AlgoliaSearch({
<link
rel="preconnect"
href="https://PCTGM1JTQL-dsn.algolia.net"
crossOrigin="true"
crossOrigin="anonymous"
/>
</Head>
{!tiny ? (
Expand All @@ -86,9 +86,8 @@ export function AlgoliaSearch({
className="flex w-full items-center rounded-md bg-white py-1.5 px-2 text-sm leading-4 ring-1 ring-slate-300 transition dark:bg-slate-700 dark:ring-slate-900"
>
<MagnifyingGlassIcon className="h-4 w-4 flex-none" />
<span className="mx-3 text-xs text-slate-300 dark:text-slate-400 md:text-sm lg:inline-flex">
Search{' '}
<span className="ml-2 hidden md:inline">Documentation ...</span>
<span className="mx-3 text-xs text-slate-300 dark:text-slate-400 md:text-sm inline-flex">
Search <span className="ml-1 hidden md:inline">the docs ...</span>
</span>
<span
style={{ opacity: browserDetected ? '1' : '0' }}
Expand Down Expand Up @@ -138,7 +137,7 @@ export function AlgoliaSearch({
distinct: true,
}}
initialQuery={initialQuery}
placeholder="Search documentation"
placeholder="Search the docs"
initialScrollY={window.scrollY}
onClose={handleClose}
indexName="nx-production"
Expand Down
1 change: 1 addition & 0 deletions nx-dev/ui-common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from './lib/champion-card';
export * from './lib/champion-perks';
export * from './lib/header';
export * from './lib/flip-card';
export * from './lib/nx-cloud-icon';
export * from './lib/footer';
export * from './lib/sidebar-container';
export * from './lib/sidebar';
Expand Down
74 changes: 60 additions & 14 deletions nx-dev/ui-common/src/lib/documentation-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ import { ThemeSwitcher } from '@nx/nx-dev/ui-theme';
import cx from 'classnames';
import Link from 'next/link';
import { useRouter } from 'next/router';
import { AnnouncementBanner } from './announcement-banner';
import { ButtonLink } from './button';
import { NxCloudIcon } from './nx-cloud-icon';

function Menu({ tabs }: { tabs: any[] }): JSX.Element {
return (
<div className="hidden sm:block">
<nav className="-mb-px flex space-x-8" aria-label="Tabs">
<nav
role="documentation-nav"
aria-label="Tabs"
className="-mb-px flex gap-6"
>
{tabs.map((tab) => (
<Link
key={tab.name}
Expand All @@ -23,7 +28,7 @@ function Menu({ tabs }: { tabs: any[] }): JSX.Element {
)}
aria-current={tab.current ? 'page' : undefined}
>
{tab.content ?? tab.name}
{tab.name}
</Link>
))}
</nav>
Expand Down Expand Up @@ -85,11 +90,6 @@ export function DocumentationHeader({
name: 'AI Chat',
href: '/ai-chat',
current: isAiChat,
content: (
<>
<span>AI Chat</span>
</>
),
},
];

Expand Down Expand Up @@ -166,7 +166,7 @@ export function DocumentationHeader({

return (
<div className="border-b border-slate-200 bg-slate-50 dark:border-slate-700 dark:bg-slate-800/60 print:hidden">
<div className="mx-auto flex w-full items-center sm:space-x-6 lg:py-4 lg:px-8">
<div className="mx-auto flex w-full items-center gap-6 lg:py-4 lg:px-8">
{/*MOBILE MENU*/}
<div className="flex w-full items-center lg:hidden">
<button
Expand Down Expand Up @@ -221,16 +221,62 @@ export function DocumentationHeader({
<AlgoliaSearch />
</div>
{/*NAVIGATION*/}
<div className="hidden flex-grow lg:flex">{/* SPACER */}</div>
<div className="hidden lg:flex">
<AnnouncementBanner />
<div className="hidden flex-shrink-0 lg:flex">
<nav
role="menu"
className="items-justified hidden justify-center space-x-2 text-sm lg:flex"
>
<h2 className="sr-only">Main navigation</h2>
<Link
href="/blog"
title="Blog"
className="hidden px-3 py-2 font-medium leading-tight hover:text-blue-500 dark:text-slate-200 dark:hover:text-sky-500 md:inline-flex"
>
Blog
</Link>
<Link
href="/community"
title="Nx Community: Join us!"
className="hidden px-3 py-2 font-medium leading-tight hover:text-blue-500 dark:text-slate-200 dark:hover:text-sky-500 md:inline-flex"
>
Community
</Link>
<Link
href="/launch-nx"
title="Launch Nx"
className="relative hidden px-3 py-2 font-medium leading-tight hover:text-blue-500 dark:text-slate-200 dark:hover:text-sky-500 md:inline-flex"
>
{/*<span className="absolute top-0 right-0 -mt-1 -mr-1 flex h-3 w-3">*/}
{/* <span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-blue-500 opacity-75 dark:bg-sky-500" />*/}
{/* <span className="relative inline-flex h-3 w-3 rounded-full bg-blue-500 dark:bg-sky-500" />*/}
{/*</span>*/}Launch Nx
</Link>
<a
href="https://nx.app/enterprise?utm_source=nx.dev&utm_medium=header-menu"
target="_blank"
title="Contact us"
className="hidden px-3 py-2 font-medium leading-tight hover:text-blue-500 dark:text-slate-200 dark:hover:text-sky-500 md:inline-flex"
>
Contact us
</a>
</nav>
</div>
<div className="hidden flex-grow lg:flex">{/* SPACER */}</div>
<div className="hidden flex-shrink-0 lg:flex">
<nav
role="accessory-nav"
className="items-justified hidden justify-center space-x-4 text-xs lg:flex"
role="menu"
className="items-justified hidden justify-center space-x-4 lg:flex"
>
<ThemeSwitcher />
<ButtonLink
href="https://nx.app/?utm_source=nx.dev&utm_medium=header-menu"
title="Go to app"
variant="secondary"
size="small"
>
<NxCloudIcon className="w-4 h-4" aria-hidden="true" />
<span>Go to app</span>
</ButtonLink>
</nav>
</div>
</div>
Expand Down
30 changes: 11 additions & 19 deletions nx-dev/ui-common/src/lib/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ export function Header(): JSX.Element {
href: '/launch-nx',
},
{
name: 'Nx Enterprise',
description: 'Need help?',
href: 'https://nx.app/enterprise?utm_source=nx.dev',
name: 'Contact us',
description: 'Give us a call!',
href: 'https://nx.app/enterprise?utm_source=nx.dev&utm_medium=header-menu',
},
];

Expand Down Expand Up @@ -173,15 +173,6 @@ export function Header(): JSX.Element {
</>
)}
</Popover>
<Link
href="https://nx.app/enterprise?utm_source=nx.dev"
title="Check Nx Enterprise"
target="_blank"
rel="noreferrer"
className="hidden px-3 py-2 font-medium leading-tight hover:text-blue-500 dark:text-slate-200 dark:hover:text-sky-500 md:inline-flex"
>
Enterprise
</Link>
<Link
href="/blog"
title="Blog"
Expand All @@ -196,13 +187,6 @@ export function Header(): JSX.Element {
>
Community
</Link>
<Link
href="/plugin-registry"
title="Check Nx available plugins"
className="hidden px-3 py-2 font-medium leading-tight hover:text-blue-500 dark:text-slate-200 dark:hover:text-sky-500 md:inline-flex"
>
Plugins registry
</Link>
<Link
href="/launch-nx"
title="Launch Nx"
Expand All @@ -213,6 +197,14 @@ export function Header(): JSX.Element {
{/* <span className="relative inline-flex h-3 w-3 rounded-full bg-blue-500 dark:bg-sky-500" />*/}
{/*</span>*/}Launch Nx
</Link>
<a
href="https://nx.app/enterprise?utm_source=nx.dev&utm_medium=header-menu"
target="_blank"
title="Contact us"
className="hidden px-3 py-2 font-medium leading-tight hover:text-blue-500 dark:text-slate-200 dark:hover:text-sky-500 md:inline-flex"
>
Contact us
</a>
</nav>
</div>
<div className="flex-shrink-0 text-sm">
Expand Down
17 changes: 17 additions & 0 deletions nx-dev/ui-common/src/lib/nx-cloud-icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { FC, SVGProps } from 'react';

export const NxCloudIcon: FC<SVGProps<SVGSVGElement>> = (props) => (
<svg
role="img"
xmlns="http://www.w3.org/2000/svg"
stroke="currentColor"
fill="transparent"
viewBox="0 0 24 24"
{...props}
>
<path
d="M22.167 7.167v-2.5a2.5 2.5 0 0 0-2.5-2.5h-15a2.5 2.5 0 0 0-2.5 2.5v15a2.5 2.5 0 0 0 2.5 2.5h2.5m15-15c-2.76 0-5 2.24-5 5s-2.24 5-5 5-5 2.24-5 5m15-15V19.59a2.577 2.577 0 0 1-2.576 2.576H7.167"
strokeWidth="2"
/>
</svg>
);
129 changes: 83 additions & 46 deletions nx-dev/ui-common/src/lib/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,35 +185,53 @@ export function SidebarMobile({
const isNx: boolean =
!isCI && !isAPI && !isPlugins && !isChangelog && !isAiChat;

const sections = [
{ name: 'Home', href: '/', current: false },
{ name: 'Nx', href: '/getting-started/intro', current: isNx },
{
name: 'CI',
href: '/ci/intro/ci-with-nx',
current: isCI,
},
{
name: 'Extending Nx',
href: '/extending-nx/intro/getting-started',
current: isPlugins,
},
{
name: 'API',
href: '/nx-api',
current: isAPI,
},
{
name: 'Changelog',
href: '/changelog',
current: isChangelog,
},
{
name: 'AI Chat',
href: '/ai-chat',
current: isAiChat,
},
];
const sections = {
general: [
{ name: 'Home', href: '/', current: false },
{ name: 'Blog', href: '/blog', current: false },
{ name: 'Community', href: '/community', current: false },
{ name: 'Launch Nx', href: '/launch-nx', current: false },
{
name: 'Contact',
href: 'https://nx.app/enterprise?utm_source=nx.dev&utm_medium=header-menu',
current: false,
},
{
name: 'Go to app',
href: 'https://nx.app/?utm_source=nx.dev&utm_medium=header-menu',
current: false,
},
],
documentation: [
{ name: 'Nx', href: '/getting-started/intro', current: isNx },
{
name: 'CI',
href: '/ci/intro/ci-with-nx',
current: isCI,
},
{
name: 'Extending Nx',
href: '/extending-nx/intro/getting-started',
current: isPlugins,
},
{
name: 'API',
href: '/nx-api',
current: isAPI,
},
{
name: 'Changelog',
href: '/changelog',
current: isChangelog,
},
{
name: 'AI Chat',
href: '/ai-chat',
current: isAiChat,
},
],
};

return (
<Transition.Root show={navIsOpen} as={Fragment}>
<Dialog as="div" className="relative z-40" onClose={() => void 0}>
Expand All @@ -229,25 +247,44 @@ export function SidebarMobile({
>
<Dialog.Panel className="relative flex w-full flex-col overflow-y-auto bg-white p-4 dark:bg-slate-900">
{/*SECTIONS*/}
<div className="mb-8 grid w-full shrink-0 grid-cols-3 items-center justify-between">
{sections.map((section) => (
<Link
key={section.name}
href={section.href}
className={cx(
section.current
? 'text-blue-600 dark:text-sky-500'
: 'hover:text-slate-900 dark:hover:text-sky-400',
'whitespace-nowrap p-4 text-center text-sm font-medium'
)}
aria-current={section.current ? 'page' : undefined}
>
{section.name}
</Link>
))}
<div className="divide-y divide-slate-200">
<div className="grid w-full shrink-0 grid-cols-3 items-center justify-between">
{sections.general.map((section) => (
<Link
key={section.name}
href={section.href}
className={cx(
section.current
? 'text-blue-600 dark:text-sky-500'
: 'hover:text-slate-900 dark:hover:text-sky-400',
'whitespace-nowrap p-4 text-center text-sm font-medium'
)}
aria-current={section.current ? 'page' : undefined}
>
{section.name}
</Link>
))}
</div>
<div className="grid w-full shrink-0 grid-cols-3 items-center justify-between">
{sections.documentation.map((section) => (
<Link
key={section.name}
href={section.href}
className={cx(
section.current
? 'text-blue-600 dark:text-sky-500'
: 'hover:text-slate-900 dark:hover:text-sky-400',
'whitespace-nowrap p-4 text-center text-sm font-medium'
)}
aria-current={section.current ? 'page' : undefined}
>
{section.name}
</Link>
))}
</div>
</div>
{/*SIDEBAR*/}
<div data-testid="mobile-navigation-wrapper ">
<div data-testid="mobile-navigation-wrapper" className="mt-8">
<nav
id="mobile-nav"
data-testid="mobile-navigation"
Expand Down
8 changes: 3 additions & 5 deletions nx-dev/ui-home/src/lib/extensible-and-integrated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,9 @@ export function ExtensibleAndIntegrated(): JSX.Element {
</div>
</Tab.List>
<Tab.Panels>
<AnimatePresence>
{tabs.map((tab) => (
<Tab.Panel key={'panel-' + tab.title}>{tab.panel}</Tab.Panel>
))}
</AnimatePresence>
{tabs.map((tab) => (
<Tab.Panel key={'panel-' + tab.title}>{tab.panel}</Tab.Panel>
))}
</Tab.Panels>
</Tab.Group>
</div>
Expand Down
Loading

0 comments on commit 27cf308

Please sign in to comment.