Skip to content

Commit

Permalink
core/edit: remove wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
retrofox committed Sep 10, 2019
1 parent b97798d commit 31ef94b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 62 deletions.
34 changes: 13 additions & 21 deletions packages/block-library/src/image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ const stopPropagationRelevantKeys = ( event ) => {
};

const ImageURLInputUI = ( {
advancedOptions,
linkDestination,
mediaLinks,
onChangeUrl,
url,
} ) => {
advancedOptions,
linkDestination,
mediaLinks,
onChangeUrl,
url,
} ) => {
const [ isOpen, setIsOpen ] = useState( false );
const openLinkUI = useCallback( () => {
setIsOpen( true );
Expand Down Expand Up @@ -603,7 +603,6 @@ export class ImageEdit extends Component {
value={ align }
onChange={ this.updateAlignment }
/>

{ url && (
<>
<Toolbar>
Expand Down Expand Up @@ -694,7 +693,7 @@ export class ImageEdit extends Component {
[ `size-${ sizeSlug }` ]: sizeSlug,
} );

const isResizable = ( [ 'wide', 'full' ].indexOf( align ) === -1 ) && isLargeViewport;
const isResizable = ( [ 'wide', 'full', 'fullScreen' ].indexOf( align ) === -1 ) && isLargeViewport;

const imageSizeOptions = this.getImageSizeOptions();

Expand Down Expand Up @@ -804,14 +803,11 @@ export class ImageEdit extends Component {
defaultedAlt = __( 'This image has an empty alt attribute' );
}

const imgContainer = (
const img = (
// Disable reason: Image itself is not meant to be interactive, but
// should direct focus to block.
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
<div
className="wp-block-image__image-wrapper"
style={ { backgroundImage: `url(${ url })` } }
>
<>
<img
src={ url }
alt={ defaultedAlt }
Expand All @@ -820,7 +816,7 @@ export class ImageEdit extends Component {
onError={ () => this.onImageError( url ) }
/>
{ isBlobURL( url ) && <Spinner /> }
</div>
</>
/* eslint-enable jsx-a11y/no-noninteractive-element-interactions */
);

Expand All @@ -829,7 +825,7 @@ export class ImageEdit extends Component {
<>
{ getInspectorControls( imageWidth, imageHeight ) }
<div style={ { width, height } }>
{ imgContainer }
{ img }
</div>
</>
);
Expand Down Expand Up @@ -897,11 +893,7 @@ export class ImageEdit extends Component {
bottom: true,
left: showLeftHandle,
} }

onResizeStart={ () => {
toggleSelection( false );
} }

onResizeStart={ onResizeStart }
onResizeStop={ ( event, direction, elt, delta ) => {
onResizeStop();
setAttributes( {
Expand All @@ -910,7 +902,7 @@ export class ImageEdit extends Component {
} );
} }
>
{ imgContainer }
{ img }
</ResizableBox>
</>
);
Expand Down
27 changes: 4 additions & 23 deletions packages/block-library/src/image/editor.scss
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
.wp-block-image {
position: relative;

&.is-transient .wp-block-image__image-wrapper {
&.is-transient img {
opacity: 0.3;
}

figcaption img {
display: inline;
}

.wp-block-image__image-wrapper {
-webkit-background-size: cover;
background-size: cover;
background-repeat: no-repeat;
background-position: 50% 50%;
img {
opacity: 0;
margin: 0;
padding: 0;
}
}

// Shown while image is being uploaded
.components-spinner {
position: absolute;
Expand Down Expand Up @@ -125,18 +113,11 @@
}
}



// Joint behavior between align and expand.
[data-type="core/image"][data-expand="screen"] {
.wp-block-image__image-wrapper,
.wp-block-image__image-wrapper img {
[data-type="core/image"][data-align="fullScreen"] {
figure img {
width: 100%;
height: 100vh;
}

&:not([data-align="wide"]):not([data-align="full"]) .wp-block-image__image-wrapper {
display: inline-block;
}
}

// This is similar to above but for resized unfloated images only, where the markup is different.
Expand Down
18 changes: 0 additions & 18 deletions packages/block-library/src/image/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,31 +59,13 @@
}
}

.wp-block-image .wp-block-image__image-wrapper {
-webkit-background-size: cover;
background-size: cover;
background-repeat: no-repeat;
background-position: 50% 50%;
}

.wp-block-image.expandscreen,
.wp-block-image .expandscreen {
.wp-block-image__image-wrapper {
height: 100vh;
}

&.alignnone {
display: inline-block;
}

&.aligncenter .wp-block-image__image-wrapper {
display: inline-block;
}

&.alignfull .wp-block-image__image-wrapper {
width: 100vw;
}

img {
height: 100vh;
opacity: 0;
Expand Down

0 comments on commit 31ef94b

Please sign in to comment.