diff --git a/src/client/types/vector.raw.scss b/src/client/types/vector.raw.scss new file mode 100644 index 0000000..c1f7c14 --- /dev/null +++ b/src/client/types/vector.raw.scss @@ -0,0 +1,8 @@ +:scope { + align-items: center; + display: flex; +} + +.separator { + margin: 0 0.25em; +} diff --git a/src/client/types/vector.type-renderer.jsx b/src/client/types/vector.type-renderer.jsx new file mode 100644 index 0000000..cce0fa4 --- /dev/null +++ b/src/client/types/vector.type-renderer.jsx @@ -0,0 +1,44 @@ +import {compose} from '@avocado/core'; +import contempo from 'contempo'; +import PropTypes from 'prop-types'; +import React from 'react'; + +import Number from './number.type-renderer'; +import propTypes from './prop-types'; + +const decorate = compose( + contempo(require('./vector.raw.scss')), +); + +const Vector = ({ + dispatchers: { + onChange = () => {}, + } = {}, + value, +}) => ( + + onChange([axe, value[1]]), + }} + value={value[0]} + /> + {' x '} + onChange([value[0], axe]), + }} + value={value[1]} + /> + +); + +Vector.propTypes = { + ...propTypes, + value: PropTypes.arrayOf(PropTypes.number).isRequired, +}; + +export default { + type: 'vector', + Component: decorate(Vector), +};