Skip to content

Commit

Permalink
section option for a better options division
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno12mota committed Sep 29, 2015
1 parent ca30638 commit 9d626cc
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 8 deletions.
1 change: 1 addition & 0 deletions assets/less/components/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
@import './overlay.less';
@import './form-state.less';
@import './pagination.less';
@import './section.less';


@import './page-builder/index.less';
Expand Down
35 changes: 35 additions & 0 deletions assets/less/components/section.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.options-section {
background-color: #1D1D1D;
margin: 0 -10px;
cursor: pointer;
padding: 0 10px;
border: 1px solid #333333;
margin-top: -1px;

i, span {
display: inline-block;
vertical-align: top;
line-height: 40px;
color: #cccccc;
}
i {
font-size: 16px;
padding-right: 7px;
}
span {
font-size: 11px;
text-transform: uppercase;
}

&:hover {
background-color: #2C2D2D;

i, span {
color: #ffffff;
}
}
}

.section-options {
margin: 20px 0;
}
28 changes: 21 additions & 7 deletions lib/components/options-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,34 @@ export default class OptionsList extends Component {
);
}
extraProps.label = option.label;
} else if (option.type === 'Section') {
if (value) {
unlockedContent = <div className='section-options'>{this.renderOptions(option.unlocks)}</div>;
}
extraProps.label = option.label;
} else if (option.unlocks.constructor === Array) {
unlockedContent = this.renderOptions(option.unlocks);
} else if (option.unlocks[value]) {
unlockedContent = this.renderOptions(option.unlocks[value]);
}
}

return (
<div className='option' key={option.id}>
{this.renderLabel(option.type !== 'Optional' && option.label)}
<Option onChange={this.onChange.bind(this, option.id)} value={value} {...extraProps} OptionsList={OptionsList} />
{unlockedContent}
</div>
);
if (option.type === 'Section') {
return (
<div key={option.id}>
<Option onChange={this.onChange.bind(this, option.id)} value={value} {...extraProps} OptionsList={OptionsList} />
{unlockedContent}
</div>
);
} else {
return (
<div className='option' key={option.id}>
{this.renderLabel(option.type !== 'Optional' && option.label)}
<Option onChange={this.onChange.bind(this, option.id)} value={value} {...extraProps} OptionsList={OptionsList} />
{unlockedContent}
</div>
);
}
}
else {
console.log('Element option type not valid');
Expand Down
24 changes: 24 additions & 0 deletions lib/components/section.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import {Component} from 'relax-framework';

export default class Section extends Component {
toggle (event) {
event.preventDefault();
this.props.onChange(!this.props.value);
}

render () {
return (
<div className='options-section' onClick={this.toggle.bind(this)}>
<i className='material-icons'>{this.props.value ? 'keyboard_arrow_down' : 'chevron_right'}</i>
<span>{this.props.label}</span>
</div>
);
}
}

Section.propTypes = {
value: React.PropTypes.bool.isRequired,
label: React.PropTypes.string.isRequired,
onChange: React.PropTypes.func.isRequired
};
4 changes: 3 additions & 1 deletion lib/data-types/options-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import CornersPicker from '../components/corners-picker';
import ColorPalettePicker from '../components/color-palette-picker';
import ColumnsManager from '../components/columns-manager';
import Optional from '../components/optional';
import Section from '../components/section';

var TypesOptionsMap = {
Color: ColorPalettePicker,
Expand All @@ -31,7 +32,8 @@ var TypesOptionsMap = {
Corners: CornersPicker,
Columns: ColumnsManager,
Border: BorderPicker,
Optional
Optional,
Section
};

var TypesOptionsDefaultProps = {
Expand Down

0 comments on commit 9d626cc

Please sign in to comment.