pixelplanet/src/components/CoordinatesBox.jsx
HF 8475ad0c9f add more translations
move descriptions of canvases.json into .js file in oder to translate it
2021-01-30 08:06:51 +01:00

49 lines
946 B
JavaScript

/**
*
* @flow
*/
import React from 'react';
import { connect } from 'react-redux';
import { t } from 'ttag';
import copy from '../utils/clipboard';
import { notify } from '../actions';
import type { State } from '../reducers';
function renderCoordinates(cell): string {
return `(${cell.join(', ')})`;
}
const CoordinatesBox = ({ view, hover, notifyCopy }) => (
<div
className="coorbox"
onClick={() => { copy(window.location.hash); notifyCopy(); }}
role="button"
title={t`Copy to Clipboard`}
tabIndex="0"
>{
renderCoordinates(hover
|| view.map(Math.round))
}</div>
);
function mapDispatchToProps(dispatch) {
return {
notifyCopy() {
dispatch(notify(t`Copied!`));
},
};
}
function mapStateToProps(state: State) {
const { view } = state.canvas;
const { hover } = state.gui;
return { view, hover };
}
export default connect(mapStateToProps, mapDispatchToProps)(CoordinatesBox);