mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-12 21:38:35 +03:00
Using prettier for linting
This commit is contained in:
@@ -1,45 +1,47 @@
|
||||
import React from 'react'
|
||||
import React from "react";
|
||||
|
||||
const DEFAULT_ZOOM_LEVELS = [
|
||||
{ label: '20 years', duration: 10512000 },
|
||||
{ label: '2 years', duration: 1051200 },
|
||||
{ label: '3 months', duration: 129600 },
|
||||
{ label: '3 days', duration: 4320 },
|
||||
{ label: '12 hours', duration: 720 },
|
||||
{ label: '1 hour', duration: 60 }
|
||||
]
|
||||
{ label: "20 years", duration: 10512000 },
|
||||
{ label: "2 years", duration: 1051200 },
|
||||
{ label: "3 months", duration: 129600 },
|
||||
{ label: "3 days", duration: 4320 },
|
||||
{ label: "12 hours", duration: 720 },
|
||||
{ label: "1 hour", duration: 60 },
|
||||
];
|
||||
|
||||
function zoomIsActive (duration, extent, max) {
|
||||
function zoomIsActive(duration, extent, max) {
|
||||
if (duration >= max && extent >= max) {
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
return duration === extent
|
||||
return duration === extent;
|
||||
}
|
||||
|
||||
const TimelineZoomControls = ({ extent, zoomLevels, dims, onApplyZoom }) => {
|
||||
function renderZoom (zoom, idx) {
|
||||
const max = zoomLevels.reduce((acc, vl) => acc.duration < vl.duration ? vl : acc)
|
||||
const isActive = zoomIsActive(zoom.duration, extent, max.duration)
|
||||
function renderZoom(zoom, idx) {
|
||||
const max = zoomLevels.reduce((acc, vl) =>
|
||||
acc.duration < vl.duration ? vl : acc
|
||||
);
|
||||
const isActive = zoomIsActive(zoom.duration, extent, max.duration);
|
||||
return (
|
||||
<text
|
||||
className={`zoom-level-button ${isActive ? 'active' : ''}`}
|
||||
x='60'
|
||||
y={(idx * 15) + 20}
|
||||
className={`zoom-level-button ${isActive ? "active" : ""}`}
|
||||
x="60"
|
||||
y={idx * 15 + 20}
|
||||
onClick={() => onApplyZoom(zoom)}
|
||||
>
|
||||
{zoom.label}
|
||||
</text>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (zoomLevels.length === 0) {
|
||||
zoomLevels = DEFAULT_ZOOM_LEVELS
|
||||
zoomLevels = DEFAULT_ZOOM_LEVELS;
|
||||
}
|
||||
return (
|
||||
<g transform={`translate(${dims.width - dims.width_controls}, 0)`}>
|
||||
{zoomLevels.map((z, idx) => renderZoom(z, idx))}
|
||||
</g>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export default TimelineZoomControls
|
||||
export default TimelineZoomControls;
|
||||
|
||||
Reference in New Issue
Block a user