This commit is contained in:
cyril lopez 2018-07-06 12:34:11 +02:00
parent b9b2e55d4b
commit 6af99aebdc
7 changed files with 63 additions and 45 deletions

View File

@ -10,8 +10,8 @@
.ctmBlockTitle { .ctmBlockTitle {
padding-top: 0px; padding-top: 0px;
line-height: 18px; line-height: 18px;
font-weight: 400;
> span { > span {
font-weight: 600;
color: #333740; color: #333740;
font-size: 18px; font-size: 18px;
} }

View File

@ -18,9 +18,7 @@ import cn from 'classnames';
import styles from './styles.scss'; import styles from './styles.scss';
const draggableAttrSource = { const draggableAttrSource = {
beginDrag: (props, monitor, component) => { beginDrag: (props) => {
const el = findDOMNode(component);
el.className = styles.dragged;
props.updateSiblingHoverState(); props.updateSiblingHoverState();
return { return {
@ -28,10 +26,7 @@ const draggableAttrSource = {
index: props.index, index: props.index,
}; };
}, },
endDrag: (props, monitor, component) => { endDrag: (props) => {
const el = findDOMNode(component);
const className = props.isEditing ? `${styles.draggableAttr} ${styles.editingAttr}` : styles.draggableAttr;
el.className = className;
props.updateSiblingHoverState(); props.updateSiblingHoverState();
return {}; return {};
@ -86,7 +81,7 @@ const draggableAttrTarget = {
}; };
class DraggableAttr extends React.Component { class DraggableAttr extends React.Component {
state = { isHover: false }; state = { isOver: false, dragStart: false };
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
const { isDraggingSibling } = this.props; const { isDraggingSibling } = this.props;
@ -104,11 +99,11 @@ class DraggableAttr extends React.Component {
handleMouseEnter = () => { handleMouseEnter = () => {
if (!this.props.isDraggingSibling) { if (!this.props.isDraggingSibling) {
this.setState({ isHover: true }); this.setState({ isOver: true });
} }
}; };
handleMouseLeave = () => this.setState({ isHover: false }); handleMouseLeave = () => this.setState({ isOver: false });
handleRemove = (e) => { handleRemove = (e) => {
e.preventDefault(); e.preventDefault();
@ -118,14 +113,18 @@ class DraggableAttr extends React.Component {
render() { render() {
const { label, name, isDragging, isEditing, connectDragSource, connectDropTarget } = this.props; const { label, name, isDragging, isEditing, connectDragSource, connectDropTarget } = this.props;
const { isHover } = this.state; const { isOver, dragStart } = this.state;
const opacity = isDragging ? 0.2 : 1; const opacity = isDragging ? 0.2 : 1;
const overClass = isOver ? styles.draggableAttrOvered : '';
const className = dragStart ? styles.dragged : styles.draggableAttr;
return ( return (
connectDragSource( connectDragSource(
connectDropTarget( connectDropTarget(
<div <div
className={cn(styles.draggableAttr, isEditing && styles.editingAttr)} className={cn(className, isEditing && styles.editingAttr, overClass)}
onDragStart={() => this.setState({ dragStart: true })}
onDragEnd={() => this.setState({ dragStart: false })}
onMouseEnter={this.handleMouseEnter} onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave} onMouseLeave={this.handleMouseLeave}
onClick={this.handleClickEdit} onClick={this.handleClickEdit}
@ -133,20 +132,20 @@ class DraggableAttr extends React.Component {
> >
<i className="fa fa-th" aria-hidden="true" /> <i className="fa fa-th" aria-hidden="true" />
<span>{name}</span> <span>{name}</span>
{ isHover && !isDragging && ( { isOver && !isDragging && (
<div className={styles.info}> <div className={styles.info}>
<FormattedMessage id="content-manager.components.DraggableAttr.edit" /> <FormattedMessage id="content-manager.components.DraggableAttr.edit" />
</div> </div>
)} )}
{ !isHover && upperFirst(name) !== label && ( { !isOver && upperFirst(name) !== label && (
<div className={styles.info}> <div className={styles.info}>
{label} {label}
</div> </div>
)} )}
{isEditing && !isHover? ( {isEditing && !isOver? (
<span className={styles.editIcon} onClick={this.handleClickEdit} /> <span className={styles.editIcon} onClick={this.handleClickEdit} />
) : ( ) : (
<span className={styles.removeIcon} onClick={this.handleRemove} /> <span className={cn( dragStart ? styles.removeIconDragged : styles.removeIcon)} onClick={this.handleRemove} />
)} )}
</div> </div>
), ),

View File

@ -1,12 +1,12 @@
.draggableAttr { .draggableAttr {
position: relative; position: relative;
height: 28px; height: 30px;
width: 100%; width: 100%;
margin-bottom: 8px; margin-bottom: 6px;
padding-left: 10px; padding-left: 10px;
justify-content: space-between; justify-content: space-between;
background: #FAFAFB; background: #FAFAFB;
line-height: 28px; line-height: 30px;
color: #333740; color: #333740;
border: 1px solid #E3E9F3; border: 1px solid #E3E9F3;
border-radius: 2px; border-radius: 2px;
@ -15,13 +15,15 @@
font-size: 11px; font-size: 11px;
color: #B3B5B9; color: #B3B5B9;
} }
&:hover { }
.draggableAttrOvered {
border: 1px solid #AED4FB!important; border: 1px solid #AED4FB!important;
}
} }
.editingAttr { .editingAttr {
background: #E6F0FB!important; background: #E6F0FB!important;
border: 1px solid #AED4FB!important;
} }
.info { .info {
@ -35,7 +37,26 @@
.removeIcon { .removeIcon {
width: 30px; width: 30px;
background: #F3F4F4; background: #F3F4F4;
height: 26px; height: 28px;
cursor: pointer;
text-align: center;
float: right;
&:after {
display: inline-block;
content: '';
width: 8px;
height: 8px;
margin: auto;
margin-top: -3px;
background-image: url('../../assets/images/icon-cross.svg');
}
}
.removeIconDragged {
width: 30px;
background: #F3F4F4;
height: 28px;
cursor: pointer; cursor: pointer;
text-align: center; text-align: center;
float: right; float: right;
@ -54,7 +75,7 @@
.editIcon { .editIcon {
width: 30px; width: 30px;
background: #E6F0FB; background: #E6F0FB;
height: 26px; height: 28px;
cursor: pointer; cursor: pointer;
text-align: center; text-align: center;
float: right; float: right;
@ -72,15 +93,16 @@
.dragged { .dragged {
position: relative; position: relative;
height: 28px; height: 30px !important;
width: 100%; width: 100%;
margin-bottom: 8px; margin-bottom: 6px;
box-shadow: 0!important;
padding-left: 10px; padding-left: 10px;
justify-content: space-between; justify-content: space-between;
background: #E6F0FB; background: #E6F0FB !important;
line-height: 28px; line-height: 30px;
color: #333740; color: #333740;
border: 1px solid #AED4FB; border: 1px solid darken(#AED4FB, 20%)!important;
border-radius: 2px; border-radius: 2px;
> i { > i {
margin-right: 10px; margin-right: 10px;

View File

@ -28,4 +28,5 @@
.frame { .frame {
position: relative; position: relative;
padding-left: 55px; padding-left: 55px;
font-weight: 500;
} }

View File

@ -43,6 +43,7 @@
"customBootstrapClass": "col-md-4 ml-md-auto", "customBootstrapClass": "col-md-4 ml-md-auto",
"didCheckErrors": false, "didCheckErrors": false,
"errors": [], "errors": [],
"style": { "marginRight": "-20px" },
"name": "defaultSort", "name": "defaultSort",
"selectOptions": ["_id"], "selectOptions": ["_id"],
"type": "select", "type": "select",
@ -53,7 +54,7 @@
"customBootstrapClass": "col-md-1", "customBootstrapClass": "col-md-1",
"didCheckErrors": false, "didCheckErrors": false,
"errors": [], "errors": [],
"inputStyle": { "maxWidth": "130px" },
"name": "sort", "name": "sort",
"selectOptions": ["ASC", "DESC"], "selectOptions": ["ASC", "DESC"],
"type": "select", "type": "select",
@ -80,15 +81,6 @@
"name": "sortable", "name": "sortable",
"type": "toggle", "type": "toggle",
"validations": {} "validations": {}
},
{
"label": { "id": "content-manager.form.Input.search.field" },
"customBootstrapClass": "col-md-6",
"didCheckErrors": false,
"errors": [],
"name": "searchable",
"type": "toggle",
"validations": {}
} }
] ]
} }

View File

@ -251,11 +251,14 @@ class SettingPage extends React.PureComponent {
<div className="row"> <div className="row">
{forms.inputs.map(input => { {forms.inputs.map(input => {
const inputName = `${namePath}.${input.name}`; const inputName = `${namePath}.${input.name}`;
console.log(input.name)
let inputStyle = input.name === 'defaulteSort' ? { marginRight: '-20px' } : {};
return ( return (
<Input <Input
{...input} {...input}
key={input.name} key={input.name}
// style={inputStyle}
name={inputName} name={inputName}
onChange={onChangeSettings} onChange={onChangeSettings}
selectOptions={this.getSelectOptions(input)} selectOptions={this.getSelectOptions(input)}

View File

@ -61,7 +61,7 @@
.dropdownWrapper { .dropdownWrapper {
margin-left: 30px; margin-left: 30px;
> div { > div {
height: 28px; height: 30px;
width: 100%; width: 100%;
justify-content: space-between; justify-content: space-between;
background: #ffffff; background: #ffffff;
@ -72,13 +72,14 @@
position: relative; position: relative;
cursor: pointer; cursor: pointer;
padding-left: 10px !important; padding-left: 10px !important;
line-height: 28px; line-height: 30px;
width: 100%; width: 100%;
color: #333740; color: #333740;
text-align: left; text-align: left;
background-color: #ffffff; background-color: #ffffff;
border: none; border: none;
font-size: 13px; font-size: 13px;
font-weight: 500;
&:focus, &:active, &:hover, &:visited { &:focus, &:active, &:hover, &:visited {
background-color: transparent!important; background-color: transparent!important;
box-shadow: none; box-shadow: none;
@ -113,8 +114,8 @@
overflow: scroll; overflow: scroll;
button { button {
height: 28px; height: 30px;
line-height: 28px; line-height: 30px;
div { div {
margin: 0; margin: 0;
white-space: nowrap; white-space: nowrap;