Skip to content

Commit

Permalink
revert defaultPadding and alignment APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
madhusudhand committed Dec 6, 2022
1 parent 6103787 commit b287560
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 40 deletions.
11 changes: 0 additions & 11 deletions docs/reference-guides/block-api/block-registration.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,17 +227,6 @@ example: {
},
```

It's possible to set padding for the block in the preview container via `defaultPadding`. For example:

```js
example: {
attributes: {
cover: 'https://example.com/image.jpg',
},
defaultPadding: '8px 16px'
},
```

#### variations (optional)

- **Type:** `Object[]`
Expand Down
19 changes: 1 addition & 18 deletions packages/block-editor/src/components/block-preview/auto.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ function ScaledBlockPreview( {
MemoizedBlockList = MemoizedBlockList || pure( BlockList );

const scale = containerWidth / viewportWidth;

const padding =
typeof __experimentalPadding === 'string'
? __experimentalPadding
: `${ __experimentalPadding }px`;

return (
<Disabled
className="block-editor-block-preview__content"
Expand All @@ -95,23 +89,12 @@ function ScaledBlockPreview( {
);
documentElement.style.position = 'absolute';
documentElement.style.width = '100%';
documentElement.style.minHeight = '100%';
bodyElement.style.padding = padding;
bodyElement.style.padding = __experimentalPadding + 'px';

// Necessary for contentResizeListener to work.
bodyElement.style.boxSizing = 'border-box';
bodyElement.style.position = 'absolute';
bodyElement.style.width = '100%';
bodyElement.style.minHeight = `${ __experimentalMinHeight }px`;

if ( __experimentalAlign || __experimentalJustify ) {
bodyElement.style.display = 'flex';
bodyElement.style.flexDirection = 'column';
bodyElement.style.alignItems =
__experimentalJustify || 'flex-start';
bodyElement.style.justifyContent =
__experimentalAlign || 'flex-start';
}
}, [] ) }
aria-hidden
tabIndex={ -1 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import { BlockListItems } from '../block-list';

export function BlockPreview( {
blocks,
viewportWidth = 1200,
__experimentalPadding = 0,
viewportWidth = 1200,
__experimentalMinHeight,
__experimentalStyles = [],
} ) {
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/buttons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const settings = {
attributes: { text: __( 'Contact us' ) },
},
],
defaultPadding: '1rem',
},
deprecated,
transforms,
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export const settings = {
// translators: Caption accompanying an image of the Mont Blanc, which serves as an example for the Image block.
caption: __( 'Mont Blanc appears—still, snowy, and serene.' ),
},
defaultPadding: '1rem',
},
__experimentalLabel( attributes, { context } ) {
if ( context === 'accessibility' ) {
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/media-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export const settings = {
},
},
],
defaultPadding: '1rem',
},
transforms,
edit,
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/pullquote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export const settings = {
),
citation: __( 'Matt Mullenweg' ),
},
defaultPadding: '1rem',
},
transforms,
edit,
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ export const settings = {
],
},
viewportWidth: 450,
defaultPadding: '1rem',
},
transforms,
edit,
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/video/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export const settings = {
// translators: Caption accompanying a video of the wood thrush singing, which serves as an example for the Video block.
caption: __( 'Wood thrush singing in Central Park, NYC.' ),
},
defaultPadding: '1rem',
},
transforms,
deprecated,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const BlockPreviewPanel = ( { name } ) => {
containerResizeListener,
{ width: containerWidth, height: containerHeight },
] = useResizeObserver();
const padding = blockExample?.defaultPadding || 0;
const viewportWidth = blockExample?.viewportWidth || containerWidth;

return ! blockExample ? null : (
Expand All @@ -20,10 +19,7 @@ const BlockPreviewPanel = ( { name } ) => {

<BlockPreview
viewportWidth={ viewportWidth }
__experimentalPadding={ padding }
__experimentalMinHeight={ containerHeight }
__experimentalAlign={ 'center' }
__experimentalJustify={ 'center' }
blocks={ getBlockFromExample( name, blockExample ) }
/>
</div>
Expand Down

0 comments on commit b287560

Please sign in to comment.