Skip to content

Commit

Permalink
fix(docz-theme-default): sidebar search
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Jul 11, 2018
1 parent dc3448a commit 8fd77ec
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
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'

Expand Down Expand Up @@ -42,20 +41,12 @@ interface SearchProps {
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>
<Input
type="text"
placeholder="Search here..."
onChange={ev => {
onSearch && onSearch(ev.target.value)
}}
/>
</Wrapper>
)
59 changes: 36 additions & 23 deletions packages/docz-theme-default/src/components/shared/Sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,17 @@ const Menus = styled('nav')`
${p =>
p.theme.mq({
paddingLeft: [10, 20],
paddingRight: [10, 20],
padding: ['0 10px', '0 20px'],
})};
`

const Empty = styled('div')`
flex: 1;
opacity: 0.6;
${p =>
p.theme.mq({
padding: ['0 20px', '0 30px'],
})};
`

Expand Down Expand Up @@ -263,27 +272,31 @@ export const Sidebar = () => (
<LogoText>{title}</LogoText>
)}
<Search showing={isDesktop || !on} onSearch={handleSearchDocs} />
<Menus>
{docsWithoutMenu.map(doc => (
<Link
key={doc.id}
to={doc.route}
onClick={handleSidebarToggle}
doc={doc}
>
{doc.name}
</Link>
))}
{menus.map(menu => (
<Menu
key={menu}
menu={menu}
docs={fromMenu(menu)}
sidebarToggle={handleSidebarToggle}
collapseAll={Boolean(state.searching)}
/>
))}
</Menus>
{docs.length < 1 ? (
<Empty>No document find.</Empty>
) : (
<Menus>
{docsWithoutMenu.map(doc => (
<Link
key={doc.id}
to={doc.route}
onClick={handleSidebarToggle}
doc={doc}
>
{doc.name}
</Link>
))}
{menus.map(menu => (
<Menu
key={menu}
menu={menu}
docs={fromMenu(menu)}
sidebarToggle={handleSidebarToggle}
collapseAll={Boolean(state.searching)}
/>
))}
</Menus>
)}
<Footer>
Built with
<FooterLink href="https://docz.site" target="_blank">
Expand Down

0 comments on commit 8fd77ec

Please sign in to comment.