Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
Allow header disclaimer and logo to be skinned
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathaningram committed Oct 17, 2017
1 parent 10cee55 commit 309f130
Show file tree
Hide file tree
Showing 15 changed files with 264 additions and 251 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ static_src/test/server/fixtures/
/static_src/components/button.jsx
/static_src/components/confirmation_box.jsx
/static_src/components/create_service_instance.jsx
/static_src/components/disclaimer.jsx
/static_src/components/dropdown.jsx
/static_src/components/home.jsx
/static_src/components/login.jsx
Expand Down
101 changes: 0 additions & 101 deletions static_src/components/disclaimer.jsx

This file was deleted.

54 changes: 0 additions & 54 deletions static_src/components/header.jsx

This file was deleted.

84 changes: 84 additions & 0 deletions static_src/components/header/disclaimer.js
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>
);
}
}
41 changes: 41 additions & 0 deletions static_src/components/header/header.js
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;
30 changes: 30 additions & 0 deletions static_src/components/header/header_link.js
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;
1 change: 1 addition & 0 deletions static_src/components/header/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './header';
25 changes: 0 additions & 25 deletions static_src/components/header_link.jsx

This file was deleted.

4 changes: 2 additions & 2 deletions static_src/components/main_container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import React from 'react';
import PropTypes from 'prop-types';
import userProvider from './user_provider.jsx';
import Disclaimer from './disclaimer.jsx';
import Disclaimer from './header/disclaimer';
import Footer from './footer.jsx';
import GlobalErrorContainer from './global_error_container.jsx';
import Header from './header.jsx';
import Header from './header';
import LoginStore from '../stores/login_store.js';
import OrgStore from '../stores/org_store.js';
import SpaceStore from '../stores/space_store.js';
Expand Down
Loading

0 comments on commit 309f130

Please sign in to comment.