From 3fa4f5ce643d77023ec180dfe5dd02ab333246de Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Tue, 17 Sep 2019 19:27:41 +0400 Subject: [PATCH] Add search row --- .../Header/component/SafeListHeader/index.jsx | 2 +- src/components/Sidebar/SafeList.jsx | 4 +- src/components/Sidebar/index.jsx | 55 +++++++++++++++---- src/components/Sidebar/style.js | 42 +++++++++++++- .../safe/components/Balances/Tokens/index.jsx | 4 +- .../Tokens/screens/TokenList/index.jsx | 4 +- 6 files changed, 94 insertions(+), 17 deletions(-) diff --git a/src/components/Header/component/SafeListHeader/index.jsx b/src/components/Header/component/SafeListHeader/index.jsx index d7d5f5cf..c7df187b 100644 --- a/src/components/Header/component/SafeListHeader/index.jsx +++ b/src/components/Header/component/SafeListHeader/index.jsx @@ -48,7 +48,7 @@ const SafeListHeader = ({ safesCount }: Props) => { {safesCount} - {isOpen ? : } + {isOpen ? : } ) diff --git a/src/components/Sidebar/SafeList.jsx b/src/components/Sidebar/SafeList.jsx index a278c628..9527aa87 100644 --- a/src/components/Sidebar/SafeList.jsx +++ b/src/components/Sidebar/SafeList.jsx @@ -10,7 +10,9 @@ import Link from '~/components/layout/Link' import Hairline from '~/components/layout/Hairline' import Paragraph from '~/components/layout/Paragraph' import Identicon from '~/components/Identicon' -import { mediumFontSize, sm, secondary, primary } from '~/theme/variables' +import { + mediumFontSize, sm, secondary, primary, +} from '~/theme/variables' import { shortVersionOf } from '~/logic/wallets/ethAddresses' import { type Safe } from '~/routes/safe/store/models/safe' import { SAFELIST_ADDRESS } from '~/routes/routes' diff --git a/src/components/Sidebar/index.jsx b/src/components/Sidebar/index.jsx index d8432158..3901e29e 100644 --- a/src/components/Sidebar/index.jsx +++ b/src/components/Sidebar/index.jsx @@ -1,8 +1,16 @@ // @flow import * as React from 'react' import { List } from 'immutable' +import SearchBar from 'material-ui-search-bar' import { connect } from 'react-redux' +import ClickAwayListener from '@material-ui/core/ClickAwayListener' import Drawer from '@material-ui/core/Drawer' +import SearchIcon from '@material-ui/icons/Search' +import Divider from '~/components/layout/Divider' +import Button from '~/components/layout/Button' +import Spacer from '~/components/Spacer' +import Hairline from '~/components/layout/Hairline' +import Row from '~/components/layout/Row' import { type Safe } from '~/routes/safe/store/models/safe' import { safesListSelector } from '~/routes/safeList/store/selectors' import useSidebarStyles from './style' @@ -29,22 +37,49 @@ const Sidebar = ({ children, safes }: SidebarProps) => { const [isOpen, setIsOpen] = useState(false) const classes = useSidebarStyles() + const searchClasses = { + input: classes.searchInput, + root: classes.searchRoot, + iconButton: classes.searchIconInput, + searchContainer: classes.searchContainer, + } + const toggleSidebar = () => { setIsOpen((prevIsOpen) => !prevIsOpen) } + const handleEsc = (e: React.KeyboardEvent) => { + if (e.keyCode === 27) { + toggleSidebar() + } + } + return ( - -
- - + + +
+ + + } /> + + + + + + + + + + {children} ) diff --git a/src/components/Sidebar/style.js b/src/components/Sidebar/style.js index 73945689..010086d5 100644 --- a/src/components/Sidebar/style.js +++ b/src/components/Sidebar/style.js @@ -1,6 +1,8 @@ // @flow import { makeStyles } from '@material-ui/core/styles' -import { headerHeight } from '~/theme/variables' +import { + xs, mediumFontSize, secondaryText, md, headerHeight, +} from '~/theme/variables' const sidebarWidth = '400px' @@ -14,6 +16,44 @@ const useSidebarStyles = makeStyles({ headerPlaceholder: { height: headerHeight, // for some reason it didn't want to work with an imported variable 🤔 }, + addSafeBtn: { + fontSize: mediumFontSize, + }, + searchIcon: { + color: secondaryText, + paddingLeft: md, + }, + searchInput: { + backgroundColor: 'transparent', + lineHeight: 'initial', + padding: 0, + '& > input::placeholder': { + letterSpacing: '-0.5px', + fontSize: mediumFontSize, + color: 'black', + }, + '& > input': { + letterSpacing: '-0.5px', + }, + }, + searchContainer: { + width: '180px', + marginLeft: xs, + marginRight: xs, + }, + searchRoot: { + letterSpacing: '-0.5px', + border: 'none', + boxShadow: 'none', + '& > button': { + display: 'none', + }, + }, + searchIconInput: { + '&:hover': { + backgroundColor: 'transparent !important', + }, + }, }) export default useSidebarStyles diff --git a/src/routes/safe/components/Balances/Tokens/index.jsx b/src/routes/safe/components/Balances/Tokens/index.jsx index b5ac8569..70f80291 100644 --- a/src/routes/safe/components/Balances/Tokens/index.jsx +++ b/src/routes/safe/components/Balances/Tokens/index.jsx @@ -40,7 +40,7 @@ const Tokens = (props: Props) => { } = props return ( - + <> Manage Tokens @@ -72,7 +72,7 @@ const Tokens = (props: Props) => { tokens={tokens} /> )} - + ) } diff --git a/src/routes/safe/components/Balances/Tokens/screens/TokenList/index.jsx b/src/routes/safe/components/Balances/Tokens/screens/TokenList/index.jsx index dd68c257..ad39c8cc 100644 --- a/src/routes/safe/components/Balances/Tokens/screens/TokenList/index.jsx +++ b/src/routes/safe/components/Balances/Tokens/screens/TokenList/index.jsx @@ -124,7 +124,7 @@ class Tokens extends React.Component { const filteredTokens = filterBy(filter, tokens) return ( - + <> @@ -179,7 +179,7 @@ class Tokens extends React.Component { ) })} - + ) } }