-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add stylebook screen for classic themes (#66851)
Unlinked contributors: acketon. Co-authored-by: tellthemachines <[email protected]> Co-authored-by: youknowriad <[email protected]> Co-authored-by: ramonjd <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: jasmussen <[email protected]> Co-authored-by: annezazu <[email protected]> Co-authored-by: mtias <[email protected]> Co-authored-by: carlomanf <[email protected]> Co-authored-by: daveloodts <[email protected]> Co-authored-by: cbirdsong <[email protected]> Co-authored-by: fabiankaegy <[email protected]> Co-authored-by: mrwweb <[email protected]> Co-authored-by: ltrihan <[email protected]> Co-authored-by: masteradhoc <[email protected]>
- Loading branch information
1 parent
f430cd7
commit 7159a78
Showing
17 changed files
with
375 additions
and
97 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
https://github.com/WordPress/wordpress-develop/pull/7865 | ||
|
||
* https://github.com/WordPress/gutenberg/pull/66851 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
|
||
import { store as coreStore } from '@wordpress/core-data'; | ||
import { useSelect } from '@wordpress/data'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
|
||
import Editor from '../editor'; | ||
|
||
export function MaybeEditor( { showEditor = true } ) { | ||
const { isBlockBasedTheme, siteUrl } = useSelect( ( select ) => { | ||
const { getEntityRecord, getCurrentTheme } = select( coreStore ); | ||
const siteData = getEntityRecord( 'root', '__unstableBase' ); | ||
|
||
return { | ||
isBlockBasedTheme: getCurrentTheme()?.is_block_theme, | ||
siteUrl: siteData?.home, | ||
}; | ||
}, [] ); | ||
|
||
// If theme is block based, return the Editor, otherwise return the site preview. | ||
return isBlockBasedTheme || showEditor ? ( | ||
<Editor /> | ||
) : ( | ||
<iframe | ||
src={ siteUrl } | ||
title={ __( 'Site Preview' ) } | ||
style={ { | ||
display: 'block', | ||
width: '100%', | ||
height: '100%', | ||
backgroundColor: '#fff', | ||
} } | ||
onLoad={ ( event ) => { | ||
// Hide the admin bar in the front-end preview. | ||
const document = event.target.contentDocument; | ||
document.getElementById( 'wpadminbar' ).remove(); | ||
document | ||
.getElementsByTagName( 'html' )[ 0 ] | ||
.setAttribute( 'style', 'margin-top: 0 !important;' ); | ||
// Make interactive elements unclickable. | ||
const interactiveElements = document.querySelectorAll( | ||
'a, button, input, details, audio' | ||
); | ||
interactiveElements.forEach( ( element ) => { | ||
element.style.pointerEvents = 'none'; | ||
element.tabIndex = -1; | ||
element.setAttribute( 'aria-hidden', 'true' ); | ||
} ); | ||
} } | ||
/> | ||
); | ||
} |
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
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 |
---|---|---|
@@ -1,15 +1,15 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import Editor from '../editor'; | ||
import SidebarNavigationScreenMain from '../sidebar-navigation-screen-main'; | ||
import { MaybeEditor } from '../maybe-editor'; | ||
|
||
export const homeRoute = { | ||
name: 'home', | ||
path: '/', | ||
areas: { | ||
sidebar: <SidebarNavigationScreenMain />, | ||
preview: <Editor />, | ||
preview: <MaybeEditor showEditor={ false } />, | ||
mobile: <SidebarNavigationScreenMain />, | ||
}, | ||
}; |
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
28 changes: 28 additions & 0 deletions
28
packages/edit-site/src/components/site-editor-routes/stylebook.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,28 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import SidebarNavigationScreen from '../sidebar-navigation-screen'; | ||
import { StyleBookPreview } from '../style-book'; | ||
|
||
export const stylebookRoute = { | ||
name: 'stylebook', | ||
path: '/stylebook', | ||
areas: { | ||
sidebar: ( | ||
<SidebarNavigationScreen | ||
title={ __( 'Styles' ) } | ||
backPath="/" | ||
description={ __( | ||
`Preview your website's visual identity: colors, typography, and blocks.` | ||
) } | ||
/> | ||
), | ||
preview: <StyleBookPreview />, | ||
mobile: <StyleBookPreview />, | ||
}, | ||
}; |
6 changes: 3 additions & 3 deletions
6
packages/edit-site/src/components/site-editor-routes/template-item.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 |
---|---|---|
@@ -1,15 +1,15 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import Editor from '../editor'; | ||
import { MaybeEditor } from '../maybe-editor'; | ||
import SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse'; | ||
|
||
export const templateItemRoute = { | ||
name: 'template-item', | ||
path: '/wp_template/*postId', | ||
areas: { | ||
sidebar: <SidebarNavigationScreenTemplatesBrowse backPath="/" />, | ||
mobile: <Editor />, | ||
preview: <Editor />, | ||
mobile: <MaybeEditor />, | ||
preview: <MaybeEditor />, | ||
}, | ||
}; |
Oops, something went wrong.