Skip to content

Commit

Permalink
feat: Add the search input to the sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Jun 18, 2020
1 parent ac158ad commit ff4faea
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/components/Sidebar.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
import React from 'react';
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { Link } from 'gatsby';
import cx from 'classnames';
import Logo from './Logo';
import Navigation from './Navigation';
import SearchInput from './SearchInput';
import styles from './Sidebar.module.scss';

const Sidebar = ({ className }) => (
<aside className={cx(styles.sidebar, className)}>
<Link to="/">
<Logo className={styles.logo} />
</Link>
<Navigation className={styles.nav} />
</aside>
);
const Sidebar = ({ className }) => {
const [searchTerm, setSearchTerm] = useState('');

return (
<aside className={cx(styles.sidebar, className)}>
<Link to="/">
<Logo className={styles.logo} />
</Link>
<SearchInput
className={styles.searchInput}
placeholder="Search developer docs"
onChange={(e) => setSearchTerm(e.target.value)}
value={searchTerm}
/>
<Navigation className={styles.nav} searchTerm={searchTerm} />
</aside>
);
};

Sidebar.propTypes = {
className: PropTypes.string,
Expand Down
4 changes: 4 additions & 0 deletions src/components/Sidebar.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@
.nav {
margin-top: 1rem;
}

.searchInput {
margin: 1rem 0;
}

0 comments on commit ff4faea

Please sign in to comment.