diff --git a/package.json b/package.json index 07226f9..0ff76fd 100644 --- a/package.json +++ b/package.json @@ -76,6 +76,7 @@ "case-sensitive-paths-webpack-plugin": "2.2.0", "chai": "^4.1.0", "chart.js": "^2.7.3", + "classnames": "^2.2.6", "cryptocurrency-icons": "^0.9.3", "css-loader": "1.0.0", "cytoscape": "^3.3.0", @@ -190,8 +191,18 @@ "react-app" ], "plugins": [ - ["@babel/plugin-proposal-decorators", { "legacy": true }], - ["@babel/plugin-proposal-class-properties", { "loose": true }], + [ + "@babel/plugin-proposal-decorators", + { + "legacy": true + } + ], + [ + "@babel/plugin-proposal-class-properties", + { + "loose": true + } + ], [ "@babel/plugin-transform-runtime", { diff --git a/public/images/favorite-sprite.png b/public/images/favorite-sprite.png new file mode 100644 index 0000000..21ecf1b Binary files /dev/null and b/public/images/favorite-sprite.png differ diff --git a/src/components/projects/Projects.jsx b/src/components/projects/Projects.jsx index 3d65462..26a3e58 100644 --- a/src/components/projects/Projects.jsx +++ b/src/components/projects/Projects.jsx @@ -21,6 +21,12 @@ 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 Table from '@material-ui/core/Table'; +import TableBody from '@material-ui/core/TableBody'; +import TableCell from '@material-ui/core/TableCell'; +import TableHead from '@material-ui/core/TableHead'; +import TableRow from '@material-ui/core/TableRow'; +import classnames from 'classnames'; import defaultProjectImage from '../../images/default-project-img.png'; import newProjectImage from '../../images/new-project.png'; @@ -30,50 +36,91 @@ const SORT_TYPES = { name: 'name' } -const styles = theme => ({ - root: { - margin: '1.75rem 4.5rem', - ...theme.typography.body1 - }, - filters: { - float: 'right' - }, - search: { - height: 36 - }, - title: { - fontSize: '20px', - textAlign: 'center', - fontWeight: 500 - }, - media: { - height: 235, - position: 'relative' - }, - avatar: { - position: 'absolute', - top: 26, - left: 26 - }, - 'card-title': { - fontSize: '20px' - }, - 'card-content': { - fontSize: '16px' - }, - 'card-actions': { - float: 'right' - }, - progress: { - height: 10 - }, - 'new-project-img': { - textAlign: 'center', - margin: 0, - paddingTop: 115, - paddingBottom: 43 - } -}) +const cardAbsolutesDistance = 26; + +const styles = theme => { + return ({ + root: { + margin: '1.75rem 4.5rem', + ...theme.typography.body1 + }, + filters: { + float: 'right' + }, + search: { + height: 36 + }, + formatBtn: { + cursor: 'pointer', + '&:hover, &.active': { + color: 'black' + } + }, + title: { + fontSize: '20px', + textAlign: 'center', + fontWeight: 500 + }, + media: { + height: 235, + position: 'relative' + }, + avatarGrid: { + position: 'absolute', + top: cardAbsolutesDistance, + left: cardAbsolutesDistance + }, + 'card-title': { + fontSize: '20px' + }, + 'card-content': { + fontSize: '16px' + }, + 'card-actions': { + float: 'right' + }, + progress: { + height: 10 + }, + 'new-project-img': { + textAlign: 'center', + margin: 0, + paddingTop: 115, + paddingBottom: 43 + }, + nameCell: { + fontSize: 18 + }, + darkRow: { + backgroundColor: theme.palette.common.grey + }, + addProjectRow: { + borderTop: '0.25px solid ' + theme.palette.text.grey, + cursor: 'pointer', + '& td': { + paddingTop: 35 + } + }, + favorite: { + display: 'inline-block', + backgroundImage: 'url("/images/favorite-sprite.png")', + backgroundRepeat: 'no-repeat', + backgroundPosition: 'bottom', + width: 30, + height: 27, + cursor: 'pointer', + '&:hover, &.isFavorite': { + backgroundPosition: 'top' + } + }, + cardFavorite: { + position: 'absolute', + top: cardAbsolutesDistance, + right: cardAbsolutesDistance, + zIndex: 9000 + } + }) +} function sortByTitle(a, b) { if (!a.manifest || !b.manifest) { @@ -90,9 +137,14 @@ function sortByDate(a, b) { return 1; } -function ProjectCard({classes, project}) { +function Favorite({classes, setFavorites, favorites, projectId, className}) { + return ( setFavorites({...favorites, [projectId]: !favorites[projectId]})}/>); +} + +function ProjectCard({classes, project, favorites, setFavorites}) { return ( - + { if (e.target.className.indexOf(classes.favorite) > -1) { e.preventDefault() } }}> Delegate: {project.manifest.creator} {/*TODO check if that really is the delegate*/} - {project.manifest.avatar && avatar} + {project.manifest.avatar && avatar} + @@ -122,8 +175,98 @@ function ProjectCard({classes, project}) { ) } -function Projects({projectAddedEvents, classes}) { +function GridView({classes, projects, favorites, setFavorites}) { + return ( + {projects.map((project, index) => { + if (!project.manifest) { + return '' + } + return ( + + ); + })} + + + +

new project

+ Add your own project +
+
+
+
) +} + +const CustomTableCell = withStyles(theme => ({ + head: { + color: theme.palette.text.grey, + fontSize: 15, + border: 0 + }, + body: { + fontSize: 16, + border: 0, + height: 80 + } +}))(TableCell); + +function ListView({classes, projects, history, favorites, setFavorites}) { + let rowCounter = -1; + return ( + + +   + Project name + Description + Funding details + Delegate +   +   + + + + {projects.map((project, index) => { + rowCounter++; + if (!project.manifest) { + return '' + } + return ( + + + {project.manifest.avatar && + avatar} + + {project.manifest.title} + {project.manifest.description} + 76% of 2.055 ETH
3 funders
+ {project.manifest.creator} + + + + + + +
+ ) + })} + history.push('/create-project/')}> + + add project + + Add your own project + + + + + + +
+
) +} + +function Projects({projectAddedEvents, classes, history}) { + const [favorites, setFavorites] = useState({}); const [sortType, _setSortType] = useState(SORT_TYPES.date); + const [isGridView, setIsGridView] = useState(true); const projects = projectAddedEvents.map(event => { return Object.assign({projectId: event.returnValues.idProject}, useProjectData(event.returnValues.idProject, '', projectAddedEvents)); @@ -134,7 +277,9 @@ function Projects({projectAddedEvents, classes}) { return (
All projects + {projects.length === 0 && } + {projects.length > 0 &&
@@ -148,27 +293,13 @@ function Projects({projectAddedEvents, classes}) { }} /> - - + + setIsGridView(true)}/> + setIsGridView(false)}/>
- - {projects.map((project, index) => { - if (!project.manifest) { - return '' - } - return ( - - ); - })} - - - -

new project

- Add your own project -
-
-
-
+ + {!isGridView && ListView({classes, projects, history, favorites, setFavorites})} + {isGridView && GridView({classes, projects, favorites, setFavorites})}
}
) diff --git a/src/index.js b/src/index.js index badf425..eab8df2 100644 --- a/src/index.js +++ b/src/index.js @@ -12,6 +12,14 @@ const theme = createMuiTheme({ useNextVariants: true, fontFamily: ['Inter', '-apple-system', 'BlinkMacSystemFont', "Segoe UI", 'Roboto', "Helvetica Neue", 'Arial', "Noto Sans", 'sans-serif', "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"].join(','), }, + palette: { + common: { + grey: '#F5F7F8' + }, + text: { + grey: '#939BA1' + } + } }); render(