Skip to content
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

Global styles revisions: integrate style book #56800

Merged
merged 7 commits into from
Dec 20, 2023

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented Dec 5, 2023

What?

Hopefully resolves #55577

Part of:

Adds a button to toggle the Style Book in global styles revisions.

Why?

So users can preview global styles revisions in the Style Book.

The Style Book displays more patterns and blocks and therefore affords users the possibility of previewing specific historical styles that may not appear in the currently-loaded template, e.g., changes to the Calendar block.

How?

Adding a second "global-styles-revisions:style-book" view to the editor canvas container that is activated when the Revisions and Style Book buttons are active.

Testing Instructions

  1. In the Global Styles panel, open the revisions view.
  2. Test that the Style Book button toggles the Style Book. And that the styles update as you move through the revision history.
  3. Check that the close button closes the Style Book view, but not revisions. A second click on the close button will exit revisions.
  4. Now return to the Global Styles panel. Click on the Style Book icon first, then the Revisions icon. Both icons should be in a pressed state with Revisions open using the Style Book in the canvas container.

Screenshots or screencast

2023-12-19.15.55.29.mp4

@ramonjd ramonjd changed the title Global styles revisions: integrate style book [WIP] Global styles revisions: integrate style book Dec 5, 2023
Copy link

github-actions bot commented Dec 5, 2023

Size Change: +185 B (0%)

Total Size: 1.71 MB

