@wordpress/edit-site 4.16.0 → 4.17.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/block-editor/block-inspector-button.js +1 -1
- package/build/components/block-editor/block-inspector-button.js.map +1 -1
- package/build/components/block-editor/index.js +17 -11
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/editor/index.js +5 -7
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/preview.js +84 -49
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +35 -4
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +15 -2
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +39 -176
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +27 -9
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/{header → header-edit-mode}/document-actions/index.js +58 -24
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -0
- package/build/components/{header → header-edit-mode}/index.js +13 -49
- package/build/components/header-edit-mode/index.js.map +1 -0
- package/build/components/{header → header-edit-mode}/mode-switcher/index.js +0 -0
- package/build/components/header-edit-mode/mode-switcher/index.js.map +1 -0
- package/build/components/{header → header-edit-mode}/more-menu/copy-content-menu-item.js +0 -0
- package/build/components/header-edit-mode/more-menu/copy-content-menu-item.js.map +1 -0
- package/build/components/{header → header-edit-mode}/more-menu/index.js +0 -0
- package/build/components/header-edit-mode/more-menu/index.js.map +1 -0
- package/build/components/{header → header-edit-mode}/more-menu/site-export.js +0 -0
- package/build/components/header-edit-mode/more-menu/site-export.js.map +1 -0
- package/build/components/{header → header-edit-mode}/more-menu/welcome-guide-menu-item.js +0 -0
- package/build/components/header-edit-mode/more-menu/welcome-guide-menu-item.js.map +1 -0
- package/build/components/{header → header-edit-mode}/plugin-more-menu-item/index.js +0 -0
- package/build/components/header-edit-mode/plugin-more-menu-item/index.js.map +1 -0
- package/build/components/{header → header-edit-mode}/plugin-sidebar-more-menu-item/index.js +0 -0
- package/build/components/header-edit-mode/plugin-sidebar-more-menu-item/index.js.map +1 -0
- package/build/components/{header → header-edit-mode}/tools-more-menu-group/index.js +0 -0
- package/build/components/header-edit-mode/tools-more-menu-group/index.js.map +1 -0
- package/build/components/{header → header-edit-mode}/undo-redo/redo.js +0 -0
- package/build/components/header-edit-mode/undo-redo/redo.js.map +1 -0
- package/build/components/{header → header-edit-mode}/undo-redo/undo.js +0 -0
- package/build/components/header-edit-mode/undo-redo/undo.js.map +1 -0
- package/build/components/keyboard-shortcuts/index.js +1 -1
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/{sidebar → sidebar-edit-mode}/constants.js +0 -0
- package/build/components/sidebar-edit-mode/constants.js.map +1 -0
- package/build/components/{sidebar → sidebar-edit-mode}/default-sidebar.js +0 -0
- package/build/components/sidebar-edit-mode/default-sidebar.js.map +1 -0
- package/build/components/{sidebar → sidebar-edit-mode}/global-styles-sidebar.js +0 -0
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -0
- package/build/components/{sidebar → sidebar-edit-mode}/index.js +1 -1
- package/build/components/sidebar-edit-mode/index.js.map +1 -0
- package/build/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/index.js +0 -0
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/index.js.map +1 -0
- package/build/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/navigation-inspector.js +0 -0
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +1 -0
- package/build/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/navigation-menu.js +0 -0
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +1 -0
- package/build/components/{sidebar → sidebar-edit-mode}/plugin-sidebar/index.js +1 -1
- package/build/components/sidebar-edit-mode/plugin-sidebar/index.js.map +1 -0
- package/build/components/{sidebar → sidebar-edit-mode}/settings-header/index.js +2 -2
- package/build/components/sidebar-edit-mode/settings-header/index.js.map +1 -0
- package/build/components/{sidebar → sidebar-edit-mode}/template-card/index.js +0 -0
- package/build/components/sidebar-edit-mode/template-card/index.js.map +1 -0
- package/build/components/{sidebar → sidebar-edit-mode}/template-card/template-actions.js +0 -0
- package/build/components/sidebar-edit-mode/template-card/template-actions.js.map +1 -0
- package/build/components/{sidebar → sidebar-edit-mode}/template-card/template-areas.js +0 -0
- package/build/components/sidebar-edit-mode/template-card/template-areas.js.map +1 -0
- package/build/index.js +3 -3
- package/build/index.js.map +1 -1
- package/build-module/components/block-editor/block-inspector-button.js +1 -1
- package/build-module/components/block-editor/block-inspector-button.js.map +1 -1
- package/build-module/components/block-editor/index.js +16 -10
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/editor/index.js +4 -6
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/preview.js +84 -49
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +36 -6
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +14 -2
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +37 -169
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +26 -9
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/{header → header-edit-mode}/document-actions/index.js +53 -24
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -0
- package/build-module/components/{header → header-edit-mode}/index.js +13 -46
- package/build-module/components/header-edit-mode/index.js.map +1 -0
- package/build-module/components/{header → header-edit-mode}/mode-switcher/index.js +0 -0
- package/build-module/components/header-edit-mode/mode-switcher/index.js.map +1 -0
- package/build-module/components/{header → header-edit-mode}/more-menu/copy-content-menu-item.js +0 -0
- package/build-module/components/header-edit-mode/more-menu/copy-content-menu-item.js.map +1 -0
- package/build-module/components/{header → header-edit-mode}/more-menu/index.js +0 -0
- package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -0
- package/build-module/components/{header → header-edit-mode}/more-menu/site-export.js +0 -0
- package/build-module/components/header-edit-mode/more-menu/site-export.js.map +1 -0
- package/build-module/components/{header → header-edit-mode}/more-menu/welcome-guide-menu-item.js +0 -0
- package/build-module/components/header-edit-mode/more-menu/welcome-guide-menu-item.js.map +1 -0
- package/build-module/components/{header → header-edit-mode}/plugin-more-menu-item/index.js +0 -0
- package/build-module/components/header-edit-mode/plugin-more-menu-item/index.js.map +1 -0
- package/build-module/components/{header → header-edit-mode}/plugin-sidebar-more-menu-item/index.js +0 -0
- package/build-module/components/header-edit-mode/plugin-sidebar-more-menu-item/index.js.map +1 -0
- package/build-module/components/{header → header-edit-mode}/tools-more-menu-group/index.js +0 -0
- package/build-module/components/header-edit-mode/tools-more-menu-group/index.js.map +1 -0
- package/build-module/components/{header → header-edit-mode}/undo-redo/redo.js +0 -0
- package/build-module/components/header-edit-mode/undo-redo/redo.js.map +1 -0
- package/build-module/components/{header → header-edit-mode}/undo-redo/undo.js +0 -0
- package/build-module/components/header-edit-mode/undo-redo/undo.js.map +1 -0
- package/build-module/components/keyboard-shortcuts/index.js +1 -1
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/{sidebar → sidebar-edit-mode}/constants.js +0 -0
- package/build-module/components/sidebar-edit-mode/constants.js.map +1 -0
- package/build-module/components/{sidebar → sidebar-edit-mode}/default-sidebar.js +0 -0
- package/build-module/components/sidebar-edit-mode/default-sidebar.js.map +1 -0
- package/build-module/components/{sidebar → sidebar-edit-mode}/global-styles-sidebar.js +0 -0
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -0
- package/build-module/components/{sidebar → sidebar-edit-mode}/index.js +1 -1
- package/build-module/components/sidebar-edit-mode/index.js.map +1 -0
- package/build-module/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/index.js +0 -0
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/index.js.map +1 -0
- package/build-module/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/navigation-inspector.js +0 -0
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +1 -0
- package/build-module/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/navigation-menu.js +0 -0
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +1 -0
- package/build-module/components/{sidebar → sidebar-edit-mode}/plugin-sidebar/index.js +1 -1
- package/build-module/components/sidebar-edit-mode/plugin-sidebar/index.js.map +1 -0
- package/build-module/components/{sidebar → sidebar-edit-mode}/settings-header/index.js +2 -2
- package/build-module/components/sidebar-edit-mode/settings-header/index.js.map +1 -0
- package/build-module/components/{sidebar → sidebar-edit-mode}/template-card/index.js +0 -0
- package/build-module/components/sidebar-edit-mode/template-card/index.js.map +1 -0
- package/build-module/components/{sidebar → sidebar-edit-mode}/template-card/template-actions.js +0 -0
- package/build-module/components/sidebar-edit-mode/template-card/template-actions.js.map +1 -0
- package/build-module/components/{sidebar → sidebar-edit-mode}/template-card/template-areas.js +0 -0
- package/build-module/components/sidebar-edit-mode/template-card/template-areas.js.map +1 -0
- package/build-module/index.js +3 -3
- package/build-module/index.js.map +1 -1
- package/build-style/style-rtl.css +61 -86
- package/build-style/style.css +61 -86
- package/package.json +29 -29
- package/src/components/block-editor/block-inspector-button.js +1 -1
- package/src/components/block-editor/index.js +29 -11
- package/src/components/editor/index.js +2 -4
- package/src/components/global-styles/preview.js +80 -59
- package/src/components/global-styles/screen-style-variations.js +39 -4
- package/src/components/global-styles/test/typography-utils.js +333 -103
- package/src/components/global-styles/test/use-global-styles-output.js +57 -3
- package/src/components/global-styles/typography-panel.js +14 -1
- package/src/components/global-styles/typography-utils.js +34 -195
- package/src/components/global-styles/use-global-styles-output.js +16 -0
- package/src/components/{header → header-edit-mode}/document-actions/index.js +67 -46
- package/src/components/{header → header-edit-mode}/document-actions/style.scss +0 -0
- package/src/components/{header → header-edit-mode}/index.js +12 -44
- package/src/components/{header → header-edit-mode}/mode-switcher/index.js +0 -0
- package/src/components/{header → header-edit-mode}/more-menu/copy-content-menu-item.js +0 -0
- package/src/components/{header → header-edit-mode}/more-menu/index.js +0 -0
- package/src/components/{header → header-edit-mode}/more-menu/site-export.js +0 -0
- package/src/components/{header → header-edit-mode}/more-menu/welcome-guide-menu-item.js +0 -0
- package/src/components/{header → header-edit-mode}/plugin-more-menu-item/index.js +0 -0
- package/src/components/{header → header-edit-mode}/plugin-sidebar-more-menu-item/index.js +0 -0
- package/src/components/{header → header-edit-mode}/style.scss +20 -50
- package/src/components/{header → header-edit-mode}/tools-more-menu-group/index.js +0 -0
- package/src/components/{header → header-edit-mode}/undo-redo/redo.js +0 -0
- package/src/components/{header → header-edit-mode}/undo-redo/undo.js +0 -0
- package/src/components/keyboard-shortcuts/index.js +1 -1
- package/src/components/{sidebar → sidebar-edit-mode}/constants.js +0 -0
- package/src/components/{sidebar → sidebar-edit-mode}/default-sidebar.js +0 -0
- package/src/components/{sidebar → sidebar-edit-mode}/global-styles-sidebar.js +0 -0
- package/src/components/{sidebar → sidebar-edit-mode}/index.js +1 -1
- package/src/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/index.js +0 -0
- package/src/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/navigation-inspector.js +0 -0
- package/src/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/navigation-menu.js +0 -0
- package/src/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/style.scss +0 -0
- package/src/components/{sidebar → sidebar-edit-mode}/plugin-sidebar/index.js +1 -1
- package/src/components/{sidebar → sidebar-edit-mode}/settings-header/index.js +2 -2
- package/src/components/{sidebar → sidebar-edit-mode}/settings-header/style.scss +2 -2
- package/src/components/{sidebar → sidebar-edit-mode}/style.scss +1 -1
- package/src/components/{sidebar → sidebar-edit-mode}/template-card/index.js +0 -0
- package/src/components/{sidebar → sidebar-edit-mode}/template-card/style.scss +0 -0
- package/src/components/{sidebar → sidebar-edit-mode}/template-card/template-actions.js +0 -0
- package/src/components/{sidebar → sidebar-edit-mode}/template-card/template-areas.js +0 -0
- package/src/index.js +3 -3
- package/src/style.scss +6 -6
- package/build/components/header/document-actions/index.js.map +0 -1
- package/build/components/header/index.js.map +0 -1
- package/build/components/header/mode-switcher/index.js.map +0 -1
- package/build/components/header/more-menu/copy-content-menu-item.js.map +0 -1
- package/build/components/header/more-menu/index.js.map +0 -1
- package/build/components/header/more-menu/site-export.js.map +0 -1
- package/build/components/header/more-menu/welcome-guide-menu-item.js.map +0 -1
- package/build/components/header/plugin-more-menu-item/index.js.map +0 -1
- package/build/components/header/plugin-sidebar-more-menu-item/index.js.map +0 -1
- package/build/components/header/tools-more-menu-group/index.js.map +0 -1
- package/build/components/header/undo-redo/redo.js.map +0 -1
- package/build/components/header/undo-redo/undo.js.map +0 -1
- package/build/components/sidebar/constants.js.map +0 -1
- package/build/components/sidebar/default-sidebar.js.map +0 -1
- package/build/components/sidebar/global-styles-sidebar.js.map +0 -1
- package/build/components/sidebar/index.js.map +0 -1
- package/build/components/sidebar/navigation-menu-sidebar/index.js.map +0 -1
- package/build/components/sidebar/navigation-menu-sidebar/navigation-inspector.js.map +0 -1
- package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +0 -1
- package/build/components/sidebar/plugin-sidebar/index.js.map +0 -1
- package/build/components/sidebar/settings-header/index.js.map +0 -1
- package/build/components/sidebar/template-card/index.js.map +0 -1
- package/build/components/sidebar/template-card/template-actions.js.map +0 -1
- package/build/components/sidebar/template-card/template-areas.js.map +0 -1
- package/build-module/components/header/document-actions/index.js.map +0 -1
- package/build-module/components/header/index.js.map +0 -1
- package/build-module/components/header/mode-switcher/index.js.map +0 -1
- package/build-module/components/header/more-menu/copy-content-menu-item.js.map +0 -1
- package/build-module/components/header/more-menu/index.js.map +0 -1
- package/build-module/components/header/more-menu/site-export.js.map +0 -1
- package/build-module/components/header/more-menu/welcome-guide-menu-item.js.map +0 -1
- package/build-module/components/header/plugin-more-menu-item/index.js.map +0 -1
- package/build-module/components/header/plugin-sidebar-more-menu-item/index.js.map +0 -1
- package/build-module/components/header/tools-more-menu-group/index.js.map +0 -1
- package/build-module/components/header/undo-redo/redo.js.map +0 -1
- package/build-module/components/header/undo-redo/undo.js.map +0 -1
- package/build-module/components/sidebar/constants.js.map +0 -1
- package/build-module/components/sidebar/default-sidebar.js.map +0 -1
- package/build-module/components/sidebar/global-styles-sidebar.js.map +0 -1
- package/build-module/components/sidebar/index.js.map +0 -1
- package/build-module/components/sidebar/navigation-menu-sidebar/index.js.map +0 -1
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-inspector.js.map +0 -1
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +0 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js.map +0 -1
- package/build-module/components/sidebar/settings-header/index.js.map +0 -1
- package/build-module/components/sidebar/template-card/index.js.map +0 -1
- package/build-module/components/sidebar/template-card/template-actions.js.map +0 -1
- package/build-module/components/sidebar/template-card/template-areas.js.map +0 -1
|
@@ -4,73 +4,59 @@
|
|
|
4
4
|
* ---------------------------------------------------------------
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { getComputedFluidTypographyValue } from '@wordpress/block-editor';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {Object} FluidPreset
|
|
14
|
+
* @property {string|undefined} max A maximum font size value.
|
|
15
|
+
* @property {?string|undefined} min A minimum font size value.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {Object} Preset
|
|
20
|
+
* @property {?string|?number} size A default font size.
|
|
21
|
+
* @property {string} name A font size name, displayed in the UI.
|
|
22
|
+
* @property {string} slug A font size slug
|
|
23
|
+
* @property {boolean|FluidPreset|undefined} fluid A font size slug
|
|
24
|
+
*/
|
|
25
|
+
|
|
7
26
|
/**
|
|
8
27
|
* Returns a font-size value based on a given font-size preset.
|
|
9
28
|
* Takes into account fluid typography parameters and attempts to return a css formula depending on available, valid values.
|
|
10
29
|
*
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {string} preset.slug A font size slug.
|
|
15
|
-
* @param {Object} preset.fluid
|
|
16
|
-
* @param {string|undefined} preset.fluid.max A maximum font size value.
|
|
17
|
-
* @param {string|undefined} preset.fluid.min A minimum font size value.
|
|
18
|
-
* @param {Object} typographySettings
|
|
19
|
-
* @param {boolean} typographySettings.fluid Whether fluid typography is enabled.
|
|
30
|
+
* @param {Preset} preset
|
|
31
|
+
* @param {Object} typographySettings
|
|
32
|
+
* @param {boolean} typographySettings.fluid Whether fluid typography is enabled.
|
|
20
33
|
*
|
|
21
|
-
* @return {string}
|
|
34
|
+
* @return {string|*} A font-size value or the value of preset.size.
|
|
22
35
|
*/
|
|
23
36
|
export function getTypographyFontSizeValue( preset, typographySettings ) {
|
|
24
37
|
const { size: defaultSize } = preset;
|
|
25
38
|
|
|
26
|
-
|
|
39
|
+
/*
|
|
40
|
+
* Catches falsy values and 0/'0'.
|
|
41
|
+
* Fluid calculations cannot be performed on 0.
|
|
42
|
+
*/
|
|
43
|
+
if ( ! defaultSize || '0' === defaultSize ) {
|
|
27
44
|
return defaultSize;
|
|
28
45
|
}
|
|
29
46
|
|
|
30
|
-
|
|
31
|
-
const DEFAULT_MAXIMUM_VIEWPORT_WIDTH = '1600px';
|
|
32
|
-
const DEFAULT_MINIMUM_VIEWPORT_WIDTH = '768px';
|
|
33
|
-
const DEFAULT_MINIMUM_FONT_SIZE_FACTOR = 0.75;
|
|
34
|
-
const DEFAULT_MAXIMUM_FONT_SIZE_FACTOR = 1.5;
|
|
35
|
-
const DEFAULT_SCALE_FACTOR = 1;
|
|
36
|
-
|
|
37
|
-
// Font sizes.
|
|
38
|
-
// A font size has explicitly bypassed fluid calculations.
|
|
39
|
-
if ( false === preset?.fluid ) {
|
|
47
|
+
if ( true !== typographySettings?.fluid ) {
|
|
40
48
|
return defaultSize;
|
|
41
49
|
}
|
|
42
50
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// Try to grab explicit min and max fluid font sizes.
|
|
46
|
-
let minimumFontSizeRaw = fluidFontSizeSettings?.min;
|
|
47
|
-
let maximumFontSizeRaw = fluidFontSizeSettings?.max;
|
|
48
|
-
const preferredSize = getTypographyValueAndUnit( defaultSize );
|
|
49
|
-
|
|
50
|
-
// Protect against unsupported units.
|
|
51
|
-
if ( ! preferredSize?.unit ) {
|
|
51
|
+
// A font size has explicitly bypassed fluid calculations.
|
|
52
|
+
if ( false === preset?.fluid ) {
|
|
52
53
|
return defaultSize;
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
// If no fluid min or max font sizes are available, create some using min/max font size factors.
|
|
56
|
-
if ( ! minimumFontSizeRaw ) {
|
|
57
|
-
minimumFontSizeRaw =
|
|
58
|
-
preferredSize.value * DEFAULT_MINIMUM_FONT_SIZE_FACTOR +
|
|
59
|
-
preferredSize.unit;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if ( ! maximumFontSizeRaw ) {
|
|
63
|
-
maximumFontSizeRaw =
|
|
64
|
-
preferredSize.value * DEFAULT_MAXIMUM_FONT_SIZE_FACTOR +
|
|
65
|
-
preferredSize.unit;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
56
|
const fluidFontSizeValue = getComputedFluidTypographyValue( {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
minimumFontSize: minimumFontSizeRaw,
|
|
73
|
-
scaleFactor: DEFAULT_SCALE_FACTOR,
|
|
57
|
+
minimumFontSize: preset?.fluid?.min,
|
|
58
|
+
maximumFontSize: preset?.fluid?.max,
|
|
59
|
+
fontSize: defaultSize,
|
|
74
60
|
} );
|
|
75
61
|
|
|
76
62
|
if ( !! fluidFontSizeValue ) {
|
|
@@ -79,150 +65,3 @@ export function getTypographyFontSizeValue( preset, typographySettings ) {
|
|
|
79
65
|
|
|
80
66
|
return defaultSize;
|
|
81
67
|
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Internal implementation of clamp() based on available min/max viewport width, and min/max font sizes.
|
|
85
|
-
*
|
|
86
|
-
* @param {Object} args
|
|
87
|
-
* @param {string} args.maximumViewPortWidth Maximum size up to which type will have fluidity.
|
|
88
|
-
* @param {string} args.minimumViewPortWidth Minimum viewport size from which type will have fluidity.
|
|
89
|
-
* @param {string} args.maximumFontSize Maximum font size for any clamp() calculation.
|
|
90
|
-
* @param {string} args.minimumFontSize Minimum font size for any clamp() calculation.
|
|
91
|
-
* @param {number} args.scaleFactor A scale factor to determine how fast a font scales within boundaries.
|
|
92
|
-
*
|
|
93
|
-
* @return {string|null} A font-size value using clamp().
|
|
94
|
-
*/
|
|
95
|
-
export function getComputedFluidTypographyValue( {
|
|
96
|
-
maximumViewPortWidth,
|
|
97
|
-
minimumViewPortWidth,
|
|
98
|
-
maximumFontSize,
|
|
99
|
-
minimumFontSize,
|
|
100
|
-
scaleFactor,
|
|
101
|
-
} ) {
|
|
102
|
-
// Grab the minimum font size and normalize it in order to use the value for calculations.
|
|
103
|
-
const minimumFontSizeParsed = getTypographyValueAndUnit( minimumFontSize );
|
|
104
|
-
|
|
105
|
-
// We get a 'preferred' unit to keep units consistent when calculating,
|
|
106
|
-
// otherwise the result will not be accurate.
|
|
107
|
-
const fontSizeUnit = minimumFontSizeParsed?.unit || 'rem';
|
|
108
|
-
|
|
109
|
-
// Grab the maximum font size and normalize it in order to use the value for calculations.
|
|
110
|
-
const maximumFontSizeParsed = getTypographyValueAndUnit( maximumFontSize, {
|
|
111
|
-
coerceTo: fontSizeUnit,
|
|
112
|
-
} );
|
|
113
|
-
|
|
114
|
-
// Protect against unsupported units.
|
|
115
|
-
if ( ! minimumFontSizeParsed || ! maximumFontSizeParsed ) {
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// Use rem for accessible fluid target font scaling.
|
|
120
|
-
const minimumFontSizeRem = getTypographyValueAndUnit( minimumFontSize, {
|
|
121
|
-
coerceTo: 'rem',
|
|
122
|
-
} );
|
|
123
|
-
|
|
124
|
-
// Viewport widths defined for fluid typography. Normalize units
|
|
125
|
-
const maximumViewPortWidthParsed = getTypographyValueAndUnit(
|
|
126
|
-
maximumViewPortWidth,
|
|
127
|
-
{ coerceTo: fontSizeUnit }
|
|
128
|
-
);
|
|
129
|
-
const minumumViewPortWidthParsed = getTypographyValueAndUnit(
|
|
130
|
-
minimumViewPortWidth,
|
|
131
|
-
{ coerceTo: fontSizeUnit }
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
// Protect against unsupported units.
|
|
135
|
-
if (
|
|
136
|
-
! maximumViewPortWidthParsed ||
|
|
137
|
-
! minumumViewPortWidthParsed ||
|
|
138
|
-
! minimumFontSizeRem
|
|
139
|
-
) {
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Build CSS rule.
|
|
144
|
-
// Borrowed from https://websemantics.uk/tools/responsive-font-calculator/.
|
|
145
|
-
const minViewPortWidthOffsetValue = roundToPrecision(
|
|
146
|
-
minumumViewPortWidthParsed.value / 100,
|
|
147
|
-
3
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
const viewPortWidthOffset = minViewPortWidthOffsetValue + fontSizeUnit;
|
|
151
|
-
let linearFactor =
|
|
152
|
-
100 *
|
|
153
|
-
( ( maximumFontSizeParsed.value - minimumFontSizeParsed.value ) /
|
|
154
|
-
( maximumViewPortWidthParsed.value -
|
|
155
|
-
minumumViewPortWidthParsed.value ) );
|
|
156
|
-
linearFactor = roundToPrecision( linearFactor, 3 ) || 1;
|
|
157
|
-
const linearFactorScaled = linearFactor * scaleFactor;
|
|
158
|
-
const fluidTargetFontSize = `${ minimumFontSizeRem.value }${ minimumFontSizeRem.unit } + ((1vw - ${ viewPortWidthOffset }) * ${ linearFactorScaled })`;
|
|
159
|
-
|
|
160
|
-
return `clamp(${ minimumFontSize }, ${ fluidTargetFontSize }, ${ maximumFontSize })`;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
*
|
|
165
|
-
* @param {string} rawValue Raw size value from theme.json.
|
|
166
|
-
* @param {Object|undefined} options Calculation options.
|
|
167
|
-
*
|
|
168
|
-
* @return {{ unit: string, value: number }|null} An object consisting of `'value'` and `'unit'` properties.
|
|
169
|
-
*/
|
|
170
|
-
export function getTypographyValueAndUnit( rawValue, options = {} ) {
|
|
171
|
-
if ( ! rawValue ) {
|
|
172
|
-
return null;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const { coerceTo, rootSizeValue, acceptableUnits } = {
|
|
176
|
-
coerceTo: '',
|
|
177
|
-
// Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( "html" ) ).fontSize`.
|
|
178
|
-
rootSizeValue: 16,
|
|
179
|
-
acceptableUnits: [ 'rem', 'px', 'em' ],
|
|
180
|
-
...options,
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
const acceptableUnitsGroup = acceptableUnits?.join( '|' );
|
|
184
|
-
const regexUnits = new RegExp(
|
|
185
|
-
`^(\\d*\\.?\\d+)(${ acceptableUnitsGroup }){1,1}$`
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
const matches = rawValue.match( regexUnits );
|
|
189
|
-
|
|
190
|
-
// We need a number value and a unit.
|
|
191
|
-
if ( ! matches || matches.length < 3 ) {
|
|
192
|
-
return null;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
let [ , value, unit ] = matches;
|
|
196
|
-
|
|
197
|
-
let returnValue = parseFloat( value );
|
|
198
|
-
|
|
199
|
-
if ( 'px' === coerceTo && ( 'em' === unit || 'rem' === unit ) ) {
|
|
200
|
-
returnValue = returnValue * rootSizeValue;
|
|
201
|
-
unit = coerceTo;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if ( 'px' === unit && ( 'em' === coerceTo || 'rem' === coerceTo ) ) {
|
|
205
|
-
returnValue = returnValue / rootSizeValue;
|
|
206
|
-
unit = coerceTo;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return {
|
|
210
|
-
value: returnValue,
|
|
211
|
-
unit,
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Returns a value rounded to defined precision.
|
|
217
|
-
* Returns `undefined` if the value is not a valid finite number.
|
|
218
|
-
*
|
|
219
|
-
* @param {number} value Raw value.
|
|
220
|
-
* @param {number} digits The number of digits to appear after the decimal point
|
|
221
|
-
*
|
|
222
|
-
* @return {number|undefined} Value rounded to standard precision.
|
|
223
|
-
*/
|
|
224
|
-
export function roundToPrecision( value, digits = 3 ) {
|
|
225
|
-
return Number.isFinite( value )
|
|
226
|
-
? parseFloat( value.toFixed( digits ) )
|
|
227
|
-
: undefined;
|
|
228
|
-
}
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
* Internal dependencies
|
|
25
25
|
*/
|
|
26
26
|
import { PRESET_METADATA, ROOT_BLOCK_SELECTOR, scopeSelector } from './utils';
|
|
27
|
+
import { getTypographyFontSizeValue } from './typography-utils';
|
|
27
28
|
import { GlobalStylesContext } from './context';
|
|
28
29
|
import { useSetting } from './hooks';
|
|
29
30
|
|
|
@@ -276,6 +277,21 @@ export function getStylesDeclarations(
|
|
|
276
277
|
}
|
|
277
278
|
}
|
|
278
279
|
|
|
280
|
+
// Calculate fluid typography rules where available.
|
|
281
|
+
if ( cssProperty === 'font-size' ) {
|
|
282
|
+
/*
|
|
283
|
+
* getTypographyFontSizeValue() will check
|
|
284
|
+
* if fluid typography has been activated and also
|
|
285
|
+
* whether the incoming value can be converted to a fluid value.
|
|
286
|
+
* Values that already have a "clamp()" function will not pass the test,
|
|
287
|
+
* and therefore the original $value will be returned.
|
|
288
|
+
*/
|
|
289
|
+
ruleValue = getTypographyFontSizeValue(
|
|
290
|
+
{ size: ruleValue },
|
|
291
|
+
tree?.settings?.typography
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
|
|
279
295
|
output.push( `${ cssProperty }: ${ ruleValue }` );
|
|
280
296
|
} );
|
|
281
297
|
|
|
@@ -21,6 +21,15 @@ import {
|
|
|
21
21
|
import { chevronDown } from '@wordpress/icons';
|
|
22
22
|
import { useState, useMemo } from '@wordpress/element';
|
|
23
23
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
24
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
25
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
26
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Internal dependencies
|
|
30
|
+
*/
|
|
31
|
+
import TemplateDetails from '../../template-details';
|
|
32
|
+
import { store as editSiteStore } from '../../../store';
|
|
24
33
|
|
|
25
34
|
function getBlockDisplayText( block ) {
|
|
26
35
|
if ( block ) {
|
|
@@ -52,25 +61,36 @@ function useSecondaryText() {
|
|
|
52
61
|
return {};
|
|
53
62
|
}
|
|
54
63
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
export default function DocumentActions() {
|
|
65
|
+
const { showIconLabels, entityTitle, template, templateType, isLoaded } =
|
|
66
|
+
useSelect( ( select ) => {
|
|
67
|
+
const { getEditedPostType, getEditedPostId } =
|
|
68
|
+
select( editSiteStore );
|
|
69
|
+
const { getEditedEntityRecord } = select( coreStore );
|
|
70
|
+
const { __experimentalGetTemplateInfo: getTemplateInfo } =
|
|
71
|
+
select( editorStore );
|
|
72
|
+
const postType = getEditedPostType();
|
|
73
|
+
const postId = getEditedPostId();
|
|
74
|
+
const record = getEditedEntityRecord(
|
|
75
|
+
'postType',
|
|
76
|
+
postType,
|
|
77
|
+
postId
|
|
78
|
+
);
|
|
79
|
+
const _isLoaded = !! postId;
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
showIconLabels: select( preferencesStore ).get(
|
|
83
|
+
'core/edit-site',
|
|
84
|
+
'showIconLabels'
|
|
85
|
+
),
|
|
86
|
+
entityTitle: getTemplateInfo( record ).title,
|
|
87
|
+
isLoaded: _isLoaded,
|
|
88
|
+
template: record,
|
|
89
|
+
templateType: postType,
|
|
90
|
+
};
|
|
91
|
+
}, [] );
|
|
92
|
+
const entityLabel =
|
|
93
|
+
templateType === 'wp_template_part' ? 'template part' : 'template';
|
|
74
94
|
const { label } = useSecondaryText();
|
|
75
95
|
|
|
76
96
|
// Use internal state instead of a ref to make sure that the component
|
|
@@ -137,33 +157,34 @@ export default function DocumentActions( {
|
|
|
137
157
|
{ label ?? '' }
|
|
138
158
|
</Text>
|
|
139
159
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
160
|
+
<Dropdown
|
|
161
|
+
popoverProps={ popoverProps }
|
|
162
|
+
position="bottom center"
|
|
163
|
+
renderToggle={ ( { isOpen, onToggle } ) => (
|
|
164
|
+
<Button
|
|
165
|
+
className="edit-site-document-actions__get-info"
|
|
166
|
+
icon={ chevronDown }
|
|
167
|
+
aria-expanded={ isOpen }
|
|
168
|
+
aria-haspopup="true"
|
|
169
|
+
onClick={ onToggle }
|
|
170
|
+
variant={ showIconLabels ? 'tertiary' : undefined }
|
|
171
|
+
label={ sprintf(
|
|
172
|
+
/* translators: %s: the entity to see details about, like "template"*/
|
|
173
|
+
__( 'Show %s details' ),
|
|
174
|
+
entityLabel
|
|
175
|
+
) }
|
|
176
|
+
>
|
|
177
|
+
{ showIconLabels && __( 'Details' ) }
|
|
178
|
+
</Button>
|
|
179
|
+
) }
|
|
180
|
+
contentClassName="edit-site-document-actions__info-dropdown"
|
|
181
|
+
renderContent={ ( { onClose } ) => (
|
|
182
|
+
<TemplateDetails
|
|
183
|
+
template={ template }
|
|
184
|
+
onClose={ onClose }
|
|
185
|
+
/>
|
|
186
|
+
) }
|
|
187
|
+
/>
|
|
167
188
|
</div>
|
|
168
189
|
</div>
|
|
169
190
|
);
|
|
File without changes
|
|
@@ -26,8 +26,6 @@ import {
|
|
|
26
26
|
VisuallyHidden,
|
|
27
27
|
} from '@wordpress/components';
|
|
28
28
|
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
29
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
30
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
31
29
|
|
|
32
30
|
/**
|
|
33
31
|
* Internal dependencies
|
|
@@ -37,7 +35,6 @@ import SaveButton from '../save-button';
|
|
|
37
35
|
import UndoButton from './undo-redo/undo';
|
|
38
36
|
import RedoButton from './undo-redo/redo';
|
|
39
37
|
import DocumentActions from './document-actions';
|
|
40
|
-
import TemplateDetails from '../template-details';
|
|
41
38
|
import { store as editSiteStore } from '../../store';
|
|
42
39
|
|
|
43
40
|
const preventDefault = ( event ) => {
|
|
@@ -52,13 +49,10 @@ export default function Header( {
|
|
|
52
49
|
const inserterButton = useRef();
|
|
53
50
|
const {
|
|
54
51
|
deviceType,
|
|
55
|
-
entityTitle,
|
|
56
|
-
template,
|
|
57
52
|
templateType,
|
|
58
53
|
isInserterOpen,
|
|
59
54
|
isListViewOpen,
|
|
60
55
|
listViewShortcut,
|
|
61
|
-
isLoaded,
|
|
62
56
|
isVisualMode,
|
|
63
57
|
settings,
|
|
64
58
|
blockEditorMode,
|
|
@@ -66,28 +60,18 @@ export default function Header( {
|
|
|
66
60
|
const {
|
|
67
61
|
__experimentalGetPreviewDeviceType,
|
|
68
62
|
getEditedPostType,
|
|
69
|
-
getEditedPostId,
|
|
70
63
|
isInserterOpened,
|
|
71
64
|
isListViewOpened,
|
|
72
65
|
getEditorMode,
|
|
73
66
|
getSettings,
|
|
74
67
|
} = select( editSiteStore );
|
|
75
|
-
const { getEditedEntityRecord } = select( coreStore );
|
|
76
|
-
const { __experimentalGetTemplateInfo: getTemplateInfo } =
|
|
77
|
-
select( editorStore );
|
|
78
68
|
const { getShortcutRepresentation } = select( keyboardShortcutsStore );
|
|
79
69
|
const { __unstableGetEditorMode } = select( blockEditorStore );
|
|
80
70
|
|
|
81
71
|
const postType = getEditedPostType();
|
|
82
|
-
const postId = getEditedPostId();
|
|
83
|
-
const record = getEditedEntityRecord( 'postType', postType, postId );
|
|
84
|
-
const _isLoaded = !! postId;
|
|
85
72
|
|
|
86
73
|
return {
|
|
87
74
|
deviceType: __experimentalGetPreviewDeviceType(),
|
|
88
|
-
entityTitle: getTemplateInfo( record ).title,
|
|
89
|
-
isLoaded: _isLoaded,
|
|
90
|
-
template: record,
|
|
91
75
|
templateType: postType,
|
|
92
76
|
isInserterOpen: isInserterOpened(),
|
|
93
77
|
isListViewOpen: isListViewOpened(),
|
|
@@ -137,16 +121,16 @@ export default function Header( {
|
|
|
137
121
|
const isZoomedOutView = blockEditorMode === 'zoom-out';
|
|
138
122
|
|
|
139
123
|
return (
|
|
140
|
-
<div className="edit-site-header">
|
|
124
|
+
<div className="edit-site-header-edit-mode">
|
|
141
125
|
<NavigableToolbar
|
|
142
|
-
className="edit-site-
|
|
126
|
+
className="edit-site-header-edit-mode__start"
|
|
143
127
|
aria-label={ __( 'Document tools' ) }
|
|
144
128
|
>
|
|
145
|
-
<div className="edit-site-
|
|
129
|
+
<div className="edit-site-header-edit-mode__toolbar">
|
|
146
130
|
<ToolbarItem
|
|
147
131
|
ref={ inserterButton }
|
|
148
132
|
as={ Button }
|
|
149
|
-
className="edit-site-header-
|
|
133
|
+
className="edit-site-header-edit-mode__inserter-toggle"
|
|
150
134
|
variant="primary"
|
|
151
135
|
isPressed={ isInserterOpen }
|
|
152
136
|
onMouseDown={ preventDefault }
|
|
@@ -182,7 +166,7 @@ export default function Header( {
|
|
|
182
166
|
/>
|
|
183
167
|
<ToolbarItem
|
|
184
168
|
as={ Button }
|
|
185
|
-
className="edit-site-header-
|
|
169
|
+
className="edit-site-header-edit-mode__list-view-toggle"
|
|
186
170
|
disabled={ ! isVisualMode && isZoomedOutView }
|
|
187
171
|
icon={ listView }
|
|
188
172
|
isPressed={ isListViewOpen }
|
|
@@ -198,14 +182,12 @@ export default function Header( {
|
|
|
198
182
|
{ isZoomedOutViewExperimentEnabled && (
|
|
199
183
|
<ToolbarItem
|
|
200
184
|
as={ Button }
|
|
201
|
-
className="edit-site-header-toolbar__zoom-out-view-toggle"
|
|
202
185
|
icon={ chevronUpDown }
|
|
203
186
|
isPressed={ isZoomedOutView }
|
|
204
187
|
/* translators: button label text should, if possible, be under 16 characters. */
|
|
205
188
|
label={ __( 'Zoom-out View' ) }
|
|
206
189
|
onClick={ () => {
|
|
207
190
|
setPreviewDeviceType( 'desktop' );
|
|
208
|
-
setIsListViewOpened( false );
|
|
209
191
|
__unstableSetEditorMode(
|
|
210
192
|
isZoomedOutView
|
|
211
193
|
? 'edit'
|
|
@@ -219,38 +201,24 @@ export default function Header( {
|
|
|
219
201
|
</div>
|
|
220
202
|
</NavigableToolbar>
|
|
221
203
|
|
|
222
|
-
<div className="edit-site-
|
|
223
|
-
<DocumentActions
|
|
224
|
-
entityTitle={ entityTitle }
|
|
225
|
-
entityLabel={
|
|
226
|
-
templateType === 'wp_template_part'
|
|
227
|
-
? 'template part'
|
|
228
|
-
: 'template'
|
|
229
|
-
}
|
|
230
|
-
isLoaded={ isLoaded }
|
|
231
|
-
showIconLabels={ showIconLabels }
|
|
232
|
-
>
|
|
233
|
-
{ ( { onClose } ) => (
|
|
234
|
-
<TemplateDetails
|
|
235
|
-
template={ template }
|
|
236
|
-
onClose={ onClose }
|
|
237
|
-
/>
|
|
238
|
-
) }
|
|
239
|
-
</DocumentActions>
|
|
204
|
+
<div className="edit-site-header-edit-mode__center">
|
|
205
|
+
<DocumentActions />
|
|
240
206
|
</div>
|
|
241
207
|
|
|
242
|
-
<div className="edit-site-
|
|
243
|
-
<div className="edit-site-
|
|
208
|
+
<div className="edit-site-header-edit-mode__end">
|
|
209
|
+
<div className="edit-site-header-edit-mode__actions">
|
|
244
210
|
{ ! isFocusMode && (
|
|
245
211
|
<div
|
|
246
212
|
className={ classnames(
|
|
247
|
-
'edit-site-
|
|
213
|
+
'edit-site-header-edit-mode__preview-options',
|
|
248
214
|
{ 'is-zoomed-out': isZoomedOutView }
|
|
249
215
|
) }
|
|
250
216
|
>
|
|
251
217
|
<PreviewOptions
|
|
252
218
|
deviceType={ deviceType }
|
|
253
219
|
setDeviceType={ setPreviewDeviceType }
|
|
220
|
+
/* translators: button label text should, if possible, be under 16 characters. */
|
|
221
|
+
viewLabel={ __( 'View' ) }
|
|
254
222
|
>
|
|
255
223
|
<MenuGroup>
|
|
256
224
|
<MenuItem
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|