-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 <isabel_brison@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org> Co-authored-by: ramonjd <ramonopoly@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: jasmussen <joen@git.wordpress.org> Co-authored-by: annezazu <annezazu@git.wordpress.org> Co-authored-by: mtias <matveb@git.wordpress.org> Co-authored-by: carlomanf <manfcarlo@git.wordpress.org> Co-authored-by: daveloodts <davelo@git.wordpress.org> Co-authored-by: cbirdsong <cbirdsong@git.wordpress.org> Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org> Co-authored-by: mrwweb <mrwweb@git.wordpress.org> Co-authored-by: ltrihan <ltrihan@git.wordpress.org> Co-authored-by: masteradhoc <masteradhoc@git.wordpress.org>
- 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.