-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Add stylebook screen for classic themes #66851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
4bca433
Boilerplate for classic stylebook
tellthemachines 75b8d04
Add provider and settings
tellthemachines 450891a
Fix link to dashboard
tellthemachines 34a8ce9
Add customizer styles to the editor.
tellthemachines 92dd468
Integrate overview section.
tellthemachines 7085e03
Make items non-clickable
tellthemachines ead2507
Display classic theme color and gradient palettes
tellthemachines 7a2ca05
Remove aria label if area isn't clickable
tellthemachines 13f7efa
Update to use site editor layout with new route
tellthemachines 4578bf9
Make style book default mobile view
tellthemachines f333acc
Rename things to be more future proof
tellthemachines 9253755
update name
tellthemachines 1d1fdea
Canvas shouldn't go into edit mode when resizing
tellthemachines 21af508
Add core PR
tellthemachines 9439ddc
lint PHP
tellthemachines 63c2a95
Use site editor URL
tellthemachines 2c93c4d
remove whitespace
tellthemachines f811ec3
Check existence of $submenu global
tellthemachines 7727bbd
Update to single entry point for Stylebook and Patterns
tellthemachines a59c4b3
Remove wp_die handler as it's been added elsewhere
tellthemachines 46341c5
Switch back mobile view
tellthemachines 6f5bcac
Try showing the site preview instead of stylebook as Design entry point
tellthemachines cd0d065
Update Styles section sidebar to go back to Design
tellthemachines 157108c
Remove top margin in preview
tellthemachines f230ba1
Update strings
tellthemachines 9bb739b
only allow users with appropriate permissions
tellthemachines 1e591b4
Move styles submenu item into compat folder
tellthemachines 35a38c8
remove require
tellthemachines 70bd056
Make preview very non-interactive
tellthemachines a122f2d
Make duotones work if declared.
tellthemachines fa9f97e
Only show Design submenu item if theme supports editor styles
tellthemachines 0a50d01
Support theme.json in the absence of editor styles.
tellthemachines 78d25eb
useMultiOriginPalettes instead of complicated logic
tellthemachines bc91ba9
Try fixing routes
tellthemachines 344964d
Make sure editor canvas button exists
tellthemachines 2dbc13f
Default value for prop
tellthemachines 859de22
Add a test for classic style book
tellthemachines File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.