Skip to content

Commit

Permalink
Mobile: Implementing Clear All Settings button on Image Settings (#…
Browse files Browse the repository at this point in the history
…13753)

* Mobile: Implementing `Reset to Original` button on Image Settings

* Mobile: Change `Revert to Origin` button title to 'Clear All Settings'

* Mobile Image block: Changed method name to `onClearSettings` for clarity
  • Loading branch information
etoledom authored Feb 12, 2019
1 parent e9f6ddd commit ba38d23
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions packages/block-library/src/image/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const MEDIA_UPLOAD_STATE_FAILED = 3;
const MEDIA_UPLOAD_STATE_RESET = 4;

const LINK_DESTINATION_CUSTOM = 'custom';
const LINK_DESTINATION_NONE = 'none';

class ImageEdit extends React.Component {
constructor( props ) {
Expand All @@ -65,6 +66,7 @@ class ImageEdit extends React.Component {
this.updateImageURL = this.updateImageURL.bind( this );
this.onSetLinkDestination = this.onSetLinkDestination.bind( this );
this.onImagePressed = this.onImagePressed.bind( this );
this.onClearSettings = this.onClearSettings.bind( this );
}

componentDidMount() {
Expand Down Expand Up @@ -163,6 +165,14 @@ class ImageEdit extends React.Component {
} );
}

onClearSettings() {
this.props.setAttributes( {
alt: '',
linkDestination: LINK_DESTINATION_NONE,
href: undefined,
} );
}

render() {
const { attributes, isSelected, setAttributes } = this.props;
const { url, caption, height, width, alt, href } = attributes;
Expand Down Expand Up @@ -244,10 +254,10 @@ class ImageEdit extends React.Component {
onChangeValue={ this.updateAlt }
/>
<BottomSheet.Cell
label={ __( 'Reset to Original' ) }
labelStyle={ styles.resetSettingsButton }
label={ __( 'Clear All Settings' ) }
labelStyle={ styles.clearSettingsButton }
drawSeparator={ false }
onPress={ () => {} }
onPress={ this.onClearSettings }
/>
</BottomSheet>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/image/styles.native.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
font-family: $default-regular-font;
}

.resetSettingsButton {
.clearSettingsButton {
color: $alert-red;
}

0 comments on commit ba38d23

Please sign in to comment.