-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: attempt of including Drawer inside of GlobalNav
- Loading branch information
Showing
3 changed files
with
236 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
204 changes: 204 additions & 0 deletions
204
src/components/navigation/GlobalNavigation/GlobalNavigationNotificationCenter.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
import React, { useMemo, useRef } from 'react' | ||
import { | ||
Center, | ||
GlobalNavigation, | ||
Icon, | ||
type IGlobalNavigationItem, | ||
type IGlobalNavigationLogo, | ||
type INavigationOrg, | ||
} from 'src/components' | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { type IGlobalNavigationLink } from 'src/components/navigation/GlobalNavigation/GlobalNavigationItems' | ||
|
||
const defaultLogo: IGlobalNavigationLogo = { | ||
label: 'Aqua', | ||
icon: <Icon name="alicorn" size="xxl" color="brand" />, | ||
type: 'custom-size', | ||
onSuiteLogoClick: () => { | ||
alert('Going to Aqua Home!') | ||
}, | ||
} | ||
|
||
const defaultTools: IGlobalNavigationItem[] = [ | ||
{ | ||
label: 'Tool 1', | ||
isActive: true, | ||
icon: <Icon name="privacy" />, | ||
type: 'menu', | ||
children: [ | ||
{ label: 'option 1', hrefOptions: { href: '/' } }, | ||
{ label: 'option 2', hrefOptions: { href: '/' } }, | ||
{ label: 'option 3', hrefOptions: { href: '/' } }, | ||
], | ||
}, | ||
{ | ||
label: 'Tool 2', | ||
icon: <Icon name="favorite" />, | ||
type: 'menu', | ||
children: [ | ||
{ label: 'option 1', hrefOptions: { href: '/' } }, | ||
{ label: 'option 2', hrefOptions: { href: '/' } }, | ||
{ label: 'option 3', hrefOptions: { href: '/' } }, | ||
], | ||
}, | ||
{ | ||
label: 'Tool 3', | ||
icon: <Icon name="connections" />, | ||
hrefOptions: { href: '/' }, | ||
}, | ||
] | ||
|
||
const defaultManagement: IGlobalNavigationItem[] = [ | ||
{ | ||
label: 'Notifications', | ||
hideLabel: true, | ||
icon: <Icon name="api" />, | ||
hrefOptions: { href: '/' }, | ||
}, | ||
{ | ||
label: 'Support', | ||
hideLabel: true, | ||
icon: <Icon name="support" />, | ||
type: 'menu', | ||
children: [ | ||
{ label: 'option 1', hrefOptions: { href: '/' } }, | ||
{ label: 'option 2', hrefOptions: { href: '/' } }, | ||
{ label: 'option 3', hrefOptions: { href: '/' } }, | ||
], | ||
}, | ||
{ | ||
label: 'Settings', | ||
hideLabel: true, | ||
icon: <Icon name="settings" />, | ||
type: 'menu', | ||
children: [ | ||
{ label: 'option 1', hrefOptions: { href: '/' } }, | ||
{ label: 'option 2', hrefOptions: { href: '/' } }, | ||
{ label: 'option 3', hrefOptions: { href: '/' } }, | ||
{ | ||
label: 'button', | ||
type: 'button', | ||
buttonOptions: { | ||
onClick: () => { | ||
alert('go') | ||
}, | ||
}, | ||
}, | ||
{ type: 'button', label: 'go', buttonOptions: { href: '/', target: '_blank' } }, | ||
], | ||
}, | ||
] | ||
|
||
const defaultOrgs: INavigationOrg[] = [ | ||
{ | ||
id: 'org1', | ||
label: 'Org 1', | ||
accounts: [ | ||
{ | ||
id: 'account1', | ||
label: 'account 1', | ||
workspaces: [ | ||
{ | ||
id: 'workspace1', | ||
label: 'Workspace 111111111', | ||
isActive: true, | ||
onClick: () => { | ||
alert('Selected Workspace 1') | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
] | ||
|
||
const meta: Meta<typeof GlobalNavigation> = { | ||
title: 'Aquarium/Navigation/GlobalNavigationNotificationCenter', | ||
component: props => ( | ||
<Center style={{ minHeight: '800px' }}> | ||
<GlobalNavigation {...props}></GlobalNavigation> | ||
</Center> | ||
), | ||
|
||
args: { | ||
logo: defaultLogo, | ||
tools: defaultTools, | ||
management: defaultManagement, | ||
orgs: defaultOrgs, | ||
navigationButtonItemOptions: { | ||
label: 'Sign Out of mParticle', | ||
onClick: () => { | ||
alert('signing out!') | ||
}, | ||
}, | ||
onMpHomeClick: () => { | ||
alert('Going to mP!') | ||
}, | ||
}, | ||
} | ||
export default meta | ||
|
||
type Story = StoryObj<typeof GlobalNavigation> | ||
|
||
export const MPWithDisabledInteractions: Story = { | ||
render: props => { | ||
// const [isNotificationCenterOpen, setIsNotificationCenterOpen] = useState(false) | ||
const notificationCenterRef = useRef(true) | ||
console.log('rendering...') | ||
const management = useMemo( | ||
() => [ | ||
{ | ||
label: 'Notifications', | ||
hideLabel: true, | ||
icon: <Icon name="notification" />, | ||
type: 'link', | ||
isActive: false, | ||
onClick: () => { | ||
notificationCenterRef.current = !notificationCenterRef.current | ||
}, | ||
} satisfies IGlobalNavigationLink, | ||
...defaultManagement, | ||
], | ||
[], | ||
) | ||
|
||
return ( | ||
<div style={{ width: 800 }}> | ||
<GlobalNavigation | ||
{...props} | ||
drawerOptions={{ | ||
title: 'Notifications', | ||
open: notificationCenterRef.current, | ||
}} | ||
logo={defaultLogo} | ||
tools={defaultTools} | ||
management={management} | ||
orgs={defaultOrgs} | ||
showSuiteLogo={true} | ||
onSearchClick={() => { | ||
alert('Searching!') | ||
}} | ||
suiteSelectorOptions={{ | ||
overviewHref: '/', | ||
onLinkClick: link => { | ||
alert(link.href) | ||
}, | ||
onUnauthorizedClick: link => { | ||
alert(`unauthorized ${link?.href} `) | ||
}, | ||
unauthorizedLinks: ['dataPlatform'], | ||
activeLink: 'oversight', | ||
links: [ | ||
{ linkId: 'oversight', href: '/oversight' }, | ||
{ linkId: 'dataPlatform', href: '/data-platform' }, | ||
{ linkId: 'customer360', href: '/customer-360' }, | ||
{ linkId: 'predictions', href: '/predictions' }, | ||
{ linkId: 'analytics', href: '/analytics' }, | ||
{ linkId: 'segmentation', href: '/segmentation' }, | ||
], | ||
}} | ||
/> | ||
</div> | ||
) | ||
}, | ||
} |