-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #582 from kitspace/ke/search-input
Put search input on front page, make it persist query
- Loading branch information
Showing
25 changed files
with
261 additions
and
363 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 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 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 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 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 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,44 @@ | ||
import React, { useState } from 'react' | ||
import { useRouter } from 'next/router' | ||
import { Form, Icon, Input } from 'semantic-ui-react' | ||
|
||
import { useSearchQuery } from '@contexts/SearchContext' | ||
|
||
const NavSearchInput = () => { | ||
const { push } = useRouter() | ||
const { query: contextQuery, updateQuery: updateContextQuery } = useSearchQuery() | ||
const [query, setQuery] = useState(contextQuery) | ||
|
||
const handleSubmit = () => { | ||
updateContextQuery(query) | ||
const path = `/search?q=${encodeURIComponent(query)}` | ||
push(path) | ||
} | ||
|
||
return ( | ||
<Form data-cy="search-form" onSubmit={handleSubmit}> | ||
<Form.Field | ||
fluid | ||
autoComplete="off" | ||
control={Input} | ||
data-cy="search-field" | ||
icon={ | ||
<Icon | ||
circular | ||
disabled={!query} | ||
link={!!query} | ||
name="search" | ||
onClick={handleSubmit} | ||
/> | ||
} | ||
id="search-field" | ||
name="query" | ||
placeholder="Search for projects" | ||
value={query ?? ''} | ||
onChange={e => setQuery(e.target.value)} | ||
/> | ||
</Form> | ||
) | ||
} | ||
|
||
export default NavSearchInput |
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
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 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,29 @@ | ||
@import './colors.scss'; | ||
|
||
.searchInput { | ||
display: block; | ||
max-width: min(600px, 90%); | ||
height: 60px; | ||
border: 1px solid $lightlightgray; | ||
margin: 0 auto !important; | ||
margin-bottom: 48px !important; | ||
box-sizing: border-box; | ||
border-radius: 4px; | ||
} | ||
|
||
.searchIcon { | ||
margin-right: 7px !important; | ||
} | ||
|
||
main #search-field::placeholder { | ||
color: $silver-chalice !important; | ||
font-size: 18px; | ||
} | ||
|
||
main #search-field { | ||
height: 60px; | ||
} | ||
|
||
main #search-field:focus { | ||
border: 1px solid $lightlightgray !important; | ||
} |
Oops, something went wrong.