improve entry editor UI

This commit is contained in:
Shawn Erquhart 2017-03-15 14:30:41 -04:00
parent 736954da8b
commit 3096b4617e
8 changed files with 97 additions and 80 deletions

View File

@ -1,3 +1,5 @@
@import "../UI/theme";
.control {
color: #7c8382;
position: relative;
@ -9,12 +11,13 @@
font-family: monospace;
display: block;
width: 100%;
padding: 12px 0 10px 0;
padding: 12px;
margin: 0;
border: none;
border-radius: var(--borderRadius);
outline: 0;
box-shadow: none;
background: 0 0;
background-color: var(--controlBGColor);
font-size: 18px;
color: #7c8382;
}
@ -22,8 +25,8 @@
.label {
display: block;
color: #AAB0AF;
font-size: 12px;
color: var(--controlLabelColor);
font-size: 14px;
}
.labelWithError {
@ -37,31 +40,3 @@
color: #FF706F;
margin-bottom: 5px;
}
.widget {
border-bottom: 1px solid #e8eae8;
position: relative;
&:after {
content: '';
position: absolute;
left: 42px;
bottom: -7px;
width: 12px;
height: 12px;
background-color: #f2f5f4;
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
z-index: 1;
border-right: 1px solid #e8eae8;
border-bottom: 1px solid #e8eae8;
}
&:last-child {
border-bottom: none;
}
&:last-child:after {
display: none;
}
}

View File

@ -5,6 +5,7 @@
overflow: auto;
padding: 0 20px;
border-right: 1px solid var(--defaultColorLight);
background-color: color(#f2f5f4 lightness(90%));
}
.previewPane {

View File

@ -14,6 +14,8 @@
--textFieldBorderColor: #e7e7e7;
--highlightFGColor: #fff;
--highlightBGColor: #3ab7a5;
--controlLabelColor: #272e30;
--controlBGColor: #fff;
}
.base {

View File

@ -1,55 +1,66 @@
@import "../UI/theme";
:global(.list-item-dragging) {
opacity: 0.5;
}
.addButton {
display: block;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
margin: 20px 0;
border: none;
background: transparent;
&::before {
content: "+";
display: inline-block;
margin-right: 5px;
width: 15px;
height: 15px;
border: 1px solid #444;
border-radius: 100%;
background: transparent;
line-height: 13px;
}
margin-top: 20px;
padding: 8px;
border: 0;
border-radius: var(--borderRadius);
background-color: var(--controlBGColor);
}
.addButtonIcon {
font-size: 18px;
}
.addButtonText {
margin-left: 4px;
}
.removeButton {
position: absolute;
top: 5px;
right: 5px;
display: inline-block;
top: 2px;
right: 2px;
cursor: pointer;
border: none;
background: transparent;
width: 15px;
height: 15px;
border: 1px solid #444;
border-radius: 100%;
line-height: 13px;
display: flex;
align-items: center;
padding: 0 0 2px 2px;
border: 0;
background: none;
z-index: 1;
}
.toggleButton {
position: absolute;
top: 5px;
left: 5px;
top: 0;
left: 0;
cursor: pointer;
display: flex;
align-items: center;
height: 28px;
border: none;
border-radius: var(--borderRadius) 0 0 var(--borderRadius);
background: rgba(0,0,0,0.1);
}
.item {
position: relative;
padding-left: 20px;
padding-left: 24px;
cursor: move;
}
.objectLabel {
border: 1px solid #e8eae8;
border: 2px solid rgba(0,0,0,0.1);
border-top-width: 28px;
border-radius: var(--borderRadius);
border-top-left-radius: 0;
margin-bottom: 20px;
padding: 20px;
display: none;
@ -57,6 +68,8 @@
.objectControl {
display: block;
border-top: 28px solid rgba(0,0,0,0.1);
border-top-left-radius: 0;
}
.expanded {
@ -70,3 +83,11 @@
display: none;
}
}
.dragIcon {
position: absolute;
top: 2px;
display: block;
width: 100%;
text-align: center;
}

View File

@ -1,6 +1,7 @@
import React, { Component, PropTypes } from 'react';
import { List, Map, fromJS } from 'immutable';
import { sortable } from 'react-sortable';
import FontIcon from 'react-toolbox/lib/font_icon';
import ObjectControl from './ObjectControl';
import styles from './ListControl.css';
@ -143,21 +144,23 @@ export default class ListControl extends Component {
outline="list"
>
<div className={classNames.join(' ')}>
<div className={styles.objectLabel}>{this.objectLabel(item)}</div>
<div className={styles.objectControl}>
<ObjectControl
value={item}
field={field}
onChange={this.handleChangeFor(index)}
getAsset={getAsset}
onAddAsset={onAddAsset}
onRemoveAsset={onRemoveAsset}
/>
</div>
<button className={styles.toggleButton} onClick={this.handleToggle(index)}>
{collapsed ? '+' : '-'}
<FontIcon value={collapsed ? 'expand_more' : 'expand_less'} />
</button>
<button className={styles.removeButton} onClick={this.handleRemove(index)}>x</button>
<FontIcon value="drag_handle" className={styles.dragIcon} />
<button className={styles.removeButton} onClick={this.handleRemove(index)}>
<FontIcon value="close" />
</button>
<div className={styles.objectLabel}>{this.objectLabel(item)}</div>
<ObjectControl
value={item}
field={field}
className={styles.objectControl}
onChange={this.handleChangeFor(index)}
getAsset={getAsset}
onAddAsset={onAddAsset}
onRemoveAsset={onRemoveAsset}
/>
</div>
</SortableListItem>);
}
@ -166,7 +169,10 @@ export default class ListControl extends Component {
const { value, forID } = this.props;
return (<div id={forID}>
{value && value.map((item, index) => this.renderItem(item, index))}
<div><button className={styles.addButton} onClick={this.handleAdd}>new</button></div>
<button className={styles.addButton} onClick={this.handleAdd}>
<FontIcon value="add" className={styles.addButtonIcon} />
<span className={styles.addButtonText}>new</span>
</button>
</div>);
}

