From aa0470a3076f5ac65a0311c76e58254547f3eae0 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 3 Nov 2018 17:29:49 +0100 Subject: begin client --- client/common/keyframes.component.js | 95 ++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 client/common/keyframes.component.js (limited to 'client/common/keyframes.component.js') diff --git a/client/common/keyframes.component.js b/client/common/keyframes.component.js new file mode 100644 index 00000000..62eda45e --- /dev/null +++ b/client/common/keyframes.component.js @@ -0,0 +1,95 @@ +import React from 'react' +import { Link } from 'react-router-dom' +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' + +import { Keyframe } from '.' +import * as reviewActions from '../review/review.actions' +import * as searchActions from '../search/search.actions' + +function Keyframes(props) { + // console.log(props) + let { + frames, + groupByHash, + } = props + let minDistance = 0 + if (frames && frames.length) { + minDistance = frames[0].distance || 0 + } + if (!groupByHash) { + return ( + + ) + } + const frameGroups = frames.reduce((a, b) => { + if (a[b.hash]) { + a[b.hash].push(b) + } else { + a[b.hash] = [b] + } + return a + }, {}) + return Object.keys(frameGroups) + .map(hash => [frameGroups[hash].length, hash]) + .sort((a, b) => b[0] - a[0]) + .map(([count, hash]) => ( + + )) +} + +function KeyframeList(props) { + let { + saved = {}, + frames, + options, + review, + search, + minDistance, + label, + count, + ...frameProps + } = props + if (!frames) return null + return ( +
+ {label &&

{label} ({count})

} + {frames.map(({ hash, frame, verified, distance }) => ( + review.toggleSaved({ verified, hash, frame })} + reviewActions={review} + {...frameProps} + /> + ))} +
+ ) +} + +const mapStateToProps = state => ({ + saved: state.review.saved, + options: state.search.options, +}) + +const mapDispatchToProps = dispatch => ({ + review: bindActionCreators({ ...reviewActions }, dispatch), + search: bindActionCreators({ ...searchActions }, dispatch), +}) + +export default connect(mapStateToProps, mapDispatchToProps)(Keyframes) -- cgit v1.2.3-70-g09d2