-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from abusix/pla-801-create-new-sidebar-navigat…
…ion-to-hailstorm feat(components): add navigation
- Loading branch information
Showing
7 changed files
with
240 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from "react"; | ||
import { Disclosure } from "@headlessui/react"; | ||
import { classNames } from "../../util/class-names"; | ||
|
||
export interface NavigationDisclosurePanelItemProps { | ||
children: React.ReactNode; | ||
isActive?: boolean; | ||
isIndented?: boolean; | ||
} | ||
|
||
const NavigationDisclosurePanelItem = ({ | ||
children, | ||
isActive, | ||
isIndented, | ||
}: NavigationDisclosurePanelItemProps) => { | ||
return ( | ||
<div | ||
className={classNames( | ||
"relative w-full px-8 py-3 text-left text-sm text-neutral-0 hover:bg-primary-900+10", | ||
isIndented && "px-14", | ||
isActive && "bg-primary-900+20 font-semibold hover:bg-primary-900+20" | ||
)} | ||
> | ||
{children} | ||
{isActive && ( | ||
<div className="absolute bottom-0 left-0 top-0 h-full w-0.5 rounded-r-sm bg-neutral-0" /> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export interface NavigationDisclosurePanelProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
const NavigationDisclosurePanel = ({ children }: NavigationDisclosurePanelProps) => { | ||
return <Disclosure.Panel>{children}</Disclosure.Panel>; | ||
}; | ||
|
||
NavigationDisclosurePanel.Item = NavigationDisclosurePanelItem; | ||
|
||
export { NavigationDisclosurePanel }; |
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,35 @@ | ||
import { Disclosure } from "@headlessui/react"; | ||
import React from "react"; | ||
import { NavigationDisclosurePanel } from "./navigation-disclosure-panel"; | ||
|
||
interface NavigationDisclosureButtonProps { | ||
children: React.ReactNode; | ||
LeftIcon?: React.ElementType; | ||
} | ||
|
||
const NavigationDisclosureButton = ({ children, LeftIcon }: NavigationDisclosureButtonProps) => { | ||
return ( | ||
<Disclosure.Button className="flex w-full items-center gap-x-3 px-4 py-3 text-left text-sm text-neutral-0 hover:bg-primary-900+10 ui-open:bg-primary-900+8 ui-open:font-semibold"> | ||
{LeftIcon ? <LeftIcon className="h-4 w-4" /> : null} | ||
{children} | ||
</Disclosure.Button> | ||
); | ||
}; | ||
|
||
export interface NavigationDisclosureProps { | ||
children: React.ReactNode; | ||
defaultOpen?: boolean; | ||
} | ||
|
||
const NavigationDisclosure = ({ children, defaultOpen }: NavigationDisclosureProps) => { | ||
return ( | ||
<Disclosure as="div" defaultOpen={defaultOpen}> | ||
{children} | ||
</Disclosure> | ||
); | ||
}; | ||
|
||
NavigationDisclosure.Panel = NavigationDisclosurePanel; | ||
NavigationDisclosure.Button = NavigationDisclosureButton; | ||
|
||
export { NavigationDisclosure }; |
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,33 @@ | ||
import React from "react"; | ||
import { classNames } from "../../util/class-names"; | ||
|
||
export interface NavigationGroupItemProps { | ||
children: React.ReactNode; | ||
isActive?: boolean; | ||
LeftIcon?: React.ElementType; | ||
} | ||
|
||
const NavigationGroupItem = ({ children, isActive, LeftIcon }: NavigationGroupItemProps) => { | ||
return ( | ||
<div | ||
className={classNames( | ||
"relative flex items-center gap-x-3 px-4 py-3 text-sm text-neutral-0 hover:bg-primary-900+10", | ||
isActive && "bg-primary-900+20 font-semibold hover:bg-primary-900+20" | ||
)} | ||
> | ||
{LeftIcon ? <LeftIcon className="h-4 w-4" /> : null} | ||
{children} | ||
{isActive && ( | ||
<div className="absolute bottom-0 left-0 top-0 h-full w-0.5 rounded-r-sm bg-neutral-0" /> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
const NavigationGroup = ({ children }: { children: React.ReactNode }) => { | ||
return <div className="pt-4">{children}</div>; | ||
}; | ||
|
||
NavigationGroup.Item = NavigationGroupItem; | ||
|
||
export { NavigationGroup }; |
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,96 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import React from "react"; | ||
import { Navigation } from "./navigation"; | ||
import { CogIcon, HelpIcon, InfoSignIcon } from "../../icons"; | ||
|
||
const meta: Meta<typeof Navigation> = { | ||
title: "Navigation", | ||
component: Navigation, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof Navigation>; | ||
|
||
export const Default: Story = { | ||
render: () => ( | ||
<div className="flex min-h-[1200px] flex-col"> | ||
<Navigation> | ||
<Navigation.Logo> | ||
<div className="text-neutral-0">Abusix</div> | ||
</Navigation.Logo> | ||
<nav className="flex flex-1 flex-col"> | ||
<Navigation.Group> | ||
<Navigation.Group.Item>Home</Navigation.Group.Item> | ||
<Navigation.Group.Item isActive>Dashboard</Navigation.Group.Item> | ||
</Navigation.Group> | ||
<Navigation.Group> | ||
<Navigation.Group.Item>Lookup & Delist</Navigation.Group.Item> | ||
<Navigation.Group.Item>Mail Intelligence</Navigation.Group.Item> | ||
<Navigation.Disclosure> | ||
<Navigation.Disclosure.Button>AbuseHQ</Navigation.Disclosure.Button> | ||
<Navigation.Disclosure.Panel> | ||
<Navigation.Disclosure.Panel.Item> | ||
Cases | ||
</Navigation.Disclosure.Panel.Item> | ||
<Navigation.Disclosure.Panel.Item isActive> | ||
Event Inbox | ||
</Navigation.Disclosure.Panel.Item> | ||
<Navigation.Disclosure.Panel.Item> | ||
Mailbox | ||
</Navigation.Disclosure.Panel.Item> | ||
<Navigation.Disclosure.Panel.Item> | ||
Dashboard | ||
</Navigation.Disclosure.Panel.Item> | ||
<Navigation.Disclosure.Panel.Item> | ||
Statistics | ||
</Navigation.Disclosure.Panel.Item> | ||
<Navigation.Disclosure.Panel.Item> | ||
Settings | ||
</Navigation.Disclosure.Panel.Item> | ||
</Navigation.Disclosure.Panel> | ||
</Navigation.Disclosure> | ||
</Navigation.Group> | ||
<Navigation.Group> | ||
<Navigation.Group.Item>Networks</Navigation.Group.Item> | ||
<Navigation.Group.Item>Data Channels</Navigation.Group.Item> | ||
</Navigation.Group> | ||
<div className="mt-auto"> | ||
<Navigation.Group.Item LeftIcon={HelpIcon}>Support</Navigation.Group.Item> | ||
<Navigation.Disclosure> | ||
<Navigation.Disclosure.Button LeftIcon={InfoSignIcon}> | ||
Plans & Billing | ||
</Navigation.Disclosure.Button> | ||
<Navigation.Disclosure.Panel> | ||
<Navigation.Disclosure.Panel.Item isIndented> | ||
Subscriptions | ||
</Navigation.Disclosure.Panel.Item> | ||
<Navigation.Disclosure.Panel.Item isIndented> | ||
Billing | ||
</Navigation.Disclosure.Panel.Item> | ||
<Navigation.Disclosure.Panel.Item isIndented> | ||
Invoices | ||
</Navigation.Disclosure.Panel.Item> | ||
</Navigation.Disclosure.Panel> | ||
</Navigation.Disclosure> | ||
<Navigation.Disclosure> | ||
<Navigation.Disclosure.Button LeftIcon={CogIcon}> | ||
Settings | ||
</Navigation.Disclosure.Button> | ||
<Navigation.Disclosure.Panel> | ||
<Navigation.Disclosure.Panel.Item isIndented> | ||
Profile | ||
</Navigation.Disclosure.Panel.Item> | ||
<Navigation.Disclosure.Panel.Item isIndented> | ||
Team | ||
</Navigation.Disclosure.Panel.Item> | ||
<Navigation.Disclosure.Panel.Item isIndented> | ||
Sign out | ||
</Navigation.Disclosure.Panel.Item> | ||
</Navigation.Disclosure.Panel> | ||
</Navigation.Disclosure> | ||
</div> | ||
</nav> | ||
</Navigation> | ||
</div> | ||
), | ||
}; |
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,29 @@ | ||
import React from "react"; | ||
import { NavigationDisclosure } from "./navigation-disclosure"; | ||
import { NavigationGroup } from "./navigation-group"; | ||
|
||
export interface NavigationLogoProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
const NavigationLogo = ({ children }: NavigationLogoProps) => { | ||
return <div className="px-4 py-3">{children}</div>; | ||
}; | ||
|
||
export interface NavigationProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
const Navigation = ({ children }: NavigationProps) => { | ||
return ( | ||
<div className="flex w-[180px] grow flex-col overflow-y-auto bg-primary-900 pb-5 pt-3"> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
Navigation.Logo = NavigationLogo; | ||
Navigation.Group = NavigationGroup; | ||
Navigation.Disclosure = NavigationDisclosure; | ||
|
||
export { Navigation }; |
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