forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Style Book to Global Styles (WordPress#45960)
* Add Style Book * Disable toolbar butons when Style Book is open * Disable Style Book when in Code Editor mode * Make cursor a hand when hovering an example * Remove top and bottom margin from block inside preview * Add border beneath tab bar, make tab bar scroll on mobile * Improve performance * Improve a11y * Add E2E tests * Make example titles uppercase * Hide toolbar when Style Book is open * Make tabs always have white background * Update tests * Add a little note of encouragement for future developers * Add border radius to Story Book * Fix vertical alignment of close button * Reduce font size and increase font weight of example labels * Remove hover outline * Use theme color for text instead of white or black * Use math.div()
- Loading branch information
1 parent
2a661c9
commit 8a08f6b
Showing
15 changed files
with
762 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
packages/edit-site/src/components/block-editor/editor-canvas.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
__experimentalUseResizeCanvas as useResizeCanvas, | ||
__unstableEditorStyles as EditorStyles, | ||
__unstableIframe as Iframe, | ||
__unstableUseMouseMoveTypingReset as useMouseMoveTypingReset, | ||
store as blockEditorStore, | ||
} from '@wordpress/block-editor'; | ||
import { useSelect } from '@wordpress/data'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { store as editSiteStore } from '../../store'; | ||
|
||
function EditorCanvas( { enableResizing, settings, children, ...props } ) { | ||
const { deviceType, isZoomOutMode } = useSelect( | ||
( select ) => ( { | ||
deviceType: | ||
select( editSiteStore ).__experimentalGetPreviewDeviceType(), | ||
isZoomOutMode: | ||
select( blockEditorStore ).__unstableGetEditorMode() === | ||
'zoom-out', | ||
} ), | ||
[] | ||
); | ||
const deviceStyles = useResizeCanvas( deviceType ); | ||
const mouseMoveTypingRef = useMouseMoveTypingReset(); | ||
return ( | ||
<Iframe | ||
scale={ ( isZoomOutMode && 0.45 ) || undefined } | ||
frameSize={ isZoomOutMode ? 100 : undefined } | ||
style={ enableResizing ? {} : deviceStyles } | ||
head={ | ||
<> | ||
<EditorStyles styles={ settings.styles } /> | ||
<style>{ | ||
// Forming a "block formatting context" to prevent margin collapsing. | ||
// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context | ||
`.is-root-container { display: flow-root; } | ||
body { position: relative; }` | ||
}</style> | ||
{ enableResizing && ( | ||
<style> | ||
{ | ||
// Some themes will have `min-height: 100vh` for the root container, | ||
// which isn't a requirement in auto resize mode. | ||
`.is-root-container { min-height: 0 !important; }` | ||
} | ||
</style> | ||
) } | ||
</> | ||
} | ||
assets={ settings.__unstableResolvedAssets } | ||
ref={ mouseMoveTypingRef } | ||
name="editor-canvas" | ||
className="edit-site-visual-editor__editor-canvas" | ||
{ ...props } | ||
> | ||
{ /* Filters need to be rendered before children to avoid Safari rendering issues. */ } | ||
{ settings.svgFilters } | ||
{ children } | ||
</Iframe> | ||
); | ||
} | ||
|
||
export default EditorCanvas; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.