Filename Size Change
build/edit-site/index.min.js 194 kB +185 B (0%)
ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 964 B
build/annotations/index.min.js 2.71 kB
build/api-fetch/index.min.js 2.29 kB
build/autop/index.min.js 2.11 kB
build/blob/index.min.js 590 B
build/block-directory/index.min.js 7.25 kB
build/block-directory/style-rtl.css 1.04 kB
build/block-directory/style.css 1.04 kB
build/block-editor/content-rtl.css 4.29 kB
build/block-editor/content.css 4.28 kB
build/block-editor/default-editor-styles-rtl.css 403 B
build/block-editor/default-editor-styles.css 403 B
build/block-editor/index.min.js 245 kB
build/block-editor/style-rtl.css 15.2 kB
build/block-editor/style.css 15.2 kB
build/block-library/blocks/archives/editor-rtl.css 61 B
build/block-library/blocks/archives/editor.css 60 B
build/block-library/blocks/archives/style-rtl.css 90 B
build/block-library/blocks/archives/style.css 90 B
build/block-library/blocks/audio/editor-rtl.css 150 B
build/block-library/blocks/audio/editor.css 150 B
build/block-library/blocks/audio/style-rtl.css 122 B
build/block-library/blocks/audio/style.css 122 B
build/block-library/blocks/audio/theme-rtl.css 138 B
build/block-library/blocks/audio/theme.css 138 B
build/block-library/blocks/avatar/editor-rtl.css 116 B
build/block-library/blocks/avatar/editor.css 116 B
build/block-library/blocks/avatar/style-rtl.css 104 B
build/block-library/blocks/avatar/style.css 104 B
build/block-library/blocks/block/editor-rtl.css 305 B
build/block-library/blocks/block/editor.css 305 B
build/block-library/blocks/button/editor-rtl.css 587 B
build/block-library/blocks/button/editor.css 587 B
build/block-library/blocks/button/style-rtl.css 633 B
build/block-library/blocks/button/style.css 632 B
build/block-library/blocks/buttons/editor-rtl.css 337 B
build/block-library/blocks/buttons/editor.css 337 B
build/block-library/blocks/buttons/style-rtl.css 332 B
build/block-library/blocks/buttons/style.css 332 B
build/block-library/blocks/calendar/style-rtl.css 239 B
build/block-library/blocks/calendar/style.css 239 B
build/block-library/blocks/categories/editor-rtl.css 113 B
build/block-library/blocks/categories/editor.css 112 B
build/block-library/blocks/categories/style-rtl.css 124 B
build/block-library/blocks/categories/style.css 124 B
build/block-library/blocks/code/editor-rtl.css 53 B
build/block-library/blocks/code/editor.css 53 B
build/block-library/blocks/code/style-rtl.css 121 B
build/block-library/blocks/code/style.css 121 B
build/block-library/blocks/code/theme-rtl.css 124 B
build/block-library/blocks/code/theme.css 124 B
build/block-library/blocks/columns/editor-rtl.css 108 B
build/block-library/blocks/columns/editor.css 108 B
build/block-library/blocks/columns/style-rtl.css 421 B
build/block-library/blocks/columns/style.css 421 B
build/block-library/blocks/comment-author-avatar/editor-rtl.css 125 B
build/block-library/blocks/comment-author-avatar/editor.css 125 B
build/block-library/blocks/comment-content/style-rtl.css 92 B
build/block-library/blocks/comment-content/style.css 92 B
build/block-library/blocks/comment-template/style-rtl.css 199 B
build/block-library/blocks/comment-template/style.css 198 B
build/block-library/blocks/comments-pagination-numbers/editor-rtl.css 123 B
build/block-library/blocks/comments-pagination-numbers/editor.css 121 B
build/block-library/blocks/comments-pagination/editor-rtl.css 222 B
build/block-library/blocks/comments-pagination/editor.css 209 B
build/block-library/blocks/comments-pagination/style-rtl.css 235 B
build/block-library/blocks/comments-pagination/style.css 231 B
build/block-library/blocks/comments-title/editor-rtl.css 75 B
build/block-library/blocks/comments-title/editor.css 75 B
build/block-library/blocks/comments/editor-rtl.css 840 B
build/block-library/blocks/comments/editor.css 839 B
build/block-library/blocks/comments/style-rtl.css 637 B
build/block-library/blocks/comments/style.css 636 B
build/block-library/blocks/cover/editor-rtl.css 647 B
build/block-library/blocks/cover/editor.css 650 B
build/block-library/blocks/cover/style-rtl.css 1.7 kB
build/block-library/blocks/cover/style.css 1.69 kB
build/block-library/blocks/details/editor-rtl.css 65 B
build/block-library/blocks/details/editor.css 65 B
build/block-library/blocks/details/style-rtl.css 98 B
build/block-library/blocks/details/style.css 98 B
build/block-library/blocks/embed/editor-rtl.css 293 B
build/block-library/blocks/embed/editor.css 293 B
build/block-library/blocks/embed/style-rtl.css 410 B
build/block-library/blocks/embed/style.css 410 B
build/block-library/blocks/embed/theme-rtl.css 138 B
build/block-library/blocks/embed/theme.css 138 B
build/block-library/blocks/file/editor-rtl.css 316 B
build/block-library/blocks/file/editor.css 316 B
build/block-library/blocks/file/style-rtl.css 280 B
build/block-library/blocks/file/style.css 281 B
build/block-library/blocks/file/view.min.js 322 B
build/block-library/blocks/footnotes/style-rtl.css 201 B
build/block-library/blocks/footnotes/style.css 199 B
build/block-library/blocks/form-input/editor-rtl.css 229 B
build/block-library/blocks/form-input/editor.css 228 B
build/block-library/blocks/form-input/style-rtl.css 343 B
build/block-library/blocks/form-input/style.css 343 B
build/block-library/blocks/form-submission-notification/editor-rtl.css 343 B
build/block-library/blocks/form-submission-notification/editor.css 342 B
build/block-library/blocks/form-submit-button/style-rtl.css 69 B
build/block-library/blocks/form-submit-button/style.css 69 B
build/block-library/blocks/form/view.min.js 452 B
build/block-library/blocks/freeform/editor-rtl.css 2.61 kB
build/block-library/blocks/freeform/editor.css 2.61 kB
build/block-library/blocks/gallery/editor-rtl.css 957 B
build/block-library/blocks/gallery/editor.css 962 B
build/block-library/blocks/gallery/style-rtl.css 1.75 kB
build/block-library/blocks/gallery/style.css 1.75 kB
build/block-library/blocks/gallery/theme-rtl.css 122 B
build/block-library/blocks/gallery/theme.css 122 B
build/block-library/blocks/group/editor-rtl.css 654 B
build/block-library/blocks/group/editor.css 654 B
build/block-library/blocks/group/style-rtl.css 57 B
build/block-library/blocks/group/style.css 57 B
build/block-library/blocks/group/theme-rtl.css 78 B
build/block-library/blocks/group/theme.css 78 B
build/block-library/blocks/heading/style-rtl.css 189 B
build/block-library/blocks/heading/style.css 189 B
build/block-library/blocks/html/editor-rtl.css 340 B
build/block-library/blocks/html/editor.css 341 B
build/block-library/blocks/image/editor-rtl.css 834 B
build/block-library/blocks/image/editor.css 833 B
build/block-library/blocks/image/style-rtl.css 1.61 kB
build/block-library/blocks/image/style.css 1.6 kB
build/block-library/blocks/image/theme-rtl.css 137 B
build/block-library/blocks/image/theme.css 137 B
build/block-library/blocks/image/view.min.js 2.02 kB
build/block-library/blocks/latest-comments/style-rtl.css 357 B
build/block-library/blocks/latest-comments/style.css 357 B
build/block-library/blocks/latest-posts/editor-rtl.css 213 B
build/block-library/blocks/latest-posts/editor.css 212 B
build/block-library/blocks/latest-posts/style-rtl.css 478 B
build/block-library/blocks/latest-posts/style.css 478 B
build/block-library/blocks/list/style-rtl.css 88 B
build/block-library/blocks/list/style.css 88 B
build/block-library/blocks/media-text/editor-rtl.css 266 B
build/block-library/blocks/media-text/editor.css 263 B
build/block-library/blocks/media-text/style-rtl.css 505 B
build/block-library/blocks/media-text/style.css 503 B
build/block-library/blocks/more/editor-rtl.css 431 B
build/block-library/blocks/more/editor.css 431 B
build/block-library/blocks/navigation-link/editor-rtl.css 671 B
build/block-library/blocks/navigation-link/editor.css 672 B
build/block-library/blocks/navigation-link/style-rtl.css 103 B
build/block-library/blocks/navigation-link/style.css 103 B
build/block-library/blocks/navigation-submenu/editor-rtl.css 299 B
build/block-library/blocks/navigation-submenu/editor.css 299 B
build/block-library/blocks/navigation/editor-rtl.css 2.26 kB
build/block-library/blocks/navigation/editor.css 2.26 kB
build/block-library/blocks/navigation/style-rtl.css 2.27 kB
build/block-library/blocks/navigation/style.css 2.26 kB
build/block-library/blocks/navigation/view.min.js 1.04 kB
build/block-library/blocks/nextpage/editor-rtl.css 395 B
build/block-library/blocks/nextpage/editor.css 395 B
build/block-library/blocks/page-list/editor-rtl.css 401 B
build/block-library/blocks/page-list/editor.css 401 B
build/block-library/blocks/page-list/style-rtl.css 175 B
build/block-library/blocks/page-list/style.css 175 B
build/block-library/blocks/paragraph/editor-rtl.css 235 B
build/block-library/blocks/paragraph/editor.css 235 B
build/block-library/blocks/paragraph/style-rtl.css 335 B
build/block-library/blocks/paragraph/style.css 335 B
build/block-library/blocks/post-author/style-rtl.css 175 B
build/block-library/blocks/post-author/style.css 176 B
build/block-library/blocks/post-comments-form/editor-rtl.css 96 B
build/block-library/blocks/post-comments-form/editor.css 96 B
build/block-library/blocks/post-comments-form/style-rtl.css 508 B
build/block-library/blocks/post-comments-form/style.css 508 B
build/block-library/blocks/post-date/style-rtl.css 61 B
build/block-library/blocks/post-date/style.css 61 B
build/block-library/blocks/post-excerpt/editor-rtl.css 71 B
build/block-library/blocks/post-excerpt/editor.css 71 B
build/block-library/blocks/post-excerpt/style-rtl.css 141 B
build/block-library/blocks/post-excerpt/style.css 141 B
build/block-library/blocks/post-featured-image/editor-rtl.css 666 B
build/block-library/blocks/post-featured-image/editor.css 662 B
build/block-library/blocks/post-featured-image/style-rtl.css 345 B
build/block-library/blocks/post-featured-image/style.css 345 B
build/block-library/blocks/post-navigation-link/style-rtl.css 215 B
build/block-library/blocks/post-navigation-link/style.css 214 B
build/block-library/blocks/post-template/editor-rtl.css 99 B
build/block-library/blocks/post-template/editor.css 98 B
build/block-library/blocks/post-template/style-rtl.css 409 B
build/block-library/blocks/post-template/style.css 408 B
build/block-library/blocks/post-terms/style-rtl.css 96 B
build/block-library/blocks/post-terms/style.css 96 B
build/block-library/blocks/post-time-to-read/style-rtl.css 69 B
build/block-library/blocks/post-time-to-read/style.css 69 B
build/block-library/blocks/post-title/style-rtl.css 100 B
build/block-library/blocks/post-title/style.css 100 B
build/block-library/blocks/preformatted/style-rtl.css 125 B
build/block-library/blocks/preformatted/style.css 125 B
build/block-library/blocks/pullquote/editor-rtl.css 135 B
build/block-library/blocks/pullquote/editor.css 135 B
build/block-library/blocks/pullquote/style-rtl.css 335 B
build/block-library/blocks/pullquote/style.css 335 B
build/block-library/blocks/pullquote/theme-rtl.css 168 B
build/block-library/blocks/pullquote/theme.css 168 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 122 B
build/block-library/blocks/query-pagination-numbers/editor.css 121 B
build/block-library/blocks/query-pagination/editor-rtl.css 221 B
build/block-library/blocks/query-pagination/editor.css 211 B
build/block-library/blocks/query-pagination/style-rtl.css 288 B
build/block-library/blocks/query-pagination/style.css 284 B
build/block-library/blocks/query-title/style-rtl.css 63 B
build/block-library/blocks/query-title/style.css 63 B
build/block-library/blocks/query/editor-rtl.css 486 B
build/block-library/blocks/query/editor.css 486 B
build/block-library/blocks/query/style-rtl.css 312 B
build/block-library/blocks/query/style.css 308 B
build/block-library/blocks/query/view.min.js 647 B
build/block-library/blocks/quote/style-rtl.css 237 B
build/block-library/blocks/quote/style.css 237 B
build/block-library/blocks/quote/theme-rtl.css 223 B
build/block-library/blocks/quote/theme.css 226 B
build/block-library/blocks/read-more/style-rtl.css 140 B
build/block-library/blocks/read-more/style.css 140 B
build/block-library/blocks/rss/editor-rtl.css 149 B
build/block-library/blocks/rss/editor.css 149 B
build/block-library/blocks/rss/style-rtl.css 289 B
build/block-library/blocks/rss/style.css 288 B
build/block-library/blocks/search/editor-rtl.css 184 B
build/block-library/blocks/search/editor.css 184 B
build/block-library/blocks/search/style-rtl.css 613 B
build/block-library/blocks/search/style.css 613 B
build/block-library/blocks/search/theme-rtl.css 114 B
build/block-library/blocks/search/theme.css 114 B
build/block-library/blocks/search/view.min.js 475 B
build/block-library/blocks/separator/editor-rtl.css 146 B
build/block-library/blocks/separator/editor.css 146 B
build/block-library/blocks/separator/style-rtl.css 234 B
build/block-library/blocks/separator/style.css 234 B
build/block-library/blocks/separator/theme-rtl.css 194 B
build/block-library/blocks/separator/theme.css 194 B
build/block-library/blocks/shortcode/editor-rtl.css 329 B
build/block-library/blocks/shortcode/editor.css 329 B
build/block-library/blocks/site-logo/editor-rtl.css 760 B
build/block-library/blocks/site-logo/editor.css 760 B
build/block-library/blocks/site-logo/style-rtl.css 204 B
build/block-library/blocks/site-logo/style.css 204 B
build/block-library/blocks/site-tagline/editor-rtl.css 86 B
build/block-library/blocks/site-tagline/editor.css 86 B
build/block-library/blocks/site-title/editor-rtl.css 116 B
build/block-library/blocks/site-title/editor.css 116 B
build/block-library/blocks/site-title/style-rtl.css 57 B
build/block-library/blocks/site-title/style.css 57 B
build/block-library/blocks/social-link/editor-rtl.css 184 B
build/block-library/blocks/social-link/editor.css 184 B
build/block-library/blocks/social-links/editor-rtl.css 682 B
build/block-library/blocks/social-links/editor.css 681 B
build/block-library/blocks/social-links/style-rtl.css 1.49 kB
build/block-library/blocks/social-links/style.css 1.49 kB
build/block-library/blocks/spacer/editor-rtl.css 359 B
build/block-library/blocks/spacer/editor.css 359 B
build/block-library/blocks/spacer/style-rtl.css 48 B
build/block-library/blocks/spacer/style.css 48 B
build/block-library/blocks/table/editor-rtl.css 399 B
build/block-library/blocks/table/editor.css 399 B
build/block-library/blocks/table/style-rtl.css 646 B
build/block-library/blocks/table/style.css 645 B
build/block-library/blocks/table/theme-rtl.css 157 B
build/block-library/blocks/table/theme.css 157 B
build/block-library/blocks/tag-cloud/style-rtl.css 251 B
build/block-library/blocks/tag-cloud/style.css 253 B
build/block-library/blocks/template-part/editor-rtl.css 403 B
build/block-library/blocks/template-part/editor.css 403 B
build/block-library/blocks/template-part/theme-rtl.css 101 B
build/block-library/blocks/template-part/theme.css 101 B
build/block-library/blocks/term-description/style-rtl.css 111 B
build/block-library/blocks/term-description/style.css 111 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B
build/block-library/blocks/text-columns/editor.css 95 B
build/block-library/blocks/text-columns/style-rtl.css 166 B
build/block-library/blocks/text-columns/style.css 166 B
build/block-library/blocks/verse/style-rtl.css 99 B
build/block-library/blocks/verse/style.css 99 B
build/block-library/blocks/video/editor-rtl.css 552 B
build/block-library/blocks/video/editor.css 555 B
build/block-library/blocks/video/style-rtl.css 191 B
build/block-library/blocks/video/style.css 191 B
build/block-library/blocks/video/theme-rtl.css 139 B
build/block-library/blocks/video/theme.css 139 B
build/block-library/classic-rtl.css 179 B
build/block-library/classic.css 179 B
build/block-library/common-rtl.css 1.11 kB
build/block-library/common.css 1.11 kB
build/block-library/editor-elements-rtl.css 75 B
build/block-library/editor-elements.css 75 B
build/block-library/editor-rtl.css 12.4 kB
build/block-library/editor.css 12.4 kB
build/block-library/elements-rtl.css 54 B
build/block-library/elements.css 54 B
build/block-library/index.min.js 214 kB
build/block-library/reset-rtl.css 472 B
build/block-library/reset.css 472 B
build/block-library/style-rtl.css 14.7 kB
build/block-library/style.css 14.7 kB
build/block-library/theme-rtl.css 700 B
build/block-library/theme.css 705 B
build/block-serialization-default-parser/index.min.js 1.13 kB
build/block-serialization-spec-parser/index.min.js 2.87 kB
build/blocks/index.min.js 51.3 kB
build/commands/index.min.js 15.5 kB
build/commands/style-rtl.css 947 B
build/commands/style.css 942 B
build/components/index.min.js 257 kB
build/components/style-rtl.css 12.1 kB
build/components/style.css 12.1 kB
build/compose/index.min.js 12.8 kB
build/core-commands/index.min.js 2.73 kB
build/core-data/index.min.js 72.7 kB
build/customize-widgets/index.min.js 12.1 kB
build/customize-widgets/style-rtl.css 1.36 kB
build/customize-widgets/style.css 1.36 kB
build/data-controls/index.min.js 651 B
build/data/index.min.js 8.94 kB
build/date/index.min.js 17.9 kB
build/deprecated/index.min.js 462 B
build/dom-ready/index.min.js 336 B
build/dom/index.min.js 4.68 kB
build/edit-post/classic-rtl.css 571 B
build/edit-post/classic.css 571 B
build/edit-post/index.min.js 31.4 kB
build/edit-post/style-rtl.css 7.16 kB
build/edit-post/style.css 7.15 kB
build/edit-site/style-rtl.css 14.7 kB
build/edit-site/style.css 14.8 kB
build/edit-widgets/index.min.js 17.7 kB
build/edit-widgets/style-rtl.css 4.71 kB
build/edit-widgets/style.css 4.71 kB
build/editor/index.min.js 55.1 kB
build/editor/style-rtl.css 4.38 kB
build/editor/style.css 4.38 kB
build/element/index.min.js 4.87 kB
build/escape-html/index.min.js 548 B
build/format-library/index.min.js 7.76 kB
build/format-library/style-rtl.css 577 B
build/format-library/style.css 577 B
build/hooks/index.min.js 1.57 kB
build/html-entities/index.min.js 454 B
build/i18n/index.min.js 3.61 kB
build/interactivity/file.min.js 442 B
build/interactivity/image.min.js 2.15 kB
build/interactivity/index.min.js 12.5 kB
build/interactivity/navigation.min.js 1.16 kB
build/interactivity/query.min.js 791 B
build/interactivity/search.min.js 610 B
build/is-shallow-equal/index.min.js 535 B
build/keyboard-shortcuts/index.min.js 1.76 kB
build/keycodes/index.min.js 1.49 kB
build/list-reusable-blocks/index.min.js 2.11 kB
build/list-reusable-blocks/style-rtl.css 865 B
build/list-reusable-blocks/style.css 865 B
build/media-utils/index.min.js 2.92 kB
build/modules/importmap-polyfill.min.js 12.2 kB
build/notices/index.min.js 964 B
build/nux/index.min.js 2.01 kB
build/nux/style-rtl.css 775 B
build/nux/style.css 771 B
build/patterns/index.min.js 5.27 kB
build/patterns/style-rtl.css 564 B
build/patterns/style.css 564 B
build/plugins/index.min.js 1.81 kB
build/preferences-persistence/index.min.js 1.85 kB
build/preferences/index.min.js 1.26 kB
build/primitives/index.min.js 994 B
build/priority-queue/index.min.js 1.52 kB
build/private-apis/index.min.js 994 B
build/react-i18n/index.min.js 631 B
build/react-refresh-entry/index.min.js 9.46 kB
build/react-refresh-runtime/index.min.js 6.78 kB
build/redux-routine/index.min.js 2.71 kB
build/reusable-blocks/index.min.js 2.74 kB
build/reusable-blocks/style-rtl.css 265 B
build/reusable-blocks/style.css 265 B
build/rich-text/index.min.js 10.5 kB
build/router/index.min.js 1.79 kB
build/server-side-render/index.min.js 1.96 kB
build/shortcode/index.min.js 1.4 kB
build/style-engine/index.min.js 1.98 kB
build/token-list/index.min.js 587 B
build/url/index.min.js 3.83 kB
build/vendors/inert-polyfill.min.js 2.48 kB
build/vendors/react-dom.min.js 41.8 kB
build/vendors/react.min.js 4.02 kB
build/viewport/index.min.js 967 B
build/warning/index.min.js 259 B
build/widgets/index.min.js 7.18 kB
build/widgets/style-rtl.css 1.18 kB
build/widgets/style.css 1.18 kB
build/wordcount/index.min.js 1.03 kB

