From ba38d23b4dbb47e59c1ff491357e49a9871e9de1 Mon Sep 17 00:00:00 2001 From: etoledom Date: Tue, 12 Feb 2019 14:58:25 +0100 Subject: [PATCH] Mobile: Implementing `Clear All Settings` button on Image Settings (#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 --- packages/block-library/src/image/edit.native.js | 16 +++++++++++++--- .../block-library/src/image/styles.native.scss | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/block-library/src/image/edit.native.js b/packages/block-library/src/image/edit.native.js index 77d4ce4438b477..521b143e6c2a21 100644 --- a/packages/block-library/src/image/edit.native.js +++ b/packages/block-library/src/image/edit.native.js @@ -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 ) { @@ -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() { @@ -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; @@ -244,10 +254,10 @@ class ImageEdit extends React.Component { onChangeValue={ this.updateAlt } /> {} } + onPress={ this.onClearSettings } /> ); diff --git a/packages/block-library/src/image/styles.native.scss b/packages/block-library/src/image/styles.native.scss index cc3566080f6665..ec59c4caf0a987 100644 --- a/packages/block-library/src/image/styles.native.scss +++ b/packages/block-library/src/image/styles.native.scss @@ -24,6 +24,6 @@ font-family: $default-regular-font; } -.resetSettingsButton { +.clearSettingsButton { color: $alert-red; }