Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions src/theme/ProductSwitcher/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Menu, MenuButton, MenuItems, MenuItem } from '@headlessui/react';
import { useHistory, useRouteMatch } from 'react-router-dom';
import { SignalIcon, ArrowDownTrayIcon, ChevronDownIcon } from '@heroicons/react/24/outline';
import { useRouteMatch, Link } from 'react-router-dom';
import { SignalIcon, ArrowDownTrayIcon, ChevronDownIcon, PlayCircleIcon } from '@heroicons/react/24/outline';
import brandNavySmall from '../../../static/img/brand-small-icon.svg';

import styles from './styles.module.css';
Expand All @@ -10,39 +10,46 @@ const products = [
{
id: 'dispatch',
name: 'Svix Dispatch',
url: '/',
path: '/',
description: 'Webhooks Sending',
icon: brandNavySmall
},
{
id: 'stream',
name: 'Svix Stream',
baseUrl: '/stream/',
url: '/stream/introduction/',
path: '/stream/introduction/',
description: 'Event Streaming',
icon: SignalIcon
},
{
id: 'ingest',
name: 'Svix Ingest',
baseUrl: '/ingest',
url: '/ingest/receiving-with-ingest',
path: '/ingest/receiving-with-ingest',
description: 'Webhooks Receiving',
icon: ArrowDownTrayIcon
},
{
id: 'play',
name: 'Svix Play',
baseUrl: '/play',
href: 'https://svix.com/play',
description: 'Webhooks Debugger',
icon: PlayCircleIcon
},
{
id: 'other',
name: 'More',
baseUrl: '/receiving',
url: '/receiving/introduction/',
path: '/receiving/introduction/',
description: 'Useful documentation',
icon: brandNavySmall,
hidden: true
}
];

export default function ProductSwitcher() {
const history = useHistory();
const selectedProduct = products.find(p => useRouteMatch({ path: p.baseUrl === '/' ? '/' : `${p.baseUrl}*` })) || products[0];

if (selectedProduct.hidden) {
Expand All @@ -68,9 +75,11 @@ export default function ProductSwitcher() {
{products.filter(product => !product.hidden).map((product) => (
<MenuItem
key={product.id}
as="button"
onClick={() => history.push(product.url)}
className={styles.menuItem}
as={product.href ? 'a' : Link}
target={product.href ? '_blank' : undefined}
to={product.path}
href={product.href}
>
<>
<div className={styles.menuItemIcon}>
Expand Down
3 changes: 2 additions & 1 deletion src/theme/ProductSwitcher/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
.menuItem:hover,
.menuItemActive {
background: var(--ifm-color-emphasis-100);
text-decoration: none;
}

.menuItemFocus {
Expand Down Expand Up @@ -176,4 +177,4 @@

[data-theme='dark'] .menuItemFocus {
background: var(--ifm-color-emphasis-300);
}
}