refactor: entity stuff

This commit is contained in:
cha0s 2020-06-17 19:37:09 -05:00
parent a16a54f4d7
commit 3d4711fa97
10 changed files with 134 additions and 97 deletions

View File

@ -15,7 +15,10 @@ const Entity = () => {
const {traits} = entity; const {traits} = entity;
return ( return (
<div className="entity"> <div className="entity">
<Traits traits={traits} /> <div className="document-pane"></div>
<div className="settings-pane">
<Traits traits={traits} />
</div>
</div> </div>
); );
}; };

View File

@ -0,0 +1,11 @@
.document-pane {
border-right: 1px solid #1a1a1a;
float: left;
width: calc(100% - 36em);
height: 100vh;
}
.settings-pane {
float: left;
width: 36em;
}

View File

@ -0,0 +1,23 @@
import PropTypes from 'prop-types';
import React from 'react';
import propertyPropTypes from './property-prop-types';
const Bool = ({
name,
label,
value,
}) => (
<label>
<span className="text">{label}</span>
<div className="invisible-separator" />
<input name={name} type="checkbox" checked={value} />
</label>
);
Bool.propTypes = {
...propertyPropTypes,
value: PropTypes.bool.isRequired,
};
export default Bool;

View File

@ -0,0 +1,34 @@
import PropTypes from 'prop-types';
import React from 'react';
import propertyPropTypes from './property-prop-types';
const Number = ({
name,
label,
options,
value,
}) => (
<label>
<span className="text">{label}</span>
<div className="invisible-separator" />
{
options
? (
<select name={name} value={value}>
{Object.entries(options).map(([optionValue, optionLabel]) => (
<option value={optionValue}>{optionLabel}</option>
))}
</select>
)
: <input name={name} size={5} type="text" value={value} />
}
</label>
);
Number.propTypes = {
...propertyPropTypes,
value: PropTypes.number.isRequired,
};
export default Number;

View File

@ -1,89 +1,12 @@
import PropTypes from 'prop-types'; import Bool from './bool';
import React from 'react'; import Number from './number';
import String from './string';
const propertyPropTypes = {
name: PropTypes.string.isRequired,
label: PropTypes.string,
options: PropTypes.shape({}),
};
const bool = ({
name,
label,
value,
}) => (
<label>
<span className="text">{label}</span>
<div className="invisible-separator" />
<input name={name} type="checkbox" checked={value} />
</label>
);
bool.propTypes = {
...propertyPropTypes,
value: PropTypes.bool.isRequired,
};
const number = ({
name,
label,
options,
value,
}) => (
<label>
<span className="text">{label}</span>
<div className="invisible-separator" />
{
options
? (
<select name={name} value={value}>
{Object.entries(options).map(([optionValue, optionLabel]) => (
<option value={optionValue}>{optionLabel}</option>
))}
</select>
)
: <input name={name} size={5} type="text" value={value} />
}
</label>
);
number.propTypes = {
...propertyPropTypes,
value: PropTypes.number.isRequired,
};
const string = ({
name,
label,
options,
value,
}) => (
<label>
<span className="text">{label}</span>
<div className="invisible-separator" />
{
options
? (
<select>
{ /* eslint-disable-next-line jsx-a11y/control-has-associated-label */ }
{options.map((option) => <option value={option} />)}
</select>
)
: <input name={name} size={5} type="text" value={value} />
}
</label>
);
string.propTypes = {
...propertyPropTypes,
value: PropTypes.string.isRequired,
};
// eslint-disable-next-line import/prefer-default-export // eslint-disable-next-line import/prefer-default-export
export function propertyComponents() { export function propertyComponents() {
return { return {
bool, bool: Bool,
number, number: Number,
string, string: String,
}; };
} }

View File

@ -0,0 +1,7 @@
import PropTypes from 'prop-types';
export default {
name: PropTypes.string.isRequired,
label: PropTypes.string,
options: PropTypes.shape({}),
};

View File

@ -0,0 +1,34 @@
import PropTypes from 'prop-types';
import React from 'react';
import propertyPropTypes from './property-prop-types';
const String = ({
name,
label,
options,
value,
}) => (
<label>
<span className="text">{label}</span>
<div className="invisible-separator" />
{
options
? (
<select name={name} value={value}>
{Object.entries(options).map(([optionValue, optionLabel]) => (
<option value={optionValue}>{optionLabel}</option>
))}
</select>
)
: <input name={name} size={5} type="text" value={value} />
}
</label>
);
String.propTypes = {
...propertyPropTypes,
value: PropTypes.string.isRequired,
};
export default String;

View File

@ -19,7 +19,7 @@ form {
} }
.invisible-separator { .invisible-separator {
margin: 1em 0; margin: 0.25em 0;
} }
.text { .text {

View File

@ -74,32 +74,34 @@ code {
} }
label { label {
align-items: center; align-items: left;
background-color: #272727; background-color: #272727;
color: #ffffff; color: #ffffff;
display: flex; display: flex;
flex-direction: column;
flex-wrap: wrap; flex-wrap: wrap;
font-family: "Ubuntu Mono", "Liberation Mono", "DejaVu Sans Mono", "Courier New", monospace; font-family: "Ubuntu Mono", "Liberation Mono", "DejaVu Sans Mono", "Courier New", monospace;
font-size: 0.6em; font-size: 0.6em;
min-height: 3em; min-height: 3em;
justify-content: space-between;
padding: 0.5em 0.5em 0.5em 1em; padding: 0.5em 0.5em 0.5em 1em;
text-transform: uppercase; // text-transform: uppercase;
user-select: none; user-select: none;
} }
@media(min-width: 20em) {
label {
align-items: center;
flex-direction: row;
justify-content: space-between;
}
}
@media(min-width: 32em) { @media(min-width: 32em) {
label { label {
font-size: 0.8em; font-size: 0.8em;
} }
} }
@media(min-width: 64em) {
label {
font-size: 1em;
}
}
label:nth-of-type(2n+1) { label:nth-of-type(2n+1) {
background-color: #1b1b1b; background-color: #1d1d1d
} }
input { input {

View File

@ -2,7 +2,7 @@
.react-tabs__tab-list { .react-tabs__tab-list {
background-color: #272727; background-color: #272727;
font-family: "Ubuntu Mono", "Liberation Mono", "DejaVu Sans Mono", "Courier New", monospace; font-family: Ubuntu, "Droid Sans", sans-serif;
font-size: 0.9em; font-size: 0.9em;
overflow-x: hidden; overflow-x: hidden;
scrollbar-width: thin; scrollbar-width: thin;
@ -13,7 +13,7 @@
height: 6px; height: 6px;
} }
&::-webkit-scrollbar-track { &::-webkit-scrollbar-track {
background: #212121; background: #2e1d1d;
} }
&::-webkit-scrollbar-thumb { &::-webkit-scrollbar-thumb {
background-color: #777; background-color: #777;
@ -23,7 +23,7 @@
} }
.react-tabs__tab { .react-tabs__tab {
background-color: #333333; background-color: #2d2d2d;
color: #aaaaaa; color: #aaaaaa;
cursor: pointer; cursor: pointer;
display: inline-block; display: inline-block;