compressed-size-action

Copy link

github-actions bot commented Dec 5, 2023

Flaky tests detected in d1307e6.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7242922633
📝 Reported issues:

@ramonjd ramonjd self-assigned this Dec 6, 2023
@ramonjd ramonjd added [Type] Enhancement A suggestion for improvement. [Status] In Progress Tracking issues with work in progress Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Dec 6, 2023
@ramonjd ramonjd force-pushed the try/global-styles-revisions-show-style-book branch from e43943b to a6a11e4 Compare December 13, 2023 03:28
@@ -57,6 +78,20 @@ export default function GlobalStylesSidebar() {
}, [ shouldClearCanvasContainerView ] );

const { setIsListViewOpened } = useDispatch( editSiteStore );
const { goTo } = useNavigator();
const loadRevisions = () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved the revision icon in the styles panel header here to make it easier to work with style book vars.

That's the theory 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this change might not be needed. Might be a okay for a follow up as it consolidates styles actions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const settings = useMemo(
() => ( { ...originalSettings, __unstableIsPreviewMode: true } ),
[ originalSettings ]
);

const [ globalStyles ] = useGlobalStylesOutputWithConfig( mergedConfig );
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This repeats what <Revisions /> does. Should perhaps abstract into a hook

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, the refactor goes deep 😄

