-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docz-theme-default): add sidebar search
- Loading branch information
1 parent
4f10a6d
commit 8218dc1
Showing
13 changed files
with
324 additions
and
137 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
61 changes: 61 additions & 0 deletions
61
packages/docz-theme-default/src/components/shared/Sidebar/Search.tsx
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,61 @@ | ||
import * as React from 'react' | ||
import { SFC } from 'react' | ||
import { Value } from 'react-powerplug' | ||
import styled from 'react-emotion' | ||
import SearchIcon from 'react-feather/dist/icons/search' | ||
|
||
interface WrapperProps { | ||
showing: boolean | ||
} | ||
|
||
const Wrapper = styled('div')` | ||
display: flex; | ||
align-items: center; | ||
padding: 5px 30px; | ||
margin-bottom: 30px; | ||
border-top: 1px solid ${p => p.theme.colors.border}; | ||
border-bottom: 1px solid ${p => p.theme.colors.border}; | ||
opacity: ${(p: WrapperProps) => (p.showing ? 1 : 0)}; | ||
` | ||
|
||
const Icon = styled(SearchIcon)` | ||
stroke: ${p => p.theme.colors.sidebarText}; | ||
width: 20px; | ||
opacity: 0.5; | ||
` | ||
|
||
const Input = styled('input')` | ||
outline: none; | ||
width: 100%; | ||
padding: 10px; | ||
background: transparent; | ||
border: none; | ||
font-size: 14px; | ||
color: ${p => p.theme.colors.sidebarText}; | ||
` | ||
|
||
interface SearchProps { | ||
showing: boolean | ||
onSearch: (value: string) => void | ||
} | ||
|
||
export const Search: SFC<SearchProps> = ({ onSearch, showing }) => ( | ||
<Wrapper showing={showing}> | ||
<Icon /> | ||
<Value> | ||
{({ value, setValue }: any) => ( | ||
<Input | ||
type="text" | ||
value={value} | ||
placeholder="Search here..." | ||
onChange={ev => { | ||
const value = ev.target.value | ||
|
||
setValue(value) | ||
onSearch && onSearch(value) | ||
}} | ||
/> | ||
)} | ||
</Value> | ||
</Wrapper> | ||
) |
Oops, something went wrong.