Skip to content

Commit

Permalink
Pass only modified media-placeholder styles
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonis Lilis committed Jul 15, 2020
1 parent a0cd93b commit 7aec919
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { Icon, plusCircleFilled } from '@wordpress/icons';
/**
* Internal dependencies
*/
import defaultStyles from './styles.scss';
import styles from './styles.scss';

// remove duplicates after gallery append
const dedupMedia = ( media ) =>
Expand All @@ -44,11 +44,10 @@ function MediaPlaceholder( props ) {
multiple,
value = [],
children,
customStyles,
customEmptyStateContainer,
customEmptyStateTitle,
} = props;

const styles = customStyles === undefined ? defaultStyles : customStyles;

// use ref to keep media array current for callbacks during rerenders
const mediaRef = useRef( value );
mediaRef.current = value;
Expand Down Expand Up @@ -95,7 +94,7 @@ function MediaPlaceholder( props ) {
}

const emptyStateTitleStyle = getStylesFromColorScheme(
styles.emptyStateTitle,
[ styles.emptyStateTitle, props.customEmptyStateTitle ],
styles.emptyStateTitleDark
);
const addMediaButtonStyle = getStylesFromColorScheme(
Expand Down Expand Up @@ -138,7 +137,7 @@ function MediaPlaceholder( props ) {
styles.appenderDark
);
const emptyStateContainerStyle = getStylesFromColorScheme(
styles.emptyStateContainer,
[ styles.emptyStateContainer, props.customEmptyStateContainer ],
styles.emptyStateContainerDark
);

Expand Down
8 changes: 6 additions & 2 deletions packages/block-library/src/cover/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import { getProtocol } from '@wordpress/url';
* Internal dependencies
*/
import styles from './style.scss';
import placeholderStyles from './media-placeholder.scss';
import {
attributesFromMedia,
COVER_MIN_HEIGHT,
Expand Down Expand Up @@ -347,7 +346,12 @@ const Cover = ( {
return (
<View>
<MediaPlaceholder
customStyles={ placeholderStyles }
customEmptyStateContainer={
styles.mediaPlaceholderEmptyStateContainer
}
customEmptyStateTitle={
styles.mediaPlaceholderEmptyStateTitle
}
icon={ placeholderIcon }
labels={ {
title: __( 'Cover' ),
Expand Down
73 changes: 0 additions & 73 deletions packages/block-library/src/cover/media-placeholder.native.scss

This file was deleted.

9 changes: 9 additions & 0 deletions packages/block-library/src/cover/style.native.scss
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,12 @@
width: 32px;
height: 32px;
}

.mediaPlaceholderEmptyStateContainer {
height: 300;
}

.mediaPlaceholderEmptyStateTitle {
margin-top: 4;
margin-bottom: 16;
}

0 comments on commit 7aec919

Please sign in to comment.