I might do it in a follow up.

The plan:

  • add and export a new function useGlobalStylesOutputWithCustomConfig( customConfig: GlobaStylesObject ) or something to use-global-styles-output.js
  • Move and export the util mergeBaseAndUserConfigs from global-styles-provider.js to use-global-styles-output.js and update all usages.
  • Use useGlobalStylesOutputWithCustomConfig in Revisions and Style Book

Note to self - working diff:

Diff
diff --git a/packages/block-editor/src/components/global-styles/index.js b/packages/block-editor/src/components/global-styles/index.js
index 76a95357ba..e7f965fe24 100644
--- a/packages/block-editor/src/components/global-styles/index.js
+++ b/packages/block-editor/src/components/global-styles/index.js
@@ -9,6 +9,7 @@ export {
 	getLayoutStyles,
 	useGlobalStylesOutput,
 	useGlobalStylesOutputWithConfig,
+	useGlobalStylesOutputWithCustomConfig,
 } from './use-global-styles-output';
 export { GlobalStylesContext } from './context';
 export {
diff --git a/packages/block-editor/src/components/global-styles/use-global-styles-output.js b/packages/block-editor/src/components/global-styles/use-global-styles-output.js
index 7e99eca355..37996587de 100644
--- a/packages/block-editor/src/components/global-styles/use-global-styles-output.js
+++ b/packages/block-editor/src/components/global-styles/use-global-styles-output.js
@@ -1,3 +1,8 @@
+/**
+ * External dependencies
+ */
+import deepmerge from 'deepmerge';
+
 /**
  * WordPress dependencies
  */
@@ -38,6 +43,7 @@ import {
 	setImmutably,
 } from '../../utils/object';
 import BlockContext from '../block-context';
+import { isPlainObject } from 'is-plain-object';
 
 // List of block support features that can have their related styles
 // generated under their own feature level selector rather than the block's.
@@ -48,6 +54,23 @@ const BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = {
 	typography: 'typography',
 };
 
+
+function isObjectEmpty( object ) {
+	return ! object || Object.keys( object ).length === 0;
+}
+
+// Copied from packages/edit-site/src/components/global-styles/global-styles-provider.js
+// @todo: this should be exported and used from here?
+export function mergeBaseAndUserConfigs( base, user ) {
+	return deepmerge( base, user, {
+		// We only pass as arrays the presets,
+		// in which case we want the new array of values
+		// to override the old array (no merging).
+		isMergeableObject: isPlainObject,
+	} );
+}
+
+
 function compileStyleValue( uncompiledValue ) {
 	const VARIABLE_REFERENCE_PREFIX = 'var:';
 	const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
@@ -1264,3 +1287,35 @@ export function useGlobalStylesOutput() {
 	const { merged: mergedConfig } = useContext( GlobalStylesContext );
 	return useGlobalStylesOutputWithConfig( mergedConfig );
 }
+
+/**
+ * Like useGlobalStylesOutputWithConfig but returns global style output by
+ * merging incoming "overrides" with base config and settings.
+ *
+ * The use case is to output real-time changes to global styles based on custom configs
+ * other than `userConfig`, for example historical global styles changes (revisions).
+ *
+ * @param {Object} customConfig A custom global styles configuration.
+ * @return {Array|undefined}    Array of global styles stylesheets and settings. Undefined if no styles are output.
+ */
+export function useGlobalStylesOutputWithCustomConfig( customConfig ) {
+	const { base: baseConfig } = useContext( GlobalStylesContext );
+
+	const mergedConfig = useMemo( () => {
+		if (
+			! isObjectEmpty( customConfig ) &&
+			! isObjectEmpty( baseConfig )
+		) {
+			return mergeBaseAndUserConfigs( baseConfig, customConfig );
+		}
+		return {};
+	}, [ baseConfig, customConfig ] );
+
+	const [ globalStyles ] = useGlobalStylesOutputWithConfig( mergedConfig );
+
+	if ( ! isObjectEmpty( globalStyles ) && ! isObjectEmpty( customConfig ) ) {
+		return globalStyles;
+	}
+
+	return undefined;
+}
diff --git a/packages/edit-site/src/components/revisions/index.js b/packages/edit-site/src/components/revisions/index.js
index aeb7779d06..ba1b53730d 100644
--- a/packages/edit-site/src/components/revisions/index.js
+++ b/packages/edit-site/src/components/revisions/index.js
@@ -6,52 +6,30 @@ import { __ } from '@wordpress/i18n';
 import {
 	BlockList,
 	privateApis as blockEditorPrivateApis,
-	store as blockEditorStore,
 	__unstableEditorStyles as EditorStyles,
+	store as blockEditorStore,
 	__unstableIframe as Iframe,
 } from '@wordpress/block-editor';
 import { useSelect } from '@wordpress/data';
 import { useMemo } from '@wordpress/element';
-import { store as coreStore } from '@wordpress/core-data';
 
 /**
  * Internal dependencies
  */
 
 import { unlock } from '../../lock-unlock';
-import { mergeBaseAndUserConfigs } from '../global-styles/global-styles-provider';
 import EditorCanvasContainer from '../editor-canvas-container';
 
-const { ExperimentalBlockEditorProvider, useGlobalStylesOutputWithConfig } =
-	unlock( blockEditorPrivateApis );
-
-function isObjectEmpty( object ) {
-	return ! object || Object.keys( object ).length === 0;
-}
+const {
+	ExperimentalBlockEditorProvider,
+	useGlobalStylesOutputWithCustomConfig,
+} = unlock( blockEditorPrivateApis );
 
 function Revisions( { actions, userConfig, blocks } ) {
-	const { baseConfig } = useSelect(
-		( select ) => ( {
-			baseConfig:
-				select(
-					coreStore
-				).__experimentalGetCurrentThemeBaseGlobalStyles(),
-		} ),
-		[]
-	);
-
-	const mergedConfig = useMemo( () => {
-		if ( ! isObjectEmpty( userConfig ) && ! isObjectEmpty( baseConfig ) ) {
-			return mergeBaseAndUserConfigs( baseConfig, userConfig );
-		}
-		return {};
-	}, [ baseConfig, userConfig ] );
-
 	const renderedBlocksArray = useMemo(
 		() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),
 		[ blocks ]
 	);
-
 	const originalSettings = useSelect(
 		( select ) => select( blockEditorStore ).getSettings(),
 		[]
@@ -60,13 +38,8 @@ function Revisions( { actions, userConfig, blocks } ) {
 		() => ( { ...originalSettings, __unstableIsPreviewMode: true } ),
 		[ originalSettings ]
 	);
-
-	const [ globalStyles ] = useGlobalStylesOutputWithConfig( mergedConfig );
-
 	const editorStyles =
-		! isObjectEmpty( globalStyles ) && ! isObjectEmpty( userConfig )
-			? globalStyles
-			: settings.styles;
+		useGlobalStylesOutputWithCustomConfig( userConfig ) || settings.styles;
 
 	return (
 		<EditorCanvasContainer
diff --git a/packages/edit-site/src/components/style-book/index.js b/packages/edit-site/src/components/style-book/index.js
index 2194920b18..4efd26a1f0 100644
--- a/packages/edit-site/src/components/style-book/index.js
+++ b/packages/edit-site/src/components/style-book/index.js
@@ -29,19 +29,17 @@ import { useSelect } from '@wordpress/data';
 import { useResizeObserver } from '@wordpress/compose';
 import { useMemo, useState, memo } from '@wordpress/element';
 import { ENTER, SPACE } from '@wordpress/keycodes';
-import { store as coreStore } from '@wordpress/core-data';
 
 /**
  * Internal dependencies
  */
 import { unlock } from '../../lock-unlock';
 import EditorCanvasContainer from '../editor-canvas-container';
-import { mergeBaseAndUserConfigs } from '../global-styles/global-styles-provider';
 
 const {
 	ExperimentalBlockEditorProvider,
 	useGlobalStyle,
-	useGlobalStylesOutputWithConfig,
+	useGlobalStylesOutputWithCustomConfig,
 } = unlock( blockEditorPrivateApis );
 
 const {
@@ -122,10 +120,6 @@ const STYLE_BOOK_IFRAME_STYLES = `
 	}
 `;
 
-function isObjectEmpty( object ) {
-	return ! object || Object.keys( object ).length === 0;
-}
-
 function getExamples() {
 	// Use our own example for the Heading block so that we can show multiple
 	// heading levels.
@@ -206,25 +200,6 @@ function StyleBook( {
 		[ examples ]
 	);
 
-	const { baseConfig } = useSelect(
-		( select ) => ( {
-			baseConfig:
-				select(
-					coreStore
-				).__experimentalGetCurrentThemeBaseGlobalStyles(),
-		} ),
-		[]
-	);
-
-	const mergedConfig = useMemo( () => {
-		if ( ! isObjectEmpty( userConfig ) && ! isObjectEmpty( baseConfig ) ) {
-			return mergeBaseAndUserConfigs( baseConfig, userConfig );
-		}
-		return {};
-	}, [ baseConfig, userConfig ] );
-
-	// Copied from packages/edit-site/src/components/revisions/index.js
-	// could we create a shared hook?
 	const originalSettings = useSelect(
 		( select ) => select( blockEditorStore ).getSettings(),
 		[]
@@ -235,12 +210,8 @@ function StyleBook( {
 		[ originalSettings ]
 	);
 
-	const [ globalStyles ] = useGlobalStylesOutputWithConfig( mergedConfig );
-
 	settings.styles =
-		! isObjectEmpty( globalStyles ) && ! isObjectEmpty( userConfig )
-			? globalStyles
-			: settings.styles;
+		useGlobalStylesOutputWithCustomConfig( userConfig ) || settings.styles;
 
 	return (
 		<EditorCanvasContainer

@ramonjd ramonjd marked this pull request as ready for review December 13, 2023 07:50
@ramonjd ramonjd changed the title [WIP] Global styles revisions: integrate style book Global styles revisions: integrate style book Dec 13, 2023
@ramonjd ramonjd force-pushed the try/global-styles-revisions-show-style-book branch from 7a63789 to 24e494a Compare December 13, 2023 23:24
Copy link
Contributor

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, cool idea! I like how the additional style book button moves the toggling to the preview area, so that the buttons at the top right of the UI still switch between the overall area (and prevents folks from getting stuck). It means that it feels more like you're still "within" the global styles revisions while looking around 👍

One tiny UX thing I noticed: when you open the Revisions panel, focus is moved to the eye icon. Should it still be going to the close button?

2023-12-14.12.12.09.mp4

Would it be worth pinging some designers for feedback at this stage? I quite like the buttons here, but I wasn't sure if they might need a container or background to group them together, as they stand out a bit with darker site background colours. I.e. should it feel more like a toolbar, or are standalone buttons okay, UI-wise?

image

Other than that, it's all testing nicely for me so far! Toggling on and off Style Book and Revisions screens appears to be behaving as on trunk as far as I can tell 👍

@ramonjd ramonjd added Needs Design Needs design efforts. Needs Design Feedback Needs general design feedback. and removed Needs Design Needs design efforts. labels Dec 14, 2023
@ramonjd
Copy link
Member Author

ramonjd commented Dec 14, 2023

Thank you for testing @andrewserong !

One tiny UX thing I noticed: when you open the Revisions panel, focus is moved to the eye icon. Should it still be going to the close button?

I had prepared an answer for this 😄

By virtue of useFocusOnMount( 'firstElement' ) the canvas will focus on the first tabbable element.

I wasn't sure whether we should focus on the close button always, even if there are other "actions".

Asking myself "why", I'm not convinced there is a good reason to do so.

Is there a reason to skip the first tabbable element and land on a specific one?

For reference here's the PR that introduced useFocusOnMount: #42187

If we land on the close button, the user will have to back tab to find out about preceding actions. Is being able to close with a focussed button, on top of the esc button, more important or accessible? cc @tellthemachines for opinions.

I'm open for any approach, but it'd be good to articulate why.

Let's say we wanted that behaviour.

useFocusOnMount is a bit fiddly - I tried to pass it ref.current but it will use the first value it receives, so by the time ref.current exists useFocusOnMount has already fired off using null. It probably needs to be incorporated into an external hook, or we could just use useEffect and focus on the ref internally.

Or, and I tried this, we use flex-direction so that the close button is the first element but in the UI, it's the last element. Then we'd have to fudge the tab order, which gets messy.

Would it be worth pinging some designers for feedback at this stage? I quite like the buttons here, but I wasn't sure if they might need a container or background to group them together, as they stand out a bit with darker site background colours. I.e. should it feel more like a toolbar, or are standalone buttons okay, UI-wise?

Yes! Now that I have something half working, it'd be good to get some input. @jameskoster is my go-to for revisions 😄

@andrewserong
Copy link
Contributor

Is there a reason to skip the first tabbable element and land on a specific one?

I can't remember where the discussion last was, but from memory one of the arguments I've heard before is that if focus goes to a close button, then hitting enter to toggle something open means you can hit enter again to toggle it closed. If focus goes to another action, it's (potentially) harder for someone to go back. That's mitigated in this scenario by being able to press Escape to close the modal. But @jeryj might be another good person to ping for the desired behaviour of which button to focus first, I don't have a strong opinion either way 🙂

@ramonjd
Copy link
Member Author

ramonjd commented Dec 14, 2023

If focus goes to another action, it's (potentially) harder for someone to go back

Yeah that sounds fair enough, thanks for raising that.

Maybe, if we do focus on close, then we could enclose in a ButtonGroup with some labels/description

Actually, maybe a ButtonGroup would be good any way 👍🏻 Let's see what folks say. Also happy to slide in either direction.

@jameskoster
Copy link
Contributor

Thanks for the PR, this seems like a reasonable feature to add. If a style revision includes only changes to an obscure block it should be easy enough to find a visual preview of that block.

That said I don't love the design, but I also don't have any great alternative solutions because the long-term vision for the Styles panel still isn't 100% clear.

One potential idea to try would be to make the style book more integrated in the revisions preview. IE instead of a (duplicate) eye icon, maybe display the tab bar permanently, with an additional (default) "Site" tab which displays the site:

Screenshot 2023-12-14 at 10 12 40

It would be good to get @SaxonF's thoughts on this as he's thought a lot more about the Styles panel than I have recently.

@ramonjd
Copy link
Member Author

ramonjd commented Dec 14, 2023

One potential idea to try would be to make the style book more integrated in the revisions preview.

That's so crazy, it just might work!! 😆 I like it. Thanks for the feedback!

@SaxonF
Copy link
Contributor

SaxonF commented Dec 15, 2023

Another alternative until we figure out the styles panel. Make it so the style book can be toggled on/off in combination with revisions. ie both can be enabled.
image

@ramonjd
Copy link
Member Author

ramonjd commented Dec 15, 2023

Another alternative until we figure out the styles panel. Make it so the style book can be toggled on/off in combination with revisions. ie both can be enabled.

That was going to be my first take on it (See #55577 (comment) - about half way down the comment) - I shied away for fear of introducing too much complexity, but if the styles panel is fair game, I'll take a crack at it as well 😄 Might just work.

Edit: here's what it looks like. I've pushed this commit in 9b7b858 so there's a record of it.

2023-12-15.15.58.42.mp4

One potential idea to try would be to make the style book more integrated in the revisions preview. IE instead of a (duplicate) eye icon, maybe display the tab bar permanently, with an additional (default) "Site" tab which displays the site

The above alt-button state is a bit fiddly in term of UX so I'd like to try this idea too for comparison.

@ramonjd ramonjd force-pushed the try/global-styles-revisions-show-style-book branch from 2bbe8a0 to 9b7b858 Compare December 15, 2023 05:00
@jameskoster
Copy link
Contributor

Make it so the style book can be toggled on/off in combination with revisions. ie both can be enabled.

Oh yeah, that makes much more sense. We'd just need to work out a couple of flow issues:

  • If you open revisions then style book, the close button (in the canvas area) should exit style book, but the revisions panel should probably remain open.
  • If you open style book then open revisions, style book should remain toggled on.

Plus that active button state you mentioned @ramonjd, but hopefully that's easy to fix.

Copy link
Contributor

@apeatling apeatling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the selected state should both be dark here, not the alternative selected state that exists for the style book right now:

Screenshot 2023-12-18 at 9 04 05 AM

@ramonjd
Copy link
Member Author

ramonjd commented Dec 18, 2023

I think the selected state should both be dark here, not the alternative selected state that exists for the style book right now:

Thanks for testing!

So, the default white on black? Easy done. I'll just remove the custom styles and it should work out of the box.

@ramonjd ramonjd force-pushed the try/global-styles-revisions-show-style-book branch from d1307e6 to 39656cc Compare December 19, 2023 04:57
@ramonjd
Copy link
Member Author

ramonjd commented Dec 19, 2023

So, the default white on black? Easy done. I'll just remove the custom styles and it should work out of the box.

Done, and updated description with new screencast.

Agree - looks much more consistent.

🍺

@jameskoster
Copy link
Contributor

Thanks for all the work on this so far, it feels very close. The only tiny nitpick I have is: If you open both Style Book and Revisions, then close Revisions, the Style Book should remain open. What do you think?

@ramonjd
Copy link
Member Author

ramonjd commented Dec 19, 2023

Thanks for all the work on this so far, it feels very close. The only tiny nitpick I have is: If you open both Style Book and Revisions, then close Revisions, the Style Book should remain open. What do you think?

That sounds logical to me. I'll take a shot at it today. Thanks for the feedback!

…s area) will exit style book, but the revisions panel remains open.

If you open style book then open revisions, style book will remain toggled on.

Render the style book window immediately to avoid a flash of the underlying editor
…Style Book remains open

Added e2e tests to reflect this
@ramonjd ramonjd force-pushed the try/global-styles-revisions-show-style-book branch from 39656cc to 84f05b2 Compare December 20, 2023 01:44
Copy link
Contributor

@jameskoster jameskoster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this is working well. Happy to approve for design 🚀

Copy link
Contributor

@apeatling apeatling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good with that followup. LGTM!

@ramonjd
Copy link
Member Author

ramonjd commented Dec 20, 2023

Thanks for hanging in there with me on this one, folks!

@ramonjd ramonjd merged commit 588fc12 into trunk Dec 20, 2023
52 checks passed
@ramonjd ramonjd deleted the try/global-styles-revisions-show-style-book branch December 20, 2023 20:26
@github-actions github-actions bot added this to the Gutenberg 17.4 milestone Dec 20, 2023
@andrewserong
Copy link
Contributor

Nice work! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json Needs Design Feedback Needs general design feedback. [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Styles: when viewing revisions, allow for the option to view with Style Book
5 participants