feat: vector renderer

This commit is contained in:
cha0s 2020-06-22 05:39:15 -05:00
parent 562512e2b9
commit 6b52c18a0d
2 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,8 @@
:scope {
align-items: center;
display: flex;
}
.separator {
margin: 0 0.25em;
}

View File

@ -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,
}) => (
<span className="vector">
<Number.Component
dispatchers={{
onChange: (axe) => onChange([axe, value[1]]),
}}
value={value[0]}
/>
<span className="separator">{' x '}</span>
<Number.Component
dispatchers={{
onChange: (axe) => onChange([value[0], axe]),
}}
value={value[1]}
/>
</span>
);
Vector.propTypes = {
...propTypes,
value: PropTypes.arrayOf(PropTypes.number).isRequired,
};
export default {
type: 'vector',
Component: decorate(Vector),
};