Skip to content

Commit

Permalink
[RNMobile] Performance improvements in File related controls (#28224)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewalczak committed Jan 28, 2021
1 parent 6119ad9 commit ccc1e86
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
30 changes: 17 additions & 13 deletions packages/block-library/src/file/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
ToolbarGroup,
PanelBody,
ToggleControl,
BottomSheet,
TextControl,
SelectControl,
Icon,
} from '@wordpress/components';
Expand Down Expand Up @@ -263,13 +263,16 @@ export class FileEdit extends Component {
);

const isCopyUrlDisabled = isUploadFailed || isUploadInProgress;
const dimmedStyle = isCopyUrlDisabled && styles.disabledButton;
const finalButtonStyle = Object.assign(
{},
actionButtonStyle,
dimmedStyle

const dimmedActionButtonStyle = this.props.getStylesFromColorScheme(
styles.dimmedActionButton,
styles.dimmedActionButtonDark
);

const finalButtonStyle = isCopyUrlDisabled
? dimmedActionButtonStyle
: actionButtonStyle;

return (
<InspectorControls>
{ isSidebarLinkSettings || (
Expand Down Expand Up @@ -297,7 +300,7 @@ export class FileEdit extends Component {
onChange={ this.onChangeDownloadButtonVisibility }
/>
) }
<BottomSheet.Cell
<TextControl
disabled={ isCopyUrlDisabled }
label={
this.state.isUrlCopied
Expand Down Expand Up @@ -455,12 +458,13 @@ export class FileEdit extends Component {
openMediaOptions
) }
{ getMediaOptions() }
{ this.getInspectorControls(
attributes,
media,
isUploadInProgress,
isUploadFailed
) }
{ isSelected &&
this.getInspectorControls(
attributes,
media,
isUploadInProgress,
isUploadFailed
) }
<View style={ styles.container }>
<RichText
withoutInteractiveFormatting
Expand Down
14 changes: 10 additions & 4 deletions packages/block-library/src/file/style.native.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
padding-right: $grid-unit-20;
}

.disabledButton {
opacity: 0.45;
}

.uploadFailedText {
color: #fff;
font-size: 14;
Expand All @@ -41,6 +37,16 @@
color: $blue-30;
}

.dimmedActionButton {
color: $blue-50;
opacity: 0.45;
}

.dimmedActionButtonDark {
opacity: 0.45;
color: $blue-30;
}

.errorContainer {
flex-direction: row;
align-items: center;
Expand Down
6 changes: 5 additions & 1 deletion packages/components/src/text-control/index.native.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* WordPress dependencies
*/
import { memo } from '@wordpress/element';
/**
* Internal dependencies
*/
Expand Down Expand Up @@ -32,4 +36,4 @@ function TextControl( {
);
}

export default TextControl;
export default memo( TextControl );

0 comments on commit ccc1e86

Please sign in to comment.