Pass search query and handler in props
This commit is contained in:
parent
a5ad47a4d8
commit
d5eab71f3a
|
@ -9,7 +9,9 @@ import contentStyle from '../stylesheets/content.scss'
|
||||||
export default class Blog extends Component {
|
export default class Blog extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
isLoading: PropTypes.bool.isRequired,
|
isLoading: PropTypes.bool.isRequired,
|
||||||
posts: PropTypes.arrayOf(PropTypes.object).isRequired
|
posts: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
|
searchString: PropTypes.string.isRequired,
|
||||||
|
handleChange: PropTypes.func.isRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
@ -41,7 +43,7 @@ export default class Blog extends Component {
|
||||||
<div className={`${contentStyle.content}`} id="blog" role="region" aria-label="Blog posts">
|
<div className={`${contentStyle.content}`} id="blog" role="region" aria-label="Blog posts">
|
||||||
<div className={styles.headerContainer}>
|
<div className={styles.headerContainer}>
|
||||||
<Header header={'Blog'} role="heading" aria-level="2"/>
|
<Header header={'Blog'} role="heading" aria-level="2"/>
|
||||||
<SearchBox />
|
<SearchBox searchString={this.props.searchString} handleChange={this.props.handleChange} />
|
||||||
</div>
|
</div>
|
||||||
<div className={`${styles.postsList}`} role="list">
|
<div className={`${styles.postsList}`} role="list">
|
||||||
{postsHTML}
|
{postsHTML}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Navbar, Header } from '.'
|
||||||
import '../stylesheets/globals.scss'
|
import '../stylesheets/globals.scss'
|
||||||
import contentStyle from '../stylesheets/content.scss'
|
import contentStyle from '../stylesheets/content.scss'
|
||||||
|
|
||||||
export const NotFoundPage = (props) => {
|
const NotFoundPage = (props) => {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Navbar config={props.config}/>
|
<Navbar config={props.config}/>
|
||||||
|
|
|
@ -5,14 +5,17 @@ import styles from './SearchBox.scss'
|
||||||
|
|
||||||
export default class SearchBox extends Component {
|
export default class SearchBox extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
query: PropTypes.string
|
handleChange: PropTypes.func.isRequired,
|
||||||
|
searchString: PropTypes.string
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
return (
|
return (
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
<input placeholder='Search' className={styles.search} type="text" />
|
<input placeholder='Search' className={styles.search} type="text" value={this.props.searchString} onChange={this.props.handleChange}/>
|
||||||
<i className="fa fa-search"></i>
|
<span>
|
||||||
|
<i className={`fa fa-search ${styles.icon}`}></i>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
border: 2px $black;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.search {
|
.search {
|
||||||
|
@ -15,11 +14,10 @@
|
||||||
width: 20px;
|
width: 20px;
|
||||||
color: $black;
|
color: $black;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: 100;
|
|
||||||
letter-spacing: 2px;
|
letter-spacing: 2px;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
background: $body;
|
background: $white;
|
||||||
transition: width 0.4s ease;
|
transition: width 0.4s ease;
|
||||||
outline: none;
|
outline: none;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
@ -27,7 +25,7 @@
|
||||||
&:focus{ width: 300px; }
|
&:focus{ width: 300px; }
|
||||||
}
|
}
|
||||||
|
|
||||||
i{
|
.icon{
|
||||||
position: relative;
|
position: relative;
|
||||||
left: -37px;
|
left: -37px;
|
||||||
color: $black;
|
color: $black;
|
||||||
|
|
|
@ -12,13 +12,18 @@ export default class BlogContainer extends Component {
|
||||||
super(props)
|
super(props)
|
||||||
this.state = {
|
this.state = {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
posts: props.posts
|
posts: props.posts,
|
||||||
|
searchString: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleChange (event) {
|
||||||
|
this.setState({ searchString: event.target.value })
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
return (
|
return (
|
||||||
<Blog isLoading={ this.state.isLoading } posts={ this.state.posts } />
|
<Blog isLoading={ this.state.isLoading } posts={ this.state.posts } searchString={this.state.searchString} handleChange={this.handleChange.bind(this)} />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,13 +11,11 @@ export default class NotFoundContainer extends Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
super(props)
|
super(props)
|
||||||
let data
|
let data
|
||||||
|
if (typeof window === 'undefined') {
|
||||||
// eslint-disable-next-line no-undef
|
data = props.staticContext.context
|
||||||
if (__isBrowser__) {
|
} else {
|
||||||
data = window.__INITIAL_DATA__
|
data = window.__INITIAL_DATA__
|
||||||
delete window.__INITIAL_DATA__
|
delete window.__INITIAL_DATA__
|
||||||
} else {
|
|
||||||
data = props.staticContext.context
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
|
Loading…
Reference in New Issue