Skip to content

Commit 13df2c1

Browse files
authored
Configurable developer menu (#1797)
1 parent 34b633a commit 13df2c1

File tree

3 files changed

+58
-28
lines changed

3 files changed

+58
-28
lines changed

.changeset/tender-donuts-jam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@theguild/components": patch
3+
---
4+
5+
Expose `developerMenu` prop from `HiveNavigation`.

packages/components/src/components/hive-navigation/hive-navigation.stories.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Meta, StoryContext, StoryObj } from '@storybook/react';
33
import { hiveThemeDecorator } from '../../../../../.storybook/hive-theme-decorator';
44
import { PRODUCTS } from '../../products';
55
import { Anchor } from '../anchor';
6-
import { CodegenIcon } from '../icons';
6+
import { CodegenIcon, GitHubIcon, PaperIcon, PencilIcon } from '../icons';
77
import { GraphQLConfCard } from './graphql-conf-card';
88
import {
99
CompanyMenu,
@@ -115,7 +115,7 @@ export const Developer: StoryObj = {
115115
render() {
116116
return (
117117
<NavigationMenu>
118-
<DeveloperMenu isHive={false} />
118+
<DeveloperMenu isHive={false} developerMenu={undefined} />
119119
</NavigationMenu>
120120
);
121121
},
@@ -158,6 +158,23 @@ export const CodegenNavmenu: StoryObj<HiveNavigationProps> = {
158158
children: 'Plugins',
159159
},
160160
],
161+
developerMenu: [
162+
{
163+
href: '/docs',
164+
icon: PaperIcon,
165+
children: 'Documentation',
166+
},
167+
{
168+
href: 'https://the-guild.dev/blog',
169+
icon: PencilIcon,
170+
children: 'Blog',
171+
},
172+
{
173+
href: 'https://github.com/dotansimha/graphql-code-generator',
174+
icon: GitHubIcon,
175+
children: 'GitHub',
176+
},
177+
],
161178
productName: PRODUCTS.CODEGEN.name,
162179
logo: (
163180
<Anchor href="/" className="hive-focus -m-2 flex items-center gap-3 rounded-md p-2">

packages/components/src/components/hive-navigation/index.tsx

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export interface HiveNavigationProps {
5050
productName: string;
5151
logo?: ReactNode;
5252
navLinks?: { href: string; children: ReactNode }[];
53+
developerMenu?: { href: string; icon: React.FC<{ className?: string }>; children: ReactNode }[];
5354
}
5455
/**
5556
*
@@ -70,6 +71,7 @@ export function HiveNavigation({
7071
productName,
7172
logo,
7273
navLinks,
74+
developerMenu,
7375
}: HiveNavigationProps) {
7476
// `useThemeConfig` doesn't return anything outside of Nextra, and the provider isn't exported
7577
const themeConfig = useThemeConfig() as ReturnType<typeof useThemeConfig> | undefined;
@@ -122,7 +124,7 @@ export function HiveNavigation({
122124
<NavigationMenuItem>
123125
<NavigationMenuTrigger>Developer</NavigationMenuTrigger>
124126
<NavigationMenuContent>
125-
<DeveloperMenu isHive={isHive} />
127+
<DeveloperMenu isHive={isHive} developerMenu={developerMenu} />
126128
</NavigationMenuContent>
127129
</NavigationMenuItem>
128130
{!ENTERPRISE_MENU_HIDDEN && (
@@ -267,12 +269,13 @@ export const ProductsMenu = React.forwardRef<HTMLDivElement, ProductsMenuProps>(
267269
className="flex flex-row items-center gap-3 px-4 py-2"
268270
arrow
269271
>
270-
<div className="flex size-8 items-center justify-center rounded bg-beige-200 dark:bg-white/5">
272+
<div className="flex size-8 items-center justify-center rounded bg-beige-200 p-[5px] dark:bg-white/5">
271273
<Logo className="size-8 text-green-1000 dark:text-neutral-300" />
272274
</div>
273275
<div>
274276
<p className="text-base font-medium leading-normal text-green-1000 dark:text-neutral-200">
275-
{product.name}
277+
{/* shortened to one word */}
278+
{product.name === PRODUCTS.ESLINT.name ? 'ESLint' : product.name}
276279
</p>
277280
</div>
278281
</NavigationMenuLink>
@@ -318,38 +321,43 @@ MenuContentColumns.displayName = 'MenuContentColumns';
318321

319322
interface DeveloperMenuProps extends React.HTMLAttributes<HTMLDivElement> {
320323
isHive: boolean;
324+
developerMenu:
325+
| undefined
326+
| { href: string; icon: React.FC<{ className?: string }>; children: ReactNode }[];
321327
}
322328
/**
323329
* @internal
324330
*/
325331
export const DeveloperMenu = React.forwardRef<HTMLDivElement, DeveloperMenuProps>(
326-
({ isHive, ...rest }, ref) => {
332+
({ isHive, developerMenu, ...rest }, ref) => {
333+
developerMenu ||= [
334+
{
335+
href: isHive ? '/docs' : 'https://the-guild.dev/graphql/hive/docs',
336+
icon: PaperIcon,
337+
children: 'Documentation',
338+
},
339+
{ href: 'https://status.graphql-hive.com/', icon: TargetIcon, children: 'Status' },
340+
{
341+
href: isHive ? '/product-updates' : 'https://the-guild.dev/graphql/hive/product-updates',
342+
icon: RightCornerIcon,
343+
children: 'Product Updates',
344+
},
345+
{ href: 'https://the-guild.dev/blog', icon: PencilIcon, children: 'Blog' },
346+
{
347+
href: 'https://github.com/dotansimha/graphql-code-generator',
348+
icon: GitHubIcon,
349+
children: 'GitHub',
350+
},
351+
];
352+
327353
return (
328354
<MenuContentColumns {...rest} ref={ref}>
329355
<div>
330356
<ColumnLabel>Developer</ColumnLabel>
331357
<ul>
332-
{(
333-
[
334-
[
335-
'Documentation',
336-
PaperIcon,
337-
isHive ? '/docs' : 'https://the-guild.dev/graphql/hive/docs',
338-
],
339-
['Status', TargetIcon, 'https://status.graphql-hive.com/'],
340-
[
341-
'Product Updates',
342-
RightCornerIcon,
343-
isHive
344-
? '/product-updates'
345-
: 'https://the-guild.dev/graphql/hive/product-updates',
346-
],
347-
['Blog', PencilIcon, 'https://the-guild.dev/blog'],
348-
['GitHub', GitHubIcon, 'https://github.com/kamilkisiela/graphql-hive'],
349-
] as const
350-
).map(([text, Icon, href], i) => (
351-
<MenuColumnListItem key={i} href={href} icon={Icon}>
352-
{text}
358+
{developerMenu.map(({ href, icon, children }, i) => (
359+
<MenuColumnListItem key={i} href={href} icon={icon}>
360+
{children}
353361
</MenuColumnListItem>
354362
))}
355363
</ul>
@@ -388,7 +396,7 @@ function MenuColumnListItem({
388396
}: {
389397
children: ReactNode;
390398
href: string;
391-
icon: (props: React.SVGProps<SVGSVGElement>) => React.ReactNode;
399+
icon: React.FC<{ className?: string }>;
392400
}) {
393401
return (
394402
<li>

0 commit comments

Comments
 (0)