-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
33 - Create the navigation elements of the design system #54
Merged
kcondon
merged 9 commits into
develop
from
feature/create-the-navigation-elements-of-the-design-system
Apr 26, 2023
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
46ba0cb
feat(Breadcrumb): add the breadcrumb of the design system
MellyGray c7e12a3
feat(Breadcrumb): add tests
MellyGray 7278e06
feat(BreadcrumbItem): add tests
MellyGray 2a5d0fc
feat(Tabs): add Tabs component to the design system
MellyGray 80565f6
feat(Tabs): add tests
MellyGray 1e1c54b
fix(Breadcrumbs): refactor
MellyGray 7ce257a
feat(Navbar): refactor navbar for better readbility
MellyGray fecd13e
fix: merge conflicts
MellyGray e886f0a
fix: linter
MellyGray File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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,55 @@ | ||
import { Navbar } from '../../../../src/sections/ui/navbar/Navbar' | ||
|
||
const brand = { | ||
logoImgSrc: '/logo.svg', | ||
title: 'Brand Title', | ||
href: '/home' | ||
} | ||
|
||
describe('Navbar component', () => { | ||
it('renders the brand logo and title', () => { | ||
cy.mount(<Navbar brand={brand} />) | ||
|
||
cy.findByRole('img', { name: 'Brand Logo Image' }).should('exist') | ||
cy.findByText('Brand Title').should('exist') | ||
}) | ||
|
||
it('renders the navbar links', () => { | ||
cy.mount( | ||
<Navbar brand={brand}> | ||
<Navbar.Link href="/link-1">Link 1</Navbar.Link> | ||
<Navbar.Link href="/link-2">Link 2</Navbar.Link> | ||
<Navbar.Dropdown title="Dropdown" id="dropdown"> | ||
<Navbar.Dropdown.Item href="/sublink-1">Sublink 1</Navbar.Dropdown.Item> | ||
<Navbar.Dropdown.Item href="/sublink-2">Sublink 2</Navbar.Dropdown.Item> | ||
</Navbar.Dropdown> | ||
</Navbar> | ||
) | ||
|
||
cy.findByRole('button', { name: 'Toggle navigation' }).click() | ||
cy.findByRole('link', { name: 'Link 1' }).should('exist') | ||
cy.findByRole('link', { name: 'Link 2' }).should('exist') | ||
|
||
const dropdownElement = cy.findByRole('button', { name: 'Dropdown' }) | ||
dropdownElement.should('exist') | ||
}) | ||
|
||
it('shows the sublinks when the dropdown is clicked', () => { | ||
cy.mount( | ||
<Navbar brand={brand}> | ||
<Navbar.Link href="/link-1">Link 1</Navbar.Link> | ||
<Navbar.Link href="/link-2">Link 2</Navbar.Link> | ||
<Navbar.Dropdown title="Dropdown" id="dropdown"> | ||
<Navbar.Dropdown.Item href="/sublink-1">Sublink 1</Navbar.Dropdown.Item> | ||
<Navbar.Dropdown.Item href="/sublink-2">Sublink 2</Navbar.Dropdown.Item> | ||
</Navbar.Dropdown> | ||
</Navbar> | ||
) | ||
cy.findByRole('button', { name: 'Toggle navigation' }).click() | ||
const dropdownElement = cy.findByRole('button', { name: 'Dropdown' }) | ||
dropdownElement.click() | ||
|
||
cy.findByRole('link', { name: 'Sublink 1' }).should('exist') | ||
cy.findByRole('link', { name: 'Sublink 2' }).should('exist') | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
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
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,11 @@ | ||
import { Breadcrumb as BreadcrumbBS } from 'react-bootstrap' | ||
import { PropsWithChildren } from 'react' | ||
import { BreadcrumbItem } from './BreadcrumbItem' | ||
|
||
function Breadcrumb({ children }: PropsWithChildren) { | ||
return <BreadcrumbBS>{children}</BreadcrumbBS> | ||
} | ||
|
||
Breadcrumb.Item = BreadcrumbItem | ||
|
||
export { Breadcrumb } |
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,14 @@ | ||
import { BreadcrumbItem as BreadcrumbItemBS } from 'react-bootstrap' | ||
import { PropsWithChildren } from 'react' | ||
|
||
interface BreadcrumbItemProps { | ||
href?: string | ||
active?: boolean | ||
} | ||
export function BreadcrumbItem({ href, active, children }: PropsWithChildren<BreadcrumbItemProps>) { | ||
return ( | ||
<BreadcrumbItemBS href={href} active={active}> | ||
{children} | ||
</BreadcrumbItemBS> | ||
) | ||
} |
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 |
---|---|---|
@@ -1,33 +1,38 @@ | ||
import { Navbar as NavbarBS } from 'react-bootstrap' | ||
import { Nav } from 'react-bootstrap' | ||
import { Link, NavbarProps } from './NavbarProps' | ||
import { NavDropdown } from './nav-dropdown/NavDropdown' | ||
import { NavbarDropdown } from './navbar-dropdown/NavbarDropdown' | ||
import { Container } from '../grid/Container' | ||
import { PropsWithChildren } from 'react' | ||
import { NavbarLink } from './NavbarLink' | ||
|
||
export function Navbar({ brand, links }: NavbarProps) { | ||
interface Brand { | ||
title: string | ||
href: string | ||
logoImgSrc: string | ||
} | ||
|
||
export interface NavbarProps { | ||
brand: Brand | ||
} | ||
|
||
function Navbar({ brand, children }: PropsWithChildren<NavbarProps>) { | ||
return ( | ||
<NavbarBS collapseOnSelect bg="light" expand="lg" fixed="top"> | ||
<Container> | ||
<NavbarBS.Brand href={brand.path}> | ||
<img width="28" height="28" src={brand.logo.src} alt={brand.logo.altText} /> | ||
<NavbarBS.Brand href={brand.href}> | ||
<img width="28" height="28" src={brand.logoImgSrc} alt="Brand Logo Image" /> | ||
{brand.title} | ||
</NavbarBS.Brand> | ||
<NavbarBS.Toggle aria-controls="responsive-navbar-nav" /> | ||
<NavbarBS.Collapse id="responsive-navbar-nav"> | ||
<Nav> | ||
{links.length != 0 && | ||
links.map((link: Link, index) => | ||
typeof link.value == 'string' ? ( | ||
<Nav.Link eventKey={index} key={index} href={link.value}> | ||
{link.title} | ||
</Nav.Link> | ||
) : ( | ||
<NavDropdown key={index} title={link.title} links={link.value} /> | ||
) | ||
)} | ||
</Nav> | ||
<Nav>{children}</Nav> | ||
</NavbarBS.Collapse> | ||
</Container> | ||
</NavbarBS> | ||
) | ||
} | ||
|
||
Navbar.Link = NavbarLink | ||
Navbar.Dropdown = NavbarDropdown | ||
|
||
export { Navbar } |
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,10 @@ | ||
import { Nav } from 'react-bootstrap' | ||
import { PropsWithChildren } from 'react' | ||
|
||
interface NavbarLinkProps { | ||
href: string | ||
} | ||
|
||
export function NavbarLink({ href, children }: PropsWithChildren<NavbarLinkProps>) { | ||
return <Nav.Link href={href}>{children}</Nav.Link> | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,20 @@ | ||
import { NavDropdown as NavDropdownBS } from 'react-bootstrap' | ||
import { PropsWithChildren } from 'react' | ||
import { NavbarDropdownItem } from './NavbarDropdownItem' | ||
|
||
interface DropdownProps { | ||
title: string | ||
id: string | ||
} | ||
|
||
function NavbarDropdown({ title, id, children }: PropsWithChildren<DropdownProps>) { | ||
return ( | ||
<NavDropdownBS title={title} id={id}> | ||
{children} | ||
</NavDropdownBS> | ||
) | ||
} | ||
|
||
NavbarDropdown.Item = NavbarDropdownItem | ||
|
||
export { NavbarDropdown } |
10 changes: 10 additions & 0 deletions
10
src/sections/ui/navbar/navbar-dropdown/NavbarDropdownItem.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,10 @@ | ||
import { NavDropdown } from 'react-bootstrap' | ||
import { PropsWithChildren } from 'react' | ||
|
||
interface NavbarDropdownItemProps { | ||
href: string | ||
} | ||
|
||
export function NavbarDropdownItem({ href, children }: PropsWithChildren<NavbarDropdownItemProps>) { | ||
return <NavDropdown.Item href={href}>{children}</NavDropdown.Item> | ||
} |
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,15 @@ | ||
import { PropsWithChildren } from 'react' | ||
import { Tab as TabBS } from 'react-bootstrap' | ||
|
||
export interface TabProps { | ||
title: string | ||
eventKey: string | ||
} | ||
|
||
export function Tab({ title, eventKey, children }: PropsWithChildren<TabProps>) { | ||
return ( | ||
<TabBS title={title} eventKey={eventKey}> | ||
{children} | ||
</TabBS> | ||
) | ||
} |
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,15 @@ | ||
import { PropsWithChildren } from 'react' | ||
import { Tab } from './Tab' | ||
import { Tabs as TabsBS } from 'react-bootstrap' | ||
|
||
interface TabsProps { | ||
defaultActiveKey: string | ||
} | ||
|
||
function Tabs({ defaultActiveKey, children }: PropsWithChildren<TabsProps>) { | ||
return <TabsBS defaultActiveKey={defaultActiveKey}>{children}</TabsBS> | ||
} | ||
|
||
Tabs.Tab = Tab | ||
|
||
export { Tabs } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this have a heading of "Props"? This is what I see:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @pdurbin ! The Props heading is missing because this branch is older than the #40 mdx storybook docs template. Then the template with the Props heading is missing in this branch but once this is merged it should look good in dev
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MellyGray yes, you're right. I hope you don't mind but I did
git rebase develop
on this PR and then force pushed it. The Props heading is there now: