Skip to content
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

Add Flagship to Navbar #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 10 additions & 1 deletion src/components/Navbar/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@ import React from 'react'
import { NavbarProvider } from './NavbarContext'

export default function Navbar({ children }) {
const hasService = children.find(
(child) => child.type.displayName in ['NavbarLogoFlagship']
)

return (
<header className='hw-navbar'>
<div className='hw-navbar__content'>
<div className='hw-navbar__top'>
<div
className={
'hw-navbar__top' +
(hasService ? ' hw-navbar__top--service' : '')
}
>
<NavbarProvider>{children}</NavbarProvider>
</div>
</div>
Expand Down
32 changes: 32 additions & 0 deletions src/components/Navbar/Navbar.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import NavbarSearchButton from './NavbarSearchButton'
import NavbarSearch from './NavbarSearch'
import NavbarMenuButton from './NavbarMenuButton'
import NavbarMenuDrawer from './NavbarMenuDrawer'
import NavbarLogoFlagship from './NavbarLogoFlagship'
import Block from '../../layout/Block/Block'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faUser } from '@fortawesome/pro-regular-svg-icons'
Expand Down Expand Up @@ -167,3 +168,34 @@ const Template = (args) => (
)

export const Default = Template.bind({})

const TemplateFlagship = (args) => (
<div style={{ height: '600px' }}>
<Navbar {...args}>
<NavbarLogoFlagship
title='Posten logo'
logo='posten'
href='#'
ariaLabel='Go to homepage'
flagship='Signering'
/>
<NavbarSkipToMain title='Skip to main content' href='#main' />
<NavbarMenu>
<NavbarMenuButton
menuName='Menu'
menuTitle='Show menu'
closeName='Close'
closeTitle='Close menu'
/>
<NavbarMenuDrawer
selectorItems={selectorItems}
featuredLinks={featuredLinks}
menuSections={menuSections}
loginLink={{ href: '#', text: 'Min side' }}
/>
</NavbarMenu>
</Navbar>
</div>
)

export const Flagship = TemplateFlagship.bind({})
36 changes: 36 additions & 0 deletions src/components/Navbar/NavbarLogoFlagship.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react'
import PropTypes from 'prop-types'
import ServiceIcon from '../ServiceIcon/ServiceIcon'

export default function NavbarLogoFlagship({
href,
logo,
title,
ariaLabel,
flagship
}) {
return (
<span className='hw-navbar__logo hw-navbar__logo--service'>
<a
href={href}
style={{ zIndex: '300' }}
aria-label={ariaLabel || title}
>
<ServiceIcon
icon={'logo-' + logo}
title={title}
className='hw-navbar__logo-standard'
/>
</a>
<span className='hw-navbar__logo-flagship'>{flagship}</span>
</span>
)
}

NavbarLogoFlagship.propTypes = {
href: PropTypes.string.isRequired,
logo: PropTypes.oneOf(['bring', 'posten']).isRequired,
title: PropTypes.string.isRequired,
ariaLabel: PropTypes.string,
flagship: PropTypes.string.isRequired
}