2021-05-29 13:59:11 +00:00
|
|
|
import { ZoomInIcon, ZoomOutIcon } from '@radix-ui/react-icons'
|
2021-07-10 12:01:59 +00:00
|
|
|
import { TertiaryButton, TertiaryButtonsContainer } from './shared'
|
2021-05-29 13:59:11 +00:00
|
|
|
import state, { useSelector } from 'state'
|
2021-06-29 12:00:59 +00:00
|
|
|
import tld from 'utils/tld'
|
2021-05-29 13:59:11 +00:00
|
|
|
|
|
|
|
const zoomIn = () => state.send('ZOOMED_IN')
|
|
|
|
const zoomOut = () => state.send('ZOOMED_OUT')
|
|
|
|
const zoomToFit = () => state.send('ZOOMED_TO_FIT')
|
|
|
|
const zoomToActual = () => state.send('ZOOMED_TO_ACTUAL')
|
|
|
|
|
2021-06-21 21:35:28 +00:00
|
|
|
export default function Zoom(): JSX.Element {
|
2021-05-29 13:59:11 +00:00
|
|
|
return (
|
2021-07-10 12:14:00 +00:00
|
|
|
<TertiaryButtonsContainer bp={{ '@initial': 'mobile', '@sm': 'small' }}>
|
2021-07-10 12:01:59 +00:00
|
|
|
<TertiaryButton label="Zoom Out" onClick={zoomOut}>
|
|
|
|
<ZoomOutIcon />
|
|
|
|
</TertiaryButton>
|
|
|
|
<TertiaryButton label="Zoom In" onClick={zoomIn}>
|
|
|
|
<ZoomInIcon />
|
|
|
|
</TertiaryButton>
|
|
|
|
<ZoomCounter />
|
|
|
|
</TertiaryButtonsContainer>
|
2021-05-29 13:59:11 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
function ZoomCounter() {
|
2021-06-29 12:00:59 +00:00
|
|
|
const zoom = useSelector((s) => tld.getCurrentCamera(s.data).zoom)
|
2021-06-03 12:06:39 +00:00
|
|
|
|
2021-05-29 13:59:11 +00:00
|
|
|
return (
|
2021-07-10 12:01:59 +00:00
|
|
|
<TertiaryButton
|
|
|
|
label="Reset Zoom"
|
2021-06-24 08:17:54 +00:00
|
|
|
onClick={zoomToActual}
|
|
|
|
onDoubleClick={zoomToFit}
|
|
|
|
>
|
2021-06-03 12:06:39 +00:00
|
|
|
{Math.round(zoom * 100)}%
|
2021-07-10 12:01:59 +00:00
|
|
|
</TertiaryButton>
|
2021-05-29 13:59:11 +00:00
|
|
|
)
|
|
|
|
}
|