Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
feat(header): new header component
Browse files Browse the repository at this point in the history
feat(header): new header component
  • Loading branch information
Metnew committed Feb 18, 2018
1 parent f2ed57e commit 64c2bb5
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 49 deletions.
55 changes: 55 additions & 0 deletions src/common/components/Header/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* @flow
*/
import React from 'react'
import {connect} from 'react-redux'
import {Icon} from 'semantic-ui-react'
import {withRouter, matchPath} from 'react-router'
import _ from 'lodash'
import {TOGGLE_SIDEBAR} from 'actions/layout'
import {StyledHeader} from './style'
import {getMetaRoutes} from 'routing'
import {getLayoutMobileStatuses} from 'selectors'
import Headroom from 'react-headroom'

type Props = {
title: string,
toggleSidebar: () => void,
isMobile: boolean
}

const Header = ({title, toggleSidebar, isMobile}: Props) => {
return (
<Headroom>
<StyledHeader>
<div className="header-inner">
{isMobile && (
<span className="navicon" role="button" onClick={toggleSidebar}>
<Icon name="content" />
</span>
)}
<span className="page-title">{title}</span>
</div>
</StyledHeader>
</Headroom>
)
}

const mapStateToProps = (state, props) => {
const {location: {pathname}} = props
const {name: title} =
_.find(getMetaRoutes(), a => matchPath(pathname, a)) || {}
const {isMobile} = getLayoutMobileStatuses(state)
return {
title,
isMobile
}
}

const mapDispatchToProps = dispatch => ({
toggleSidebar () {
dispatch(TOGGLE_SIDEBAR)
}
})

export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Header))
38 changes: 38 additions & 0 deletions src/common/components/Header/style.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import styled from 'styled-components'
import {media} from 'styles/utils'

export const StyledHeader = styled.header`
background: ${props => props.theme.navy};
color: ${props => props.theme.white};
border-bottom: 1px solid ${props => props.theme.black};;
display: flex;
justify-content: center;
flex-direction: column;
width: 100%;
z-index: 444;
height: 72px;
.header-inner {
display: flex;
padding: 0 15px;
}
.page-title {
line-height: 1;
font-size: 24px;
align-items: center;
display: flex;
}
.navicon {
width: 48px;
height: 48px;
padding: 12px;
line-height: 1;
font-size: 24px;
display: none;
${media.md`
display: block;
`};
}
`
49 changes: 0 additions & 49 deletions src/common/components/parts/Header/style.jsx

This file was deleted.

0 comments on commit 64c2bb5

Please sign in to comment.