Skip to content

Commit a1eaee7

Browse files
Configurable logo (#1788)
Co-authored-by: Dimitri POSTOLOV <[email protected]>
1 parent eda871a commit a1eaee7

17 files changed

+419
-379
lines changed

.changeset/clean-worms-lie.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@theguild/components": patch
3+
---
4+
5+
Make `HiveNavigation` logo configurable through `logo` prop.
6+
Expose `navLinks` prop to add links to /plugins.

packages/components/src/components/explore-main-product-cards.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function ExploreMainProductCards({ className, ...rest }: ExploreMainProdu
2828
</TextLink>
2929
</div>
3030
<ul className="-mx-12 -my-2 flex shrink-0 grow gap-[22px] overflow-auto px-12 py-2 [@media(max-width:1490px)]:w-full [@media(min-width:1490px)]:overflow-visible [&>:nth-child(n+4)]:[@media(min-width:1490px)]:hidden">
31-
{[PRODUCTS.HIVE, PRODUCTS.YOGA, PRODUCTS.MESH, PRODUCTS.CODEGEN].map(product => (
31+
{[PRODUCTS.HIVE, PRODUCTS.HIVE_GATEWAY, PRODUCTS.YOGA, PRODUCTS.MESH].map(product => (
3232
<MainProductCard key={product.name} as="li" product={product} />
3333
))}
3434
</ul>

packages/components/src/components/hive-footer.stories.ts renamed to packages/components/src/components/hive-footer.stories.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Meta, StoryObj } from '@storybook/react';
22
import { hiveThemeDecorator } from '../../../../.storybook/hive-theme-decorator';
33
import { HiveFooter, HiveFooterProps } from './hive-footer';
4+
import { CodegenIcon } from './icons';
45

56
export default {
67
title: 'Hive/HiveFooter',
@@ -34,3 +35,18 @@ export const Default: StoryObj<HiveFooterProps> = {
3435
],
3536
},
3637
};
38+
39+
export const CodegenFooter: StoryObj<HiveFooterProps> = {
40+
...Default,
41+
args: {
42+
logo: {
43+
href: '/',
44+
children: (
45+
<div className="flex items-center gap-3 text-green-1000">
46+
<CodegenIcon className="size-8" />
47+
<span className="text-2xl/[1.2] font-medium tracking-[-0.16px]">Codegen</span>
48+
</div>
49+
),
50+
},
51+
},
52+
};

packages/components/src/components/hive-footer.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ export function HiveFooter({ className, logo, resources = [], sameSite }: HiveFo
2121
<div className="mx-4 grid w-full max-w-[75rem] grid-cols-1 gap-x-6 text-green-800 max-lg:gap-y-16 sm:grid-cols-4 lg:gap-x-8 xl:gap-x-10 dark:text-neutral-400">
2222
<div className="max-lg:col-span-full">
2323
<Anchor
24-
href="https://the-guild.dev"
24+
href="/"
2525
sameSite={sameSite}
2626
{...logo}
2727
className="hive-focus -m-1.5 flex rounded p-1.5"
2828
>
29-
<HiveCombinationMark className="h-8 w-auto text-green-1000 dark:text-white" />
29+
{logo?.children || (
30+
<HiveCombinationMark className="h-8 w-auto text-green-1000 dark:text-white" />
31+
)}
3032
</Anchor>
3133
<p className="mt-6 lg:mt-8">Open-source GraphQL management platform</p>
3234
</div>

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { DocsThemeConfig, default as NextraLayout } from 'nextra-theme-docs';
22
import { Meta, StoryContext, StoryObj } from '@storybook/react';
33
import { hiveThemeDecorator } from '../../../../../.storybook/hive-theme-decorator';
44
import { PRODUCTS } from '../../products';
5+
import { Anchor } from '../anchor';
6+
import { CodegenIcon } from '../icons';
57
import { GraphQLConfCard } from './graphql-conf-card';
68
import {
79
CompanyMenu,
@@ -147,6 +149,25 @@ export const Company: StoryObj = {
147149
},
148150
};
149151

152+
export const CodegenNavmenu: StoryObj<HiveNavigationProps> = {
153+
...Default,
154+
args: {
155+
navLinks: [
156+
{
157+
href: '/plugins',
158+
children: 'Plugins',
159+
},
160+
],
161+
productName: PRODUCTS.CODEGEN.name,
162+
logo: (
163+
<Anchor href="/" className="hive-focus -m-2 flex items-center gap-3 rounded-md p-2">
164+
<CodegenIcon className="size-8" />
165+
<span className="text-2xl font-medium tracking-[-0.16px]">Codegen</span>
166+
</Anchor>
167+
),
168+
},
169+
};
170+
150171
function nextraThemeDocsCtxDecorator(Story: () => React.ReactNode, _ctx: StoryContext) {
151172
return (
152173
<NextraLayout

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

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ export interface HiveNavigationProps {
4848
* We change links to relative based on what product we're in.
4949
*/
5050
productName: string;
51+
logo?: ReactNode;
52+
navLinks?: { href: string; children: ReactNode }[];
5153
}
5254
/**
5355
*
@@ -66,6 +68,8 @@ export function HiveNavigation({
6668
children,
6769
className,
6870
productName,
71+
logo,
72+
navLinks,
6973
}: HiveNavigationProps) {
7074
// `useThemeConfig` doesn't return anything outside of Nextra, and the provider isn't exported
7175
const themeConfig = useThemeConfig() as ReturnType<typeof useThemeConfig> | undefined;
@@ -75,6 +79,14 @@ export function HiveNavigation({
7579

7680
const containerRef = useRef<HTMLDivElement>(null!);
7781

82+
logo ||= <HiveLogoLink isHive={isHive} />;
83+
navLinks ||= [
84+
{
85+
href: isHive ? '#pricing' : 'https://the-guild.dev/graphql/hive#pricing',
86+
children: 'Pricing',
87+
},
88+
];
89+
7890
return (
7991
<div
8092
ref={containerRef}
@@ -93,13 +105,13 @@ export function HiveNavigation({
93105

94106
{/* mobile menu */}
95107
<div className="flex items-center justify-between md:hidden">
96-
<HiveLogoLink />
108+
{logo}
97109
<HamburgerButton />
98110
</div>
99111

100112
{/* desktop menu */}
101113
<NavigationMenu className={cn('mx-auto hidden md:flex', className)} delayDuration={0}>
102-
<HiveLogoLink />
114+
{logo}
103115
<NavigationMenuList className="ml-4 bg-white dark:bg-transparent [@media(min-width:1180px)]:ml-16">
104116
<NavigationMenuItem>
105117
<NavigationMenuTrigger>Products</NavigationMenuTrigger>
@@ -127,15 +139,15 @@ export function HiveNavigation({
127139
<CompanyMenu>{companyMenuChildren}</CompanyMenu>
128140
</NavigationMenuContent>
129141
</NavigationMenuItem>
130-
<NavigationMenuItem className="flex">
131-
<NavigationMenuLink
132-
href={isHive ? '#pricing' : 'https://the-guild.dev/graphql/hive#pricing'}
133-
className="font-medium"
134-
>
135-
Pricing
136-
</NavigationMenuLink>
137-
</NavigationMenuItem>
142+
{navLinks.map(({ href, children }, i) => (
143+
<NavigationMenuItem key={i} className="flex">
144+
<NavigationMenuLink href={href} className="font-medium">
145+
{children}
146+
</NavigationMenuLink>
147+
</NavigationMenuItem>
148+
))}
138149
</NavigationMenuList>
150+
139151
<div className="flex-1" />
140152

141153
{children}
@@ -197,7 +209,7 @@ export const ProductsMenu = React.forwardRef<HTMLDivElement, ProductsMenuProps>(
197209
Hive
198210
</p>
199211
<p className="mt-1 text-sm leading-5 text-green-800 dark:text-neutral-400">
200-
GraphQL Management Platform, a Gateway & Decision-making Engine
212+
GraphQL Management Platform & Decision-making Engine
201213
</p>
202214
</NavigationMenuLink>
203215
<Anchor
@@ -207,14 +219,14 @@ export const ProductsMenu = React.forwardRef<HTMLDivElement, ProductsMenuProps>(
207219
<span>Get started</span> <ArrowIcon />
208220
</Anchor>
209221
</div>
210-
<div className="w-[267px]">
222+
<div className="w-[269px]">
211223
<ColumnLabel>The GraphQL Stack</ColumnLabel>
212224
<ul>
213225
{(
214226
[
227+
[PRODUCTS.HIVE_GATEWAY, 'Federation Gateway'],
215228
[PRODUCTS.MESH, 'Anything to GraphQL'],
216229
[PRODUCTS.YOGA, 'GraphQL Server & Subgraph'],
217-
[PRODUCTS.CODEGEN, 'GraphQL Code Generation'],
218230
] as const
219231
).map(([product, description]) => {
220232
const Logo = product.logo;
@@ -491,9 +503,12 @@ export function CompanyMenu({ children }: { children: React.ReactNode }) {
491503
);
492504
}
493505

494-
function HiveLogoLink() {
506+
function HiveLogoLink({ isHive }: { isHive: boolean }) {
495507
return (
496-
<Anchor href="/" className="hive-focus -m-2 flex items-center rounded-md p-2">
508+
<Anchor
509+
href={isHive ? '/' : 'https://the-guild.dev/graphql/hive'}
510+
className="hive-focus -m-2 flex items-center rounded-md p-2"
511+
>
497512
<HiveCombinationMark className="text-green-1000 dark:text-neutral-200" />
498513
</Anchor>
499514
);
Lines changed: 11 additions & 0 deletions
Loading

packages/components/src/components/icons/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export { ReactComponent as CodegenIcon } from './codegen.svg';
1515
export { ReactComponent as MeshIcon } from './mesh.svg';
1616
export { ReactComponent as YogaIcon } from './yoga.svg';
1717
export { ReactComponent as HiveIcon } from './hive.svg';
18+
export { ReactComponent as HiveGatewayIcon } from './hive-gateway.svg';
1819

1920
export { InformationCircleIcon, GitHubIcon, DiscordIcon } from 'nextra/icons';
2021

0 commit comments

Comments
 (0)