@wordpress/edit-site 6.8.6 → 6.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/editor-canvas-container/index.js +1 -1
- package/build/components/editor-canvas-container/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-card.js +1 -1
- package/build/components/global-styles/font-library-modal/font-card.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-collection.js +4 -4
- package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build/components/global-styles/font-library-modal/index.js +1 -1
- package/build/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/installed-fonts.js +5 -5
- package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build/components/global-styles/font-sizes/font-size.js +15 -6
- package/build/components/global-styles/font-sizes/font-size.js.map +1 -1
- package/build/components/global-styles/header.js +1 -1
- package/build/components/global-styles/header.js.map +1 -1
- package/build/components/global-styles/navigation-button.js +2 -2
- package/build/components/global-styles/navigation-button.js.map +1 -1
- package/build/components/global-styles/screen-revisions/index.js +1 -2
- package/build/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build/components/global-styles/shadows-edit-panel.js +4 -1
- package/build/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build/components/global-styles/ui.js +6 -19
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles-sidebar/index.js +1 -1
- package/build/components/global-styles-sidebar/index.js.map +1 -1
- package/build/components/page-patterns/fields.js +2 -4
- package/build/components/page-patterns/fields.js.map +1 -1
- package/build/components/resizable-frame/index.js +25 -7
- package/build/components/resizable-frame/index.js.map +1 -1
- package/build/components/routes/link.js +6 -3
- package/build/components/routes/link.js.map +1 -1
- package/build/components/save-panel/index.js +2 -4
- package/build/components/save-panel/index.js.map +1 -1
- package/build/components/sidebar-button/index.js +2 -4
- package/build/components/sidebar-button/index.js.map +1 -1
- package/build/components/sidebar-dataviews/add-new-view.js +4 -8
- package/build/components/sidebar-dataviews/add-new-view.js.map +1 -1
- package/build/components/site-hub/index.js +12 -24
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/style-book/categories.js +70 -0
- package/build/components/style-book/categories.js.map +1 -0
- package/build/components/style-book/constants.js +151 -0
- package/build/components/style-book/constants.js.map +1 -0
- package/build/components/style-book/examples.js +58 -0
- package/build/components/style-book/examples.js.map +1 -0
- package/build/components/style-book/index.js +52 -133
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/style-book/types.js +6 -0
- package/build/components/style-book/types.js.map +1 -0
- package/build/store/selectors.js +1 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/editor-canvas-container/index.js +1 -1
- package/build-module/components/editor-canvas-container/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/font-card.js +1 -1
- package/build-module/components/global-styles/font-library-modal/font-card.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/font-collection.js +5 -5
- package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/index.js +1 -1
- package/build-module/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js +5 -5
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-sizes/font-size.js +16 -7
- package/build-module/components/global-styles/font-sizes/font-size.js.map +1 -1
- package/build-module/components/global-styles/header.js +2 -2
- package/build-module/components/global-styles/header.js.map +1 -1
- package/build-module/components/global-styles/navigation-button.js +3 -3
- package/build-module/components/global-styles/navigation-button.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/index.js +1 -2
- package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build-module/components/global-styles/shadows-edit-panel.js +4 -1
- package/build-module/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build-module/components/global-styles/ui.js +3 -16
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles-sidebar/index.js +1 -1
- package/build-module/components/global-styles-sidebar/index.js.map +1 -1
- package/build-module/components/page-patterns/fields.js +2 -4
- package/build-module/components/page-patterns/fields.js.map +1 -1
- package/build-module/components/resizable-frame/index.js +26 -8
- package/build-module/components/resizable-frame/index.js.map +1 -1
- package/build-module/components/routes/link.js +6 -3
- package/build-module/components/routes/link.js.map +1 -1
- package/build-module/components/save-panel/index.js +2 -4
- package/build-module/components/save-panel/index.js.map +1 -1
- package/build-module/components/sidebar-button/index.js +2 -4
- package/build-module/components/sidebar-button/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/add-new-view.js +4 -8
- package/build-module/components/sidebar-dataviews/add-new-view.js.map +1 -1
- package/build-module/components/site-hub/index.js +12 -24
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/style-book/categories.js +64 -0
- package/build-module/components/style-book/categories.js.map +1 -0
- package/build-module/components/style-book/constants.js +145 -0
- package/build-module/components/style-book/constants.js.map +1 -0
- package/build-module/components/style-book/examples.js +52 -0
- package/build-module/components/style-book/examples.js.map +1 -0
- package/build-module/components/style-book/index.js +51 -132
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/style-book/types.js +2 -0
- package/build-module/components/style-book/types.js.map +1 -0
- package/build-module/store/selectors.js +1 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/posts-rtl.css +32 -12
- package/build-style/posts.css +32 -12
- package/build-style/style-rtl.css +44 -21
- package/build-style/style.css +44 -21
- package/package.json +41 -41
- package/src/components/editor-canvas-container/index.js +1 -1
- package/src/components/editor-canvas-container/style.scss +2 -2
- package/src/components/global-styles/font-library-modal/font-card.js +1 -1
- package/src/components/global-styles/font-library-modal/font-collection.js +8 -10
- package/src/components/global-styles/font-library-modal/index.js +1 -1
- package/src/components/global-styles/font-library-modal/installed-fonts.js +9 -11
- package/src/components/global-styles/font-library-modal/style.scss +5 -1
- package/src/components/global-styles/font-sizes/font-size.js +15 -8
- package/src/components/global-styles/header.js +2 -2
- package/src/components/global-styles/navigation-button.js +3 -4
- package/src/components/global-styles/screen-revisions/index.js +1 -2
- package/src/components/global-styles/shadows-edit-panel.js +5 -1
- package/src/components/global-styles/ui.js +5 -19
- package/src/components/global-styles-sidebar/index.js +1 -1
- package/src/components/global-styles-sidebar/style.scss +1 -8
- package/src/components/layout/style.scss +7 -2
- package/src/components/page-patterns/fields.js +1 -2
- package/src/components/resizable-frame/index.js +14 -8
- package/src/components/routes/link.js +6 -3
- package/src/components/save-panel/index.js +1 -2
- package/src/components/sidebar-button/index.js +1 -2
- package/src/components/sidebar-dataviews/add-new-view.js +2 -4
- package/src/components/site-hub/index.js +6 -12
- package/src/components/style-book/categories.ts +91 -0
- package/src/components/style-book/constants.ts +191 -0
- package/src/components/style-book/examples.ts +63 -0
- package/src/components/style-book/index.js +76 -163
- package/src/components/style-book/style.scss +9 -5
- package/src/components/style-book/test/categories.js +171 -0
- package/src/components/style-book/types.ts +27 -0
- package/src/store/selectors.js +1 -1
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import type { StyleBookCategory } from './types';
|
|
10
|
+
|
|
11
|
+
export const STYLE_BOOK_THEME_SUBCATEGORIES: Omit<
|
|
12
|
+
StyleBookCategory,
|
|
13
|
+
'subcategories'
|
|
14
|
+
>[] = [
|
|
15
|
+
{
|
|
16
|
+
slug: 'site-identity',
|
|
17
|
+
title: __( 'Site Identity' ),
|
|
18
|
+
blocks: [ 'core/site-logo', 'core/site-title', 'core/site-tagline' ],
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
slug: 'design',
|
|
22
|
+
title: __( 'Design' ),
|
|
23
|
+
blocks: [ 'core/navigation', 'core/avatar', 'core/post-time-to-read' ],
|
|
24
|
+
exclude: [ 'core/home-link', 'core/navigation-link' ],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
slug: 'posts',
|
|
28
|
+
title: __( 'Posts' ),
|
|
29
|
+
blocks: [
|
|
30
|
+
'core/post-title',
|
|
31
|
+
'core/post-excerpt',
|
|
32
|
+
'core/post-author',
|
|
33
|
+
'core/post-author-name',
|
|
34
|
+
'core/post-author-biography',
|
|
35
|
+
'core/post-date',
|
|
36
|
+
'core/post-terms',
|
|
37
|
+
'core/term-description',
|
|
38
|
+
'core/query-title',
|
|
39
|
+
'core/query-no-results',
|
|
40
|
+
'core/query-pagination',
|
|
41
|
+
'core/query-numbers',
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
slug: 'comments',
|
|
46
|
+
title: __( 'Comments' ),
|
|
47
|
+
blocks: [
|
|
48
|
+
'core/comments-title',
|
|
49
|
+
'core/comments-pagination',
|
|
50
|
+
'core/comments-pagination-numbers',
|
|
51
|
+
'core/comments',
|
|
52
|
+
'core/comments-author-name',
|
|
53
|
+
'core/comment-content',
|
|
54
|
+
'core/comment-date',
|
|
55
|
+
'core/comment-edit-link',
|
|
56
|
+
'core/comment-reply-link',
|
|
57
|
+
'core/comment-template',
|
|
58
|
+
'core/post-comments-count',
|
|
59
|
+
'core/post-comments-link',
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
export const STYLE_BOOK_CATEGORIES: StyleBookCategory[] = [
|
|
65
|
+
{
|
|
66
|
+
slug: 'text',
|
|
67
|
+
title: __( 'Text' ),
|
|
68
|
+
blocks: [
|
|
69
|
+
'core/post-content',
|
|
70
|
+
'core/home-link',
|
|
71
|
+
'core/navigation-link',
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
slug: 'colors',
|
|
76
|
+
title: __( 'Colors' ),
|
|
77
|
+
blocks: [ 'custom/colors' ],
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
slug: 'theme',
|
|
81
|
+
title: __( 'Theme' ),
|
|
82
|
+
subcategories: STYLE_BOOK_THEME_SUBCATEGORIES,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
slug: 'media',
|
|
86
|
+
title: __( 'Media' ),
|
|
87
|
+
blocks: [ 'core/post-featured-image' ],
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
slug: 'widgets',
|
|
91
|
+
title: __( 'Widgets' ),
|
|
92
|
+
blocks: [],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
slug: 'embed',
|
|
96
|
+
title: __( 'Embeds' ),
|
|
97
|
+
include: [],
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
// The content area of the Style Book is rendered within an iframe so that global styles
|
|
102
|
+
// are applied to elements within the entire content area. To support elements that are
|
|
103
|
+
// not part of the block previews, such as headings and layout for the block previews,
|
|
104
|
+
// additional CSS rules need to be passed into the iframe. These are hard-coded below.
|
|
105
|
+
// Note that button styles are unset, and then focus rules from the `Button` component are
|
|
106
|
+
// applied to the `button` element, targeted via `.edit-site-style-book__example`.
|
|
107
|
+
// This is to ensure that browser default styles for buttons are not applied to the previews.
|
|
108
|
+
export const STYLE_BOOK_IFRAME_STYLES = `
|
|
109
|
+
// Forming a "block formatting context" to prevent margin collapsing.
|
|
110
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
|
|
111
|
+
.is-root-container {
|
|
112
|
+
display: flow-root;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
body {
|
|
116
|
+
position: relative;
|
|
117
|
+
padding: 32px !important;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.edit-site-style-book__examples {
|
|
121
|
+
max-width: 1200px;
|
|
122
|
+
margin: 0 auto;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.edit-site-style-book__example {
|
|
126
|
+
max-width: 900px;
|
|
127
|
+
border-radius: 2px;
|
|
128
|
+
cursor: pointer;
|
|
129
|
+
display: flex;
|
|
130
|
+
flex-direction: column;
|
|
131
|
+
gap: 40px;
|
|
132
|
+
padding: 16px;
|
|
133
|
+
width: 100%;
|
|
134
|
+
box-sizing: border-box;
|
|
135
|
+
scroll-margin-top: 32px;
|
|
136
|
+
scroll-margin-bottom: 32px;
|
|
137
|
+
margin: 0 auto 40px auto;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.edit-site-style-book__example.is-selected {
|
|
141
|
+
box-shadow: 0 0 0 1px var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.edit-site-style-book__example:focus:not(:disabled) {
|
|
145
|
+
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
|
|
146
|
+
outline: 3px solid transparent;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.edit-site-style-book__examples.is-wide .edit-site-style-book__example {
|
|
150
|
+
flex-direction: row;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.edit-site-style-book__subcategory-title,
|
|
154
|
+
.edit-site-style-book__example-title {
|
|
155
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
|
156
|
+
font-size: 11px;
|
|
157
|
+
font-weight: 500;
|
|
158
|
+
line-height: normal;
|
|
159
|
+
margin: 0;
|
|
160
|
+
text-align: left;
|
|
161
|
+
text-transform: uppercase;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.edit-site-style-book__subcategory-title {
|
|
165
|
+
font-size: 16px;
|
|
166
|
+
margin-bottom: 40px;
|
|
167
|
+
border-bottom: 1px solid #ddd;
|
|
168
|
+
padding-bottom: 8px;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.edit-site-style-book__examples.is-wide .edit-site-style-book__example-title {
|
|
172
|
+
text-align: right;
|
|
173
|
+
width: 120px;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.edit-site-style-book__example-preview {
|
|
177
|
+
width: 100%;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.edit-site-style-book__example-preview .block-editor-block-list__insertion-point,
|
|
181
|
+
.edit-site-style-book__example-preview .block-list-appender {
|
|
182
|
+
display: none;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.edit-site-style-book__example-preview .is-root-container > .wp-block:first-child {
|
|
186
|
+
margin-top: 0;
|
|
187
|
+
}
|
|
188
|
+
.edit-site-style-book__example-preview .is-root-container > .wp-block:last-child {
|
|
189
|
+
margin-bottom: 0;
|
|
190
|
+
}
|
|
191
|
+
`;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
5
|
+
import {
|
|
6
|
+
getBlockType,
|
|
7
|
+
getBlockTypes,
|
|
8
|
+
getBlockFromExample,
|
|
9
|
+
createBlock,
|
|
10
|
+
} from '@wordpress/blocks';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import type { BlockExample } from './types';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Returns a list of examples for registered block types.
|
|
19
|
+
*
|
|
20
|
+
* @return {BlockExample[]} An array of block examples.
|
|
21
|
+
*/
|
|
22
|
+
export function getExamples(): BlockExample[] {
|
|
23
|
+
const nonHeadingBlockExamples = getBlockTypes()
|
|
24
|
+
.filter( ( blockType ) => {
|
|
25
|
+
const { name, example, supports } = blockType;
|
|
26
|
+
return (
|
|
27
|
+
name !== 'core/heading' &&
|
|
28
|
+
!! example &&
|
|
29
|
+
supports.inserter !== false
|
|
30
|
+
);
|
|
31
|
+
} )
|
|
32
|
+
.map( ( blockType ) => ( {
|
|
33
|
+
name: blockType.name,
|
|
34
|
+
title: blockType.title,
|
|
35
|
+
category: blockType.category,
|
|
36
|
+
blocks: getBlockFromExample( blockType.name, blockType.example ),
|
|
37
|
+
} ) );
|
|
38
|
+
const isHeadingBlockRegistered = !! getBlockType( 'core/heading' );
|
|
39
|
+
|
|
40
|
+
if ( ! isHeadingBlockRegistered ) {
|
|
41
|
+
return nonHeadingBlockExamples;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Use our own example for the Heading block so that we can show multiple
|
|
45
|
+
// heading levels.
|
|
46
|
+
const headingsExample = {
|
|
47
|
+
name: 'core/heading',
|
|
48
|
+
title: __( 'Headings' ),
|
|
49
|
+
category: 'text',
|
|
50
|
+
blocks: [ 1, 2, 3, 4, 5, 6 ].map( ( level ) => {
|
|
51
|
+
return createBlock( 'core/heading', {
|
|
52
|
+
content: sprintf(
|
|
53
|
+
// translators: %d: heading level e.g: "1", "2", "3"
|
|
54
|
+
__( 'Heading %d' ),
|
|
55
|
+
level
|
|
56
|
+
),
|
|
57
|
+
level,
|
|
58
|
+
} );
|
|
59
|
+
} ),
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return [ headingsExample, ...nonHeadingBlockExamples ];
|
|
63
|
+
}
|
|
@@ -12,13 +12,6 @@ import {
|
|
|
12
12
|
privateApis as componentsPrivateApis,
|
|
13
13
|
} from '@wordpress/components';
|
|
14
14
|
import { __, sprintf } from '@wordpress/i18n';
|
|
15
|
-
import {
|
|
16
|
-
getCategories,
|
|
17
|
-
getBlockType,
|
|
18
|
-
getBlockTypes,
|
|
19
|
-
getBlockFromExample,
|
|
20
|
-
createBlock,
|
|
21
|
-
} from '@wordpress/blocks';
|
|
22
15
|
import {
|
|
23
16
|
BlockList,
|
|
24
17
|
privateApis as blockEditorPrivateApis,
|
|
@@ -37,6 +30,12 @@ import { ENTER, SPACE } from '@wordpress/keycodes';
|
|
|
37
30
|
*/
|
|
38
31
|
import { unlock } from '../../lock-unlock';
|
|
39
32
|
import EditorCanvasContainer from '../editor-canvas-container';
|
|
33
|
+
import { STYLE_BOOK_IFRAME_STYLES } from './constants';
|
|
34
|
+
import {
|
|
35
|
+
getExamplesByCategory,
|
|
36
|
+
getTopLevelStyleBookCategories,
|
|
37
|
+
} from './categories';
|
|
38
|
+
import { getExamples } from './examples';
|
|
40
39
|
|
|
41
40
|
const {
|
|
42
41
|
ExperimentalBlockEditorProvider,
|
|
@@ -48,126 +47,10 @@ const { mergeBaseAndUserConfigs } = unlock( editorPrivateApis );
|
|
|
48
47
|
|
|
49
48
|
const { Tabs } = unlock( componentsPrivateApis );
|
|
50
49
|
|
|
51
|
-
// The content area of the Style Book is rendered within an iframe so that global styles
|
|
52
|
-
// are applied to elements within the entire content area. To support elements that are
|
|
53
|
-
// not part of the block previews, such as headings and layout for the block previews,
|
|
54
|
-
// additional CSS rules need to be passed into the iframe. These are hard-coded below.
|
|
55
|
-
// Note that button styles are unset, and then focus rules from the `Button` component are
|
|
56
|
-
// applied to the `button` element, targeted via `.edit-site-style-book__example`.
|
|
57
|
-
// This is to ensure that browser default styles for buttons are not applied to the previews.
|
|
58
|
-
const STYLE_BOOK_IFRAME_STYLES = `
|
|
59
|
-
.edit-site-style-book__examples {
|
|
60
|
-
max-width: 900px;
|
|
61
|
-
margin: 0 auto;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.edit-site-style-book__example {
|
|
65
|
-
border-radius: 2px;
|
|
66
|
-
cursor: pointer;
|
|
67
|
-
display: flex;
|
|
68
|
-
flex-direction: column;
|
|
69
|
-
gap: 40px;
|
|
70
|
-
margin-bottom: 40px;
|
|
71
|
-
padding: 16px;
|
|
72
|
-
width: 100%;
|
|
73
|
-
box-sizing: border-box;
|
|
74
|
-
scroll-margin-top: 32px;
|
|
75
|
-
scroll-margin-bottom: 32px;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.edit-site-style-book__example.is-selected {
|
|
79
|
-
box-shadow: 0 0 0 1px var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.edit-site-style-book__example:focus:not(:disabled) {
|
|
83
|
-
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
|
|
84
|
-
outline: 3px solid transparent;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.edit-site-style-book__examples.is-wide .edit-site-style-book__example {
|
|
88
|
-
flex-direction: row;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.edit-site-style-book__example-title {
|
|
92
|
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
|
93
|
-
font-size: 11px;
|
|
94
|
-
font-weight: 500;
|
|
95
|
-
line-height: normal;
|
|
96
|
-
margin: 0;
|
|
97
|
-
text-align: left;
|
|
98
|
-
text-transform: uppercase;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.edit-site-style-book__examples.is-wide .edit-site-style-book__example-title {
|
|
102
|
-
text-align: right;
|
|
103
|
-
width: 120px;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.edit-site-style-book__example-preview {
|
|
107
|
-
width: 100%;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.edit-site-style-book__example-preview .block-editor-block-list__insertion-point,
|
|
111
|
-
.edit-site-style-book__example-preview .block-list-appender {
|
|
112
|
-
display: none;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
.edit-site-style-book__example-preview .is-root-container > .wp-block:first-child {
|
|
116
|
-
margin-top: 0;
|
|
117
|
-
}
|
|
118
|
-
.edit-site-style-book__example-preview .is-root-container > .wp-block:last-child {
|
|
119
|
-
margin-bottom: 0;
|
|
120
|
-
}
|
|
121
|
-
`;
|
|
122
|
-
|
|
123
50
|
function isObjectEmpty( object ) {
|
|
124
51
|
return ! object || Object.keys( object ).length === 0;
|
|
125
52
|
}
|
|
126
53
|
|
|
127
|
-
function getExamples() {
|
|
128
|
-
const nonHeadingBlockExamples = getBlockTypes()
|
|
129
|
-
.filter( ( blockType ) => {
|
|
130
|
-
const { name, example, supports } = blockType;
|
|
131
|
-
return (
|
|
132
|
-
name !== 'core/heading' &&
|
|
133
|
-
!! example &&
|
|
134
|
-
supports.inserter !== false
|
|
135
|
-
);
|
|
136
|
-
} )
|
|
137
|
-
.map( ( blockType ) => ( {
|
|
138
|
-
name: blockType.name,
|
|
139
|
-
title: blockType.title,
|
|
140
|
-
category: blockType.category,
|
|
141
|
-
blocks: getBlockFromExample( blockType.name, blockType.example ),
|
|
142
|
-
} ) );
|
|
143
|
-
|
|
144
|
-
const isHeadingBlockRegistered = !! getBlockType( 'core/heading' );
|
|
145
|
-
|
|
146
|
-
if ( ! isHeadingBlockRegistered ) {
|
|
147
|
-
return nonHeadingBlockExamples;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Use our own example for the Heading block so that we can show multiple
|
|
151
|
-
// heading levels.
|
|
152
|
-
const headingsExample = {
|
|
153
|
-
name: 'core/heading',
|
|
154
|
-
title: __( 'Headings' ),
|
|
155
|
-
category: 'text',
|
|
156
|
-
blocks: [ 1, 2, 3, 4, 5, 6 ].map( ( level ) => {
|
|
157
|
-
return createBlock( 'core/heading', {
|
|
158
|
-
content: sprintf(
|
|
159
|
-
// translators: %d: heading level e.g: "1", "2", "3"
|
|
160
|
-
__( 'Heading %d' ),
|
|
161
|
-
level
|
|
162
|
-
),
|
|
163
|
-
level,
|
|
164
|
-
} );
|
|
165
|
-
} ),
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
return [ headingsExample, ...nonHeadingBlockExamples ];
|
|
169
|
-
}
|
|
170
|
-
|
|
171
54
|
function StyleBook( {
|
|
172
55
|
enableResizing = true,
|
|
173
56
|
isSelected,
|
|
@@ -184,17 +67,11 @@ function StyleBook( {
|
|
|
184
67
|
const [ examples ] = useState( getExamples );
|
|
185
68
|
const tabs = useMemo(
|
|
186
69
|
() =>
|
|
187
|
-
|
|
188
|
-
.
|
|
189
|
-
|
|
190
|
-
( example ) => example.category === category.slug
|
|
191
|
-
)
|
|
70
|
+
getTopLevelStyleBookCategories().filter( ( category ) =>
|
|
71
|
+
examples.some(
|
|
72
|
+
( example ) => example.category === category.slug
|
|
192
73
|
)
|
|
193
|
-
|
|
194
|
-
name: category.slug,
|
|
195
|
-
title: category.title,
|
|
196
|
-
icon: category.icon,
|
|
197
|
-
} ) ),
|
|
74
|
+
),
|
|
198
75
|
[ examples ]
|
|
199
76
|
);
|
|
200
77
|
const { base: baseConfig } = useContext( GlobalStylesContext );
|
|
@@ -245,24 +122,26 @@ function StyleBook( {
|
|
|
245
122
|
{ showTabs ? (
|
|
246
123
|
<div className="edit-site-style-book__tabs">
|
|
247
124
|
<Tabs>
|
|
248
|
-
<
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
125
|
+
<div className="edit-site-style-book__tablist-container">
|
|
126
|
+
<Tabs.TabList>
|
|
127
|
+
{ tabs.map( ( tab ) => (
|
|
128
|
+
<Tabs.Tab
|
|
129
|
+
tabId={ tab.slug }
|
|
130
|
+
key={ tab.slug }
|
|
131
|
+
>
|
|
132
|
+
{ tab.title }
|
|
133
|
+
</Tabs.Tab>
|
|
134
|
+
) ) }
|
|
135
|
+
</Tabs.TabList>
|
|
136
|
+
</div>
|
|
258
137
|
{ tabs.map( ( tab ) => (
|
|
259
138
|
<Tabs.TabPanel
|
|
260
|
-
key={ tab.
|
|
261
|
-
tabId={ tab.
|
|
139
|
+
key={ tab.slug }
|
|
140
|
+
tabId={ tab.slug }
|
|
262
141
|
focusable={ false }
|
|
263
142
|
>
|
|
264
143
|
<StyleBookBody
|
|
265
|
-
category={ tab.
|
|
144
|
+
category={ tab.slug }
|
|
266
145
|
examples={ examples }
|
|
267
146
|
isSelected={ isSelected }
|
|
268
147
|
onSelect={ onSelect }
|
|
@@ -329,10 +208,6 @@ const StyleBookBody = ( {
|
|
|
329
208
|
readonly: true,
|
|
330
209
|
};
|
|
331
210
|
|
|
332
|
-
const buttonModeStyles = onClick
|
|
333
|
-
? 'body { cursor: pointer; } body * { pointer-events: none; }'
|
|
334
|
-
: '';
|
|
335
|
-
|
|
336
211
|
return (
|
|
337
212
|
<Iframe
|
|
338
213
|
className={ clsx( 'edit-site-style-book__iframe', {
|
|
@@ -345,14 +220,9 @@ const StyleBookBody = ( {
|
|
|
345
220
|
>
|
|
346
221
|
<EditorStyles styles={ settings.styles } />
|
|
347
222
|
<style>
|
|
348
|
-
{
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
`.is-root-container { display: flow-root; }
|
|
352
|
-
body { position: relative; padding: 32px !important; }` +
|
|
353
|
-
STYLE_BOOK_IFRAME_STYLES +
|
|
354
|
-
buttonModeStyles
|
|
355
|
-
}
|
|
223
|
+
{ STYLE_BOOK_IFRAME_STYLES }
|
|
224
|
+
{ !! onClick &&
|
|
225
|
+
'body { cursor: pointer; } body * { pointer-events: none; }' }
|
|
356
226
|
</style>
|
|
357
227
|
<Examples
|
|
358
228
|
className={ clsx( 'edit-site-style-book__examples', {
|
|
@@ -379,6 +249,16 @@ const StyleBookBody = ( {
|
|
|
379
249
|
|
|
380
250
|
const Examples = memo(
|
|
381
251
|
( { className, examples, category, label, isSelected, onSelect } ) => {
|
|
252
|
+
const categoryDefinition = category
|
|
253
|
+
? getTopLevelStyleBookCategories().find(
|
|
254
|
+
( _category ) => _category.slug === category
|
|
255
|
+
)
|
|
256
|
+
: null;
|
|
257
|
+
|
|
258
|
+
const filteredExamples = categoryDefinition
|
|
259
|
+
? getExamplesByCategory( categoryDefinition, examples )
|
|
260
|
+
: { examples };
|
|
261
|
+
|
|
382
262
|
return (
|
|
383
263
|
<Composite
|
|
384
264
|
orientation="vertical"
|
|
@@ -386,11 +266,8 @@ const Examples = memo(
|
|
|
386
266
|
aria-label={ label }
|
|
387
267
|
role="grid"
|
|
388
268
|
>
|
|
389
|
-
{ examples
|
|
390
|
-
.
|
|
391
|
-
category ? example.category === category : true
|
|
392
|
-
)
|
|
393
|
-
.map( ( example ) => (
|
|
269
|
+
{ !! filteredExamples?.examples?.length &&
|
|
270
|
+
filteredExamples.examples.map( ( example ) => (
|
|
394
271
|
<Example
|
|
395
272
|
key={ example.name }
|
|
396
273
|
id={ `example-${ example.name }` }
|
|
@@ -402,11 +279,47 @@ const Examples = memo(
|
|
|
402
279
|
} }
|
|
403
280
|
/>
|
|
404
281
|
) ) }
|
|
282
|
+
{ !! filteredExamples?.subcategories?.length &&
|
|
283
|
+
filteredExamples.subcategories.map( ( subcategory ) => (
|
|
284
|
+
<Composite.Group
|
|
285
|
+
className="edit-site-style-book__subcategory"
|
|
286
|
+
key={ `subcategory-${ subcategory.slug }` }
|
|
287
|
+
>
|
|
288
|
+
<Composite.GroupLabel>
|
|
289
|
+
<h2 className="edit-site-style-book__subcategory-title">
|
|
290
|
+
{ subcategory.title }
|
|
291
|
+
</h2>
|
|
292
|
+
</Composite.GroupLabel>
|
|
293
|
+
<Subcategory
|
|
294
|
+
examples={ subcategory.examples }
|
|
295
|
+
isSelected={ isSelected }
|
|
296
|
+
onSelect={ onSelect }
|
|
297
|
+
/>
|
|
298
|
+
</Composite.Group>
|
|
299
|
+
) ) }
|
|
405
300
|
</Composite>
|
|
406
301
|
);
|
|
407
302
|
}
|
|
408
303
|
);
|
|
409
304
|
|
|
305
|
+
const Subcategory = ( { examples, isSelected, onSelect } ) => {
|
|
306
|
+
return (
|
|
307
|
+
!! examples?.length &&
|
|
308
|
+
examples.map( ( example ) => (
|
|
309
|
+
<Example
|
|
310
|
+
key={ example.name }
|
|
311
|
+
id={ `example-${ example.name }` }
|
|
312
|
+
title={ example.title }
|
|
313
|
+
blocks={ example.blocks }
|
|
314
|
+
isSelected={ isSelected( example.name ) }
|
|
315
|
+
onClick={ () => {
|
|
316
|
+
onSelect?.( example.name );
|
|
317
|
+
} }
|
|
318
|
+
/>
|
|
319
|
+
) )
|
|
320
|
+
);
|
|
321
|
+
};
|
|
322
|
+
|
|
410
323
|
const Example = ( { id, title, blocks, isSelected, onClick } ) => {
|
|
411
324
|
const originalSettings = useSelect(
|
|
412
325
|
( select ) => select( blockEditorStore ).getSettings(),
|
|
@@ -17,12 +17,16 @@
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
.edit-site-style-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
.edit-site-style-book__tablist-container {
|
|
21
|
+
background: $white;
|
|
22
|
+
width: 100%;
|
|
23
|
+
padding-right: 56px;
|
|
24
|
+
display: flex;
|
|
25
|
+
position: absolute;
|
|
26
|
+
z-index: 1;
|
|
27
|
+
}
|
|
25
28
|
|
|
29
|
+
.edit-site-style-book__tabs {
|
|
26
30
|
[role="tabpanel"] {
|
|
27
31
|
bottom: 0;
|
|
28
32
|
left: 0;
|