Skip to content

Commit

Permalink
INT-1838: Indent carats in edit mode
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed Oct 3, 2016
1 parent 4f1deb2 commit 3b51490
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/internal-packages/crud/lib/component/document.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class Document extends React.Component {
editableElements() {
const components = [];
for (const element of this.state.doc.elements) {
components.push(<EditableElement key={element.uuid} element={element} indent={0} />);
components.push(<EditableElement key={element.uuid} element={element} />);
}
components.push(<Hotspot key="hotspot" element={this.state.doc} />);
return components;
Expand Down
18 changes: 4 additions & 14 deletions src/internal-packages/crud/lib/component/editable-element.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,6 @@ class EditableElement extends React.Component {
this.setState({ expanded: !this.state.expanded });
}

/**
* Get the inline style for the element.
*
* @returns {Object} The inline style object.
*/
inlineStyle() {
return { paddingLeft: `${this.props.indent}px` };
}

/**
* Get the style for the element component.
*
Expand Down Expand Up @@ -139,7 +130,7 @@ class EditableElement extends React.Component {
const components = [];
let index = 0;
for (const element of this.element.elements) {
components.push(<EditableElement key={element.uuid} element={element} index={index} indent={this.props.indent + 16}/>);
components.push(<EditableElement key={element.uuid} element={element} index={index} />);
index++;
}
return components;
Expand All @@ -152,7 +143,7 @@ class EditableElement extends React.Component {
*/
renderNonExpandable() {
return (
<li className={this.style()} style={{ paddingLeft: `${this.props.indent}px` }}>
<li className={this.style()}>
<ElementAction element={this.element} />
<LineNumber />
<EditableKey element={this.element} index={this.props.index} />
Expand All @@ -172,7 +163,7 @@ class EditableElement extends React.Component {
renderExpandable() {
return (
<li className={this.style(BEM_EXP_BASE)}>
<div className={this.style(HEADER)} style={this.inlineStyle()}>
<div className={this.style(HEADER)}>
<ElementAction element={this.element} />
<LineNumber />
<div className={HEADER_TOGGLE} onClick={this.toggleExpandable.bind(this)}></div>
Expand Down Expand Up @@ -203,8 +194,7 @@ EditableElement.displayName = 'EditableElement';

EditableElement.propTypes = {
element: React.PropTypes.object.isRequired,
index: React.PropTypes.number,
indent: React.PropTypes.number
index: React.PropTypes.number
};

module.exports = EditableElement;
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class InsertDocument extends React.Component {
renderElements() {
const components = [];
for (const element of this.doc.elements) {
components.push(<EditableElement key={element.uuid} element={element} indent={0} />);
components.push(<EditableElement key={element.uuid} element={element} />);
}
components.push(<Hotspot key="hotspot" element={this.doc} />);
return components;
Expand Down
14 changes: 14 additions & 0 deletions src/internal-packages/crud/styles/crud.less
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@
}
}

.editable-expandable-element-header {

&-toggle {
margin-left: -10px;
margin-right: 6px;
}

&-is-expanded {
.editable-expandable-element-header-toggle {
margin-left: -14px;
}
}
}

.document {

&:hover {
Expand Down
4 changes: 4 additions & 0 deletions src/internal-packages/crud/styles/document.less
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@
&-is-editing {
box-shadow: 2px 5px 8px rgba(0, 0, 0, 0.2);
}

.editable-element, .editable-expandable-element {
margin-left: 15px;
}
}
1 change: 0 additions & 1 deletion src/internal-packages/crud/styles/editable-element.less
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
&-field {
display: inline-block;
vertical-align: top;
margin-left: 22px;
}

&-separator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@
border-right: 0;
border-top: @caret-width-base solid transparent;
border-bottom: @caret-width-base solid transparent;
position: absolute;
left: 44px;
margin-top: 4px;
}

&-is-expanded {
Expand Down

0 comments on commit 3b51490

Please sign in to comment.