scratch-www/src/views/preview/stats.jsx

52 lines
1.4 KiB
React
Raw Normal View History

2018-09-25 17:16:02 -04:00
const PropTypes = require('prop-types');
const React = require('react');
const FlexRow = require('../../components/flex-row/flex-row.jsx');
const classNames = require('classnames');
const projectShape = require('./projectshape.jsx').projectShape;
require('./stats.scss');
2018-09-25 17:16:02 -04:00
const Stats = props => (
<FlexRow className="stats noselect">
2018-09-25 17:16:02 -04:00
<div
className={classNames('project-loves', {loved: props.loved})}
key="loves"
onClick={props.onLoveClicked}
>
2018-12-18 09:50:17 -05:00
{Math.max(0, props.loveCount)}
2018-09-25 17:16:02 -04:00
</div>
<div
className={classNames('project-favorites', {favorited: props.faved})}
key="favorites"
onClick={props.onFavoriteClicked}
>
2018-12-18 09:50:17 -05:00
{Math.max(0, props.favoriteCount)}
2018-09-25 17:16:02 -04:00
</div>
<div
className="project-remixes"
key="remixes"
>
2018-12-18 09:50:17 -05:00
{props.projectInfo.stats.remixes}
2018-09-25 17:16:02 -04:00
</div>
<div
className="project-views"
key="views"
>
{props.projectInfo.stats.views}
2018-09-25 17:16:02 -04:00
</div>
</FlexRow>
);
Stats.propTypes = {
faved: PropTypes.bool,
favoriteCount: PropTypes.number,
loveCount: PropTypes.number,
loved: PropTypes.bool,
onFavoriteClicked: PropTypes.func,
onLoveClicked: PropTypes.func,
projectInfo: projectShape
};
module.exports = Stats;