Skip to content
Snippets Groups Projects
Verified Commit 3007b603 authored by Loïs Poujade's avatar Loïs Poujade
Browse files

Better UI; use Redux selector

- time controls buttons where not visually "buttons"
- added tooltip on hover
- use a Redux selector to get annotations, don't parse them from the state
parent a44171e8
No related branches found
No related tags found
No related merge requests found
...@@ -442,27 +442,35 @@ class AnnotationCreation extends Component { ...@@ -442,27 +442,35 @@ class AnnotationCreation extends Component {
<Grid container> <Grid container>
{ mediaIsVideo && ( { mediaIsVideo && (
<> <>
<Grid item xs={12} onClick={this.seekToTstart}> <Grid item xs={12}>
<IconButton size="small"><LastPage /></IconButton> <ToggleButton title="Go to start time" size="small" onClick={this.seekToTstart} className={classes.timecontrolsbutton}>
<LastPage />
</ToggleButton>
<Typography variant="overline"> <Typography variant="overline">
Start Start
</Typography> </Typography>
</Grid> </Grid>
<Grid item xs={12} className={classes.paper}> <Grid item xs={12} className={classes.paper}>
<IconButton onClick={this.setTstartNow}><Alarm /></IconButton> <ToggleButton title="Set current time" size="small" onClick={this.setTstartNow} className={classes.timecontrolsbutton}>
<Alarm />
</ToggleButton>
<HMSInput seconds={tstart} onChange={this.updateTstart} /> <HMSInput seconds={tstart} onChange={this.updateTstart} />
</Grid> </Grid>
<Grid item xs={12} onClick={this.seekToTend}> <Grid item xs={12}>
<Typography variant="overline"> <Typography variant="overline">
<IconButton size="small"><LastPage /></IconButton> <ToggleButton title="Go to start time" size="small" onClick={this.seekToTend} className={classes.timecontrolsbutton}>
<LastPage />
</ToggleButton>
End End
</Typography> </Typography>
</Grid> </Grid>
<Grid item xs={12} className={classes.paper}> <Grid item xs={12} className={classes.paper}>
<IconButton onClick={this.setTendNow}><Alarm /></IconButton> <ToggleButton title="Set current time" size="small" onClick={this.setTendNow} className={classes.timecontrolsbutton}>
<Alarm />
</ToggleButton>
<HMSInput seconds={tend} onChange={this.updateTend} /> <HMSInput seconds={tend} onChange={this.updateTend} />
</Grid> </Grid>
</> </>
...@@ -551,6 +559,13 @@ const styles = (theme) => ({ ...@@ -551,6 +559,13 @@ const styles = (theme) => ({
paddingRight: theme.spacing(1), paddingRight: theme.spacing(1),
paddingTop: theme.spacing(2), paddingTop: theme.spacing(2),
}, },
timecontrolsbutton: {
height: '30px',
margin: 'auto',
marginLeft: '0',
marginRight: '5px',
width: '30px',
},
}); });
AnnotationCreation.propTypes = { AnnotationCreation.propTypes = {
......
...@@ -2,6 +2,7 @@ import * as actions from 'mirador/dist/es/src/state/actions'; ...@@ -2,6 +2,7 @@ import * as actions from 'mirador/dist/es/src/state/actions';
import { getCompanionWindow } from 'mirador/dist/es/src/state/selectors/companionWindows'; import { getCompanionWindow } from 'mirador/dist/es/src/state/selectors/companionWindows';
import { getWindowCurrentTime, getWindowPausedStatus } from 'mirador/dist/es/src/state/selectors/window'; import { getWindowCurrentTime, getWindowPausedStatus } from 'mirador/dist/es/src/state/selectors/window';
import { getVisibleCanvases } from 'mirador/dist/es/src/state/selectors/canvases'; import { getVisibleCanvases } from 'mirador/dist/es/src/state/selectors/canvases';
import { getPresentAnnotationsOnSelectedCanvases } from 'mirador/dist/es/src/state/selectors/annotations';
import AnnotationCreation from '../AnnotationCreation'; import AnnotationCreation from '../AnnotationCreation';
/** */ /** */
...@@ -23,16 +24,9 @@ function mapStateToProps(state, { id: companionWindowId, windowId }) { ...@@ -23,16 +24,9 @@ function mapStateToProps(state, { id: companionWindowId, windowId }) {
const { annotationid } = cw; const { annotationid } = cw;
const canvases = getVisibleCanvases(state, { windowId }); const canvases = getVisibleCanvases(state, { windowId });
let annotation = null; const annotation = getPresentAnnotationsOnSelectedCanvases(state, { windowId })
canvases.forEach((canvas) => { .flatMap((annoPage) => annoPage.json.items)
const annotationsOnCanvas = state.annotations[canvas.id]; .find((annot) => annot.id === annotationid);
Object.values(annotationsOnCanvas || {}).forEach((value, i) => {
if (value.json && value.json.items) {
const maybeAnnot = value.json.items.find((anno) => anno.id === annotationid);
if (maybeAnnot !== undefined) annotation = maybeAnnot;
}
});
});
return { return {
annotation, annotation,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment