|
| 1 | +import clsx from 'clsx' |
| 2 | +import React, { useContext, useState } from 'react' |
| 3 | + |
| 4 | +import { fade, makeStyles, Button, Tooltip, InputBase } from '@material-ui/core' |
| 5 | + |
| 6 | +import { |
| 7 | + MoreVert as IconMore, |
| 8 | + Tune as IconFilter, |
| 9 | + // ArrowDropDown as IconDropDown, |
| 10 | + Add as IconNew, |
| 11 | + Search as IconSearch, |
| 12 | +} from '@material-ui/icons' |
| 13 | + |
| 14 | +// import usersListContext from './usersListContext' |
| 15 | + |
| 16 | +const DashboardActions = () => { |
| 17 | + const classes = useStyles() |
| 18 | + const [search, setSearch] = useState('') |
| 19 | + // const { filter } = useContext(usersListContext) |
| 20 | + |
| 21 | + const handleChangeSearchInput = event => { |
| 22 | + setSearch(event.target.value) |
| 23 | + } |
| 24 | + |
| 25 | + return ( |
| 26 | + <div className={classes.root}> |
| 27 | + <div className={classes.search}> |
| 28 | + <div className={classes.searchIcon}> |
| 29 | + <IconSearch /> |
| 30 | + </div> |
| 31 | + <InputBase |
| 32 | + placeholder="Search…" |
| 33 | + classes={{ |
| 34 | + root: classes.searchInputRoot, |
| 35 | + input: clsx( |
| 36 | + classes.searchInputInput, |
| 37 | + search && classes.searchInputInputActive, |
| 38 | + ), |
| 39 | + }} |
| 40 | + inputProps={{ 'aria-label': 'search' }} |
| 41 | + onChange={handleChangeSearchInput} |
| 42 | + /> |
| 43 | + </div> |
| 44 | + <Tooltip title="Create new"> |
| 45 | + <Button color="secondary"> |
| 46 | + <IconNew className={classes.iconNew} /> |
| 47 | + New |
| 48 | + </Button> |
| 49 | + </Tooltip> |
| 50 | + <Tooltip title="Filter"> |
| 51 | + <Button color="secondary"> |
| 52 | + <IconFilter /> |
| 53 | + </Button> |
| 54 | + </Tooltip> |
| 55 | + <Tooltip title="More actions"> |
| 56 | + <Button color="secondary"> |
| 57 | + <IconMore /> |
| 58 | + </Button> |
| 59 | + </Tooltip> |
| 60 | + </div> |
| 61 | + ) |
| 62 | +} |
| 63 | + |
| 64 | +const useStyles = makeStyles(theme => ({ |
| 65 | + root: { |
| 66 | + color: theme.palette.secondary.main, |
| 67 | + }, |
| 68 | + iconNew: { |
| 69 | + marginRight: 5, |
| 70 | + }, |
| 71 | + search: { |
| 72 | + position: 'relative', |
| 73 | + display: 'inline-block', |
| 74 | + borderRadius: theme.shape.borderRadius, |
| 75 | + backgroundColor: fade(theme.palette.common.white, 0), |
| 76 | + '&:hover': { |
| 77 | + // backgroundColor: fade(theme.palette.common.white, 0.5), |
| 78 | + backgroundColor: 'rgba(140, 209, 54, 0.04)', |
| 79 | + }, |
| 80 | + marginLeft: 0, |
| 81 | + width: '100%', |
| 82 | + [theme.breakpoints.up('sm')]: { |
| 83 | + marginLeft: theme.spacing(1), |
| 84 | + width: 'auto', |
| 85 | + }, |
| 86 | + }, |
| 87 | + searchIcon: { |
| 88 | + padding: theme.spacing(0, 2), |
| 89 | + height: '100%', |
| 90 | + position: 'absolute', |
| 91 | + pointerEvents: 'none', |
| 92 | + display: 'flex', |
| 93 | + alignItems: 'center', |
| 94 | + justifyContent: 'center', |
| 95 | + }, |
| 96 | + searchInputRoot: { |
| 97 | + color: 'inherit', |
| 98 | + }, |
| 99 | + searchInputInput: { |
| 100 | + padding: theme.spacing(1, 1, 1, 0), |
| 101 | + // vertical padding + font size from searchIcon |
| 102 | + paddingLeft: `calc(1em + ${theme.spacing(4)}px)`, |
| 103 | + transition: theme.transitions.create('width'), |
| 104 | + width: '100%', |
| 105 | + [theme.breakpoints.up('sm')]: { |
| 106 | + width: '12ch', |
| 107 | + '&:focus, &.active': { |
| 108 | + width: '20ch', |
| 109 | + }, |
| 110 | + }, |
| 111 | + }, |
| 112 | +})) |
| 113 | + |
| 114 | +export default DashboardActions |
0 commit comments