Skip to content

Commit

Permalink
chore: spacing control reset position and conditional render
Browse files Browse the repository at this point in the history
  • Loading branch information
abaicus committed Aug 30, 2019
1 parent d7be266 commit 779c620
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 42 deletions.
24 changes: 12 additions & 12 deletions inc/customizer/controls/react/bundle/controls.css
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@
height: 23px;
line-height: 1;
font-size: 11px;
color: #000;
border: 1px solid #333;
color: #555;
border: 1px solid #999;
box-shadow: none;
background: #fff; }
.neve-units .components-button.is-button.is-active {
Expand Down Expand Up @@ -131,27 +131,27 @@
align-items: center;
margin: 0; }
.neve-responsive-sizing .range-control .components-base-control__field input[type="number"] {
width: 25%; }
.neve-responsive-sizing .nv-sizing-item,
.neve-responsive-sizing .nv-sizing-link {
width: calc(20% + 1px); }
.neve-responsive-sizing .nv-sizing-link {
width: 27%; }
.neve-responsive-sizing .nv-sizing-item {
width: calc(19% + 1px); }
.neve-responsive-sizing .nv-sizing-link, .neve-responsive-sizing .nv-sizing-reset {
width: calc(12% + 1px);
margin-left: -1px; }
.neve-responsive-sizing .nv-sizing-link button {
.neve-responsive-sizing .nv-sizing-link button, .neve-responsive-sizing .nv-sizing-reset button {
width: 100%;
padding: 3px;
flex-direction: row;
align-items: center;
justify-content: center;
justify-items: center;
border: 1px solid #333;
border: 1px solid #999;
border-radius: 0 3px 3px 0;
background: #fff; }
.neve-responsive-sizing .nv-sizing-link button.is-linked {
.neve-responsive-sizing .nv-sizing-link button.is-linked, .neve-responsive-sizing .nv-sizing-reset button.is-linked {
background: #008dc2;
color: #fff; }
.neve-responsive-sizing .nv-sizing-item input[type="number"] {
border: 1px solid #333;
border: 1px solid #999;
border-radius: 0; }
.neve-responsive-sizing .nv-sizing-item:not(:first-child) {
margin-left: -1px; }
Expand All @@ -164,4 +164,4 @@
text-align: center;
display: block;
font-weight: 300;
color: #333; }
color: #555; }
2 changes: 1 addition & 1 deletion inc/customizer/controls/react/bundle/controls.js

Large diffs are not rendered by default.

17 changes: 15 additions & 2 deletions inc/customizer/controls/react/src/common/Sizing.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class SizingControl extends Component {
<Dropdown
position="top center"
focusOnMount={false}
onBlur={() => {console.log('aaaa')}}
renderToggle={({ isOpen, onToggle }) => (
<input
type="number"
Expand Down Expand Up @@ -79,15 +78,29 @@ class SizingControl extends Component {
onClick={() => this.props.onLinked()}
/>
</div>
{ this.hasSetValues() && <div className="nv-sizing-reset">
<IconButton
onClick={this.props.onReset}
tooltip={__( 'Reset all Values', 'neve' )}
icon="image-rotate"
className="reset">
</IconButton>
</div> }
</div>
);
}

hasSetValues() {
return this.props.options.filter( option => option.value ).length > 0;
}
}

SizingControl.propTypes = {
options: PropTypes.array.isRequired,
onLinked: PropTypes.func.isRequired,
onChange: PropTypes.func.isRequired,
linked: PropTypes.bool.isRequired
linked: PropTypes.bool.isRequired,
onReset: PropTypes.func,
};

export default SizingControl;
26 changes: 9 additions & 17 deletions inc/customizer/controls/react/src/spacing/SpacingComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const {
const {
ButtonGroup,
Button,
Dashicon
} = wp.components;
const {
mapValues
Expand Down Expand Up @@ -84,27 +83,20 @@ class SpacingComponent extends Component {
onChange={(optionType, numericValue) => {
this.updateValues( optionType, numericValue );
}}
onReset={() => {
let devices = ['mobile', 'desktop', 'tablet'];
let value = { ...this.state.value };
devices.map( (device) => {
value[device] = mapValues( value[device], () => '' );
} );
this.setState( { value } );
this.props.control.setting.set( value );
}}
/>
<div className="neve-units">
<ButtonGroup className="units">
{this.getButtons()}
</ButtonGroup>
<Button
isLink
isDestructive
onClick={() => {
let devices = ['mobile', 'desktop', 'tablet'];
let value = { ...this.state.value };
devices.map( (device) => {
value[device] = mapValues( value[device], () => '' );
} );
this.setState( { value } );
this.props.control.setting.set( value );
}}
tooltip={__( 'Reset all Values', 'neve' )}
className="reset">
<Dashicon icon="image-rotate"/>
</Button>
</div>
</ResponsiveControl>
</Fragment>
Expand Down
20 changes: 10 additions & 10 deletions inc/customizer/controls/react/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@
height: 23px;
line-height: 1;
font-size: 11px;
color: #000;
border: 1px solid #333;
color: #555;
border: 1px solid #999;
box-shadow: none;
background: #fff;
&.is-active {
Expand Down Expand Up @@ -188,15 +188,15 @@
align-items: center;
margin: 0;
input[type="number"] {
width: 25%;
width: 27%;
}
}
}
.nv-sizing-item,
.nv-sizing-link {
width: calc(20% + 1px);
.nv-sizing-item {
width: calc(19% + 1px);
}
.nv-sizing-link {
.nv-sizing-link, .nv-sizing-reset {
width: calc(12% + 1px);
margin-left: -1px;
button {
width: 100%;
Expand All @@ -205,7 +205,7 @@
align-items: center;
justify-content: center;
justify-items: center;
border: 1px solid #333;
border: 1px solid #999;
border-radius: 0 3px 3px 0;
background: #fff;
&.is-linked {
Expand All @@ -216,7 +216,7 @@
}
.nv-sizing-item {
input[type="number"] {
border: 1px solid #333;
border: 1px solid #999;
border-radius: 0;
}
&:not(:first-child) {
Expand All @@ -233,6 +233,6 @@
text-align: center;
display: block;
font-weight: 300;
color: #333;
color: #555;
}
}

0 comments on commit 779c620

Please sign in to comment.