This repository has been archived by the owner on May 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow header disclaimer and logo to be skinned
- Loading branch information
1 parent
10cee55
commit 309f130
Showing
15 changed files
with
264 additions
and
251 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 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,84 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
import { header } from 'skin'; | ||
import { generateId } from '../../util/element_id'; | ||
|
||
const { disclaimer } = header; | ||
|
||
export default class Disclaimer extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { expanded: false }; | ||
|
||
this.handleClick = this.handleClick.bind(this); | ||
|
||
this.panelId = generateId('header_disclaimer_panel_'); | ||
} | ||
|
||
handleClick(e) { | ||
e.preventDefault(); | ||
|
||
this.setState(({ expanded }) => ({ expanded: !expanded })); | ||
} | ||
|
||
renderGuidance({ renderIcon, heading, content }) { | ||
return ( | ||
<div className="usa-width-one-half"> | ||
{renderIcon && renderIcon()} | ||
<div className="usa-media_block-body"> | ||
<p> | ||
<strong>{heading}</strong> | ||
<br /> | ||
{content} | ||
</p> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
render() { | ||
const { | ||
flag, | ||
text, | ||
linkText, | ||
renderToggleIcon, | ||
guidance1, | ||
guidance2 | ||
} = disclaimer; | ||
|
||
const { expanded } = this.state; | ||
const hidden = !expanded; | ||
const panelClass = classNames( | ||
'usa-banner-content usa-grid usa-accordion-content', | ||
{ | ||
hide: hidden | ||
} | ||
); | ||
|
||
return ( | ||
<div className="usa-banner usa-disclaimer disclaimer-no_sidebar"> | ||
<header className="grid"> | ||
<span className="usa-disclaimer-official"> | ||
{text} | ||
{flag && <img {...flag} />} | ||
<a | ||
className="action action-link action-secondary" | ||
aria-expanded={expanded} | ||
aria-controls={this.panelId} | ||
onClick={this.handleClick} | ||
> | ||
<span className="p1">{linkText}</span> | ||
{renderToggleIcon({ expanded })} | ||
</a> | ||
</span> | ||
</header> | ||
<div className={panelClass} id={this.panelId} aria-hidden={hidden}> | ||
{this.renderGuidance(guidance1)} | ||
{this.renderGuidance(guidance2)} | ||
</div> | ||
</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,41 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
import { header } from 'skin'; | ||
import LoginStore from '../../stores/login_store.js'; | ||
import HeaderLink from './header_link'; | ||
import Action from '../action.jsx'; | ||
|
||
const Header = () => { | ||
const loginLink = LoginStore.isLoggedIn() ? ( | ||
<HeaderLink> | ||
<Action href="/logout" label="Log out" type="outline"> | ||
Log out | ||
</Action> | ||
</HeaderLink> | ||
) : ( | ||
<HeaderLink> | ||
<Action href="/handshake" label="Login" type="outline"> | ||
Login | ||
</Action> | ||
</HeaderLink> | ||
); | ||
|
||
return ( | ||
<header className={classNames('header', 'header-no_sidebar')}> | ||
<div className="header-wrap"> | ||
{header.logo.render()} | ||
<nav className="header-side"> | ||
<ul className="nav"> | ||
{header.links.map((l, i) => ( | ||
<HeaderLink key={i} url={l.url} text={l.text} /> | ||
))} | ||
{loginLink} | ||
</ul> | ||
</nav> | ||
</div> | ||
</header> | ||
); | ||
}; | ||
|
||
export default Header; |
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,30 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import classNames from 'classnames'; | ||
|
||
const propTypes = { | ||
children: PropTypes.any, | ||
url: PropTypes.string, | ||
text: PropTypes.string, | ||
classes: PropTypes.array.isRequired | ||
}; | ||
|
||
const defaultProps = { | ||
classes: [] | ||
}; | ||
|
||
const HeaderLink = ({ children, url, text, classes }) => ( | ||
<li className="nav-link"> | ||
{children || ( | ||
<a href={url} className={classNames(classes)}> | ||
{text} | ||
</a> | ||
)} | ||
</li> | ||
); | ||
|
||
HeaderLink.propTypes = propTypes; | ||
|
||
HeaderLink.defaultProps = defaultProps; | ||
|
||
export default HeaderLink; |
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 @@ | ||
export { default } from './header'; |
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
File renamed without changes
File renamed without changes
Oops, something went wrong.