Skip to content

Commit

Permalink
feat(TopBar): add responsive search input
Browse files Browse the repository at this point in the history
  • Loading branch information
HipsterBrown committed May 3, 2018
1 parent eb0cf44 commit 74c02fa
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class Header extends React.Component {
`}
</style>
<div id="top" />
<TopBar className={className} LoggedInUser={this.props.LoggedInUser} />
<TopBar className={className} LoggedInUser={this.props.LoggedInUser} showSearch={this.props.showSearch} />
</header>
);
}
Expand Down
46 changes: 43 additions & 3 deletions src/components/TopBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ const logo = '/static/images/opencollective-icon.svg';
class TopBar extends React.Component {

static propTypes = {
LoggedInUser: PropTypes.object
LoggedInUser: PropTypes.object.isRequired,
showSearch: PropTypes.bool,
}

static defaultProps = {
showSearch: true,
}

constructor(props) {
Expand Down Expand Up @@ -58,13 +63,12 @@ class TopBar extends React.Component {
}

render() {
const { className, LoggedInUser, intl } = this.props;
const { className, LoggedInUser, intl, showSearch } = this.props;

return (
<div className={classNames(className, 'TopBar')}>
<style jsx>{`
.TopBar {
height: 6rem;
width: 100%;
position: relative;
}
Expand Down Expand Up @@ -126,8 +130,44 @@ class TopBar extends React.Component {
margin-right: 0;
padding-right: 0;
}
.topbar-search-form {
padding: 1rem;
width: 100%;
}
.topbar-search-input {
background-color: var(--silver-four);
border: none;
border-radius: 2px;
font-size: 1.5rem;
letter-spacing: 0.1rem;
padding: 1rem;
width: 100%;
}
@media(min-width: 500px) {
.topbar-search-form {
display: inline-block;
max-width: 30rem;
min-width: 10rem;
width: 40%;
}
.topbar-search-input {
font-size: 1.2rem;
padding: 0.5rem;
}
}
`}</style>
<a href="/" title={intl.formatMessage(this.messages['menu.homepage'])}><img src={logo} width="40" height="40" className="logo" alt="Open Collective logo" /></a>

{showSearch && (
<form action="/search" method="GET" className="topbar-search-form">
<input type="search" name="q" placeholder="Search Open Collective" className="topbar-search-input" />
</form>
)}

<div className="nav">
<ul className="mediumScreenOnly">
<li><a className="menuItem" href="/learn-more"><FormattedMessage id="menu.howItWorks" defaultMessage="How it works" /></a></li>
Expand Down
1 change: 1 addition & 0 deletions src/pages/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class SearchPage extends React.Component {
title="Search"
className={loadingUserLogin ? 'loading' : ''}
LoggedInUser={LoggedInUser}
showSearch={false}
/>
<Body>
<Grid>
Expand Down

0 comments on commit 74c02fa

Please sign in to comment.