Repository navigation
Style states: Add footer viewport and responsive styles status #84146
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
7 commits
Select commit
Hold shift + click to select a range
a9887c7
Editor: Add responsive viewport status to the footer
talldan 39e15f5
Editor: Link footer changelog to #84146
talldan 5ea75ff
Editor: Cover footer visibility in preferences e2e test
talldan dfe5944
Editor: Hide responsive style indicators on the default viewport
talldan df7a022
Editor: Disable responsive styles on the default viewport
talldan 90d1a81
Editor: Simplify footer status changelog entry
talldan 9827f91
Editor: Hide viewport dimensions when the canvas is constrained
talldan 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
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
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 |
|---|---|---|
|
|
@@ -2,7 +2,6 @@ import clsx from 'clsx'; | |
| import { useViewportMatch } from '@wordpress/compose'; | ||
| import { Button } from '@wordpress/components'; | ||
| import { __ } from '@wordpress/i18n'; | ||
| import { desktop, mobile, tablet } from '@wordpress/icons'; | ||
| import { useSelect, useDispatch } from '@wordpress/data'; | ||
| import { useEffect, useRef } from '@wordpress/element'; | ||
| import { store as coreStore } from '@wordpress/core-data'; | ||
|
|
@@ -17,7 +16,10 @@ import MoreMenuItem from '../more-menu/more-menu-item'; | |
| import { toMenuItems } from '../more-menu/more-menu-submenu'; | ||
| import { PostPreviewMenuItem } from '../post-preview-button'; | ||
| import { sidebars } from '../sidebar/constants'; | ||
| import { VIEWPORT_STATE_BY_DEVICE_TYPE } from '../../utils/device-type'; | ||
| import { | ||
| DEVICE_TYPE_METADATA, | ||
| VIEWPORT_STATE_BY_DEVICE_TYPE, | ||
| } from '../../utils/device-type'; | ||
| import { unlock } from '../../lock-unlock'; | ||
|
|
||
| const { getViewportBreakpoints } = unlock( globalStylesEnginePrivateApis ); | ||
|
|
@@ -113,12 +115,6 @@ function PreviewMenu( { forceIsAutosaveable, disabled } ) { | |
| } | ||
| }; | ||
|
|
||
| const deviceIcons = { | ||
| desktop, | ||
| mobile, | ||
| tablet, | ||
| }; | ||
|
|
||
| /** | ||
| * The choices for the device type. | ||
| * Duplicated in block-editor block-visibility constants, and in the edit-site | ||
|
|
@@ -129,7 +125,7 @@ function PreviewMenu( { forceIsAutosaveable, disabled } ) { | |
| const choices = [ | ||
| { | ||
| value: 'Desktop', | ||
| label: __( 'Desktop' ), | ||
| label: DEVICE_TYPE_METADATA.Desktop.label, | ||
| info: isResponsiveEditing | ||
| ? __( 'Style all viewports.' ) | ||
| : __( 'Preview desktop viewport.' ), | ||
|
|
@@ -138,7 +134,7 @@ function PreviewMenu( { forceIsAutosaveable, disabled } ) { | |
| ? [ | ||
| { | ||
| value: 'Tablet', | ||
| label: __( 'Tablet' ), | ||
| label: DEVICE_TYPE_METADATA.Tablet.label, | ||
| info: isResponsiveEditing | ||
| ? __( 'Style tablet only.' ) | ||
| : __( 'Preview tablet viewport.' ), | ||
|
|
@@ -149,7 +145,7 @@ function PreviewMenu( { forceIsAutosaveable, disabled } ) { | |
| ? [ | ||
| { | ||
| value: 'Mobile', | ||
| label: __( 'Mobile' ), | ||
| label: DEVICE_TYPE_METADATA.Mobile.label, | ||
| info: isResponsiveEditing | ||
| ? __( 'Style mobile only.' ) | ||
| : __( 'Preview mobile viewport.' ), | ||
|
|
@@ -165,10 +161,11 @@ function PreviewMenu( { forceIsAutosaveable, disabled } ) { | |
| render={ | ||
| <Button | ||
| className={ clsx( 'editor-preview-dropdown__toggle', { | ||
| 'is-responsive-editing': isResponsiveEditing, | ||
| 'is-responsive-editing': | ||
| isResponsiveEditing && deviceType !== 'Desktop', | ||
| } ) } | ||
| size="compact" | ||
| icon={ deviceIcons[ deviceType.toLowerCase() ] } | ||
| icon={ DEVICE_TYPE_METADATA[ deviceType ].icon } | ||
| label={ __( 'View' ) } | ||
| showTooltip={ ! showIconLabels } | ||
| accessibleWhenDisabled={ disabled } | ||
|
|
@@ -202,6 +199,7 @@ function PreviewMenu( { forceIsAutosaveable, disabled } ) { | |
| <Menu.Separator /> | ||
| <Menu.Group> | ||
| <Menu.CheckboxItem | ||
| disabled={ deviceType === 'Desktop' } | ||
| checked={ isResponsiveEditing } | ||
| onCheckedChange={ | ||
| handleResponsiveEditingChange | ||
|
|
@@ -211,9 +209,13 @@ function PreviewMenu( { forceIsAutosaveable, disabled } ) { | |
| { __( 'Responsive styles' ) } | ||
| </Menu.ItemLabel> | ||
| <Menu.ItemDescription> | ||
| { __( | ||
| 'Style changes apply only to the selected viewport.' | ||
| ) } | ||
| { deviceType === 'Desktop' | ||
| ? __( | ||
| 'Select Tablet or Mobile to style a specific viewport.' | ||
| ) | ||
| : __( | ||
| 'Style changes apply only to the selected viewport.' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is also a good improvement! It was confusing to have 'Style changes apply only to the selected viewport.' on desktop. |
||
| ) } | ||
| </Menu.ItemDescription> | ||
| </Menu.CheckboxItem> | ||
| </Menu.Group> | ||
|
|
||
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
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.