View File

@ -1,3 +1,5 @@
@import "../../../UI/theme";
.editor {
position: relative;
& h1, & h2, & h3 {
@ -57,6 +59,9 @@
:global {
& .ProseMirror {
position: relative;
background-color: var(--controlBGColor);
padding: 12px;
border-radius: var(--borderRadius);
}
& .ProseMirror-content {

View File

@ -1,6 +1,9 @@
@import "../UI/theme";
.root {
position: relative;
border: 1px solid #e8eae8;
border: 2px solid rgba(0,0,0,0.1);
border-radius: var(--borderRadius);
margin-bottom: 20px;
padding: 20px;
padding: 0 20px 12px;
}

View File

@ -8,10 +8,12 @@ export default class ObjectControl extends Component {
static propTypes = {
onChange: PropTypes.func.isRequired,
onAddAsset: PropTypes.func.isRequired,
onRemoveAsset: PropTypes.func.isRequired,
getAsset: PropTypes.func.isRequired,
value: PropTypes.node,
field: PropTypes.object,
forID: PropTypes.string.isRequired,
className: PropTypes.string,
};
controlFor(field) {
@ -21,9 +23,10 @@ export default class ObjectControl extends Component {
return (<div className={controlStyles.widget} key={field.get('name')}>
<div className={controlStyles.control} key={field.get('name')}>
<label className={controlStyles.label}>{field.get('label')}</label>
<label className={controlStyles.label} htmlFor={field.get('name')}>{field.get('label')}</label>
{
React.createElement(widget.control, {
id: field.get('name'),
field,
value: fieldValue,
onChange: (val, metadata) => {
@ -42,10 +45,11 @@ export default class ObjectControl extends Component {
const { field, forID } = this.props;
const multiFields = field.get('fields');
const singleField = field.get('field');
const className = this.props.className || '';
if (multiFields) {
return (<div id={forID} className={styles.root}>
{multiFields.map(field => this.controlFor(field))}
return (<div id={forID} className={`${ className } ${ styles.root }`}>
{multiFields.map(f => this.controlFor(f))}
</div>);
} else if (singleField) {
return this.controlFor(singleField);