add search field and grid icons

This commit is contained in:
Jonathan Rainville 2019-04-25 14:01:41 -04:00
parent 405ea1c814
commit 20dff143d2
No known key found for this signature in database
GPG Key ID: 5F4630B759727D9C
1 changed files with 26 additions and 19 deletions

View File

@ -7,11 +7,7 @@ import PropTypes from 'prop-types'
import {useProjectData} from "./hooks"; import {useProjectData} from "./hooks";
import Loading from "../base/Loading"; import Loading from "../base/Loading";
import Grid from '@material-ui/core/Grid'; import Grid from '@material-ui/core/Grid';
import Radio from '@material-ui/core/Radio';
import RadioGroup from '@material-ui/core/RadioGroup';
import FormControlLabel from '@material-ui/core/FormControlLabel';
import FormControl from '@material-ui/core/FormControl'; import FormControl from '@material-ui/core/FormControl';
import FormLabel from '@material-ui/core/FormLabel';
import Typography from "@material-ui/core/Typography"; import Typography from "@material-ui/core/Typography";
import Card from '@material-ui/core/Card'; import Card from '@material-ui/core/Card';
import CardActions from '@material-ui/core/CardActions'; import CardActions from '@material-ui/core/CardActions';
@ -20,6 +16,11 @@ import CardMedia from '@material-ui/core/CardMedia';
import Button from '@material-ui/core/Button'; import Button from '@material-ui/core/Button';
import CardActionArea from '@material-ui/core/CardActionArea'; import CardActionArea from '@material-ui/core/CardActionArea';
import LinearProgress from '@material-ui/core/LinearProgress'; import LinearProgress from '@material-ui/core/LinearProgress';
import TextField from '@material-ui/core/TextField';
import InputAdornment from '@material-ui/core/InputAdornment';
import SearchIcon from '@material-ui/icons/Search';
import ListIcon from '@material-ui/icons/Reorder';
import DashboardIcon from '@material-ui/icons/Dashboard';
import defaultProjectImage from '../../images/default-project-img.png'; import defaultProjectImage from '../../images/default-project-img.png';
import newProjectImage from '../../images/new-project.png'; import newProjectImage from '../../images/new-project.png';
@ -34,6 +35,12 @@ const styles = theme => ({
margin: '1.75rem 4.5rem', margin: '1.75rem 4.5rem',
...theme.typography.body1 ...theme.typography.body1
}, },
filters: {
float: 'right'
},
search: {
height: 36
},
title: { title: {
fontSize: '20px', fontSize: '20px',
textAlign: 'center', textAlign: 'center',
@ -116,7 +123,7 @@ function ProjectCard({classes, project}) {
} }
function Projects({projectAddedEvents, classes}) { function Projects({projectAddedEvents, classes}) {
const [sortType, setSortType] = useState(SORT_TYPES.date); const [sortType, _setSortType] = useState(SORT_TYPES.date);
const projects = projectAddedEvents.map(event => { const projects = projectAddedEvents.map(event => {
return Object.assign({projectId: event.returnValues.idProject}, useProjectData(event.returnValues.idProject, '', projectAddedEvents)); return Object.assign({projectId: event.returnValues.idProject}, useProjectData(event.returnValues.idProject, '', projectAddedEvents));
@ -125,25 +132,25 @@ function Projects({projectAddedEvents, classes}) {
let sortFunction = (sortType === SORT_TYPES.name) ? sortByTitle : sortByDate; let sortFunction = (sortType === SORT_TYPES.name) ? sortByTitle : sortByDate;
projects.sort(sortFunction); projects.sort(sortFunction);
console.log(projects);
return (<div className={classes.root}> return (<div className={classes.root}>
<Typography className={classes.title} component="h2" gutterBottom>All projects</Typography> <Typography className={classes.title} component="h2" gutterBottom>All projects</Typography>
{projects.length === 0 && <Loading/>} {projects.length === 0 && <Loading/>}
{projects.length > 0 && {projects.length > 0 &&
<Fragment> <Fragment>
<FormControl component="fieldset" className={classes.formControl}> <div className={classes.filters}>
<FormLabel component="legend">Sort by</FormLabel> <FormControl>
<RadioGroup <TextField
aria-label="Sort" variant="outlined"
name="sort" placeholder="Filter by tags"
className={classes.group} InputProps={{
value={sortType} className: classes.search,
onChange={(e, value) => setSortType(value)} startAdornment: <InputAdornment position="start"><SearchIcon/></InputAdornment>,
> }}
<FormControlLabel value={SORT_TYPES.date} control={<Radio color="default"/>} label="Date"/> />
<FormControlLabel value={SORT_TYPES.name} control={<Radio color="default"/>} label="Name"/> </FormControl>
</RadioGroup> <DashboardIcon color="disabled" fontSize="large"/>
</FormControl> <ListIcon color="disabled" fontSize="large"/>
</div>
<Grid container spacing={40}> <Grid container spacing={40}>
{projects.map((project, index) => { {projects.map((project, index) => {
if (!project.manifest) { if (!project.manifest) {