Skip to content

Commit

Permalink
fix: Additional styles story.
Browse files Browse the repository at this point in the history
  • Loading branch information
vipul0425 committed Dec 20, 2024
1 parent 8d8c185 commit 510885e
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { registerCoreBlocks } from '@wordpress/block-library';
/**
* Internal dependencies
*/
import BlockPreview from '../index';
import BlockPreview from '..';
import { BlockEditorProvider } from '../../provider';

// Register core blocks to be used in the preview.
registerCoreBlocks();
Expand Down Expand Up @@ -63,7 +64,7 @@ const meta = {
},
additionalStyles: {
description:
'Additional styles to apply to the preview iframe as an array of CSS rules.',
'Additional styles to apply to the preview iframe as an array of CSS rules. Each object should contain a `css` attribute.',
control: 'object',
table: {
type: {
Expand All @@ -78,7 +79,11 @@ export default meta;

export const Default = {
render: function Template( args ) {
return <BlockPreview { ...args } />;
return (
<BlockEditorProvider settings={ { styles: [] } }>
<BlockPreview { ...args } />
</BlockEditorProvider>
);
},
args: {
blocks: sampleBlocks,
Expand All @@ -90,12 +95,16 @@ export const Default = {

export const CustomStyles = {
render: function Template( args ) {
return <BlockPreview { ...args } />;
return (
<BlockEditorProvider settings={ { styles: [] } }>
<BlockPreview { ...args } />
</BlockEditorProvider>
);
},
args: {
blocks: sampleBlocks,
viewportWidth: 1200,
minHeight: 100,
additionalStyles: [ { css: `body { color: #ff0000; }` } ],
additionalStyles: [ { css: `p { color: #ff0000; }` } ],
},
};

0 comments on commit 510885e

Please sign in to comment.