@wordpress/edit-site 3.0.11 → 3.0.12

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.
Files changed (151) hide show
  1. package/build/components/add-new-template/new-template-part.js +34 -17
  2. package/build/components/add-new-template/new-template-part.js.map +1 -1
  3. package/build/components/add-new-template/new-template.js +41 -22
  4. package/build/components/add-new-template/new-template.js.map +1 -1
  5. package/build/components/block-editor/index.js +3 -1
  6. package/build/components/block-editor/index.js.map +1 -1
  7. package/build/components/global-styles/color-palette-panel.js +4 -4
  8. package/build/components/global-styles/color-palette-panel.js.map +1 -1
  9. package/build/components/global-styles/gradients-palette-panel.js +56 -0
  10. package/build/components/global-styles/gradients-palette-panel.js.map +1 -0
  11. package/build/components/global-styles/hooks.js +5 -5
  12. package/build/components/global-styles/hooks.js.map +1 -1
  13. package/build/components/global-styles/palette.js +11 -5
  14. package/build/components/global-styles/palette.js.map +1 -1
  15. package/build/components/global-styles/screen-background-color.js +2 -1
  16. package/build/components/global-styles/screen-background-color.js.map +1 -1
  17. package/build/components/global-styles/screen-color-palette.js +23 -3
  18. package/build/components/global-styles/screen-color-palette.js.map +1 -1
  19. package/build/components/global-styles/screen-link-color.js +2 -1
  20. package/build/components/global-styles/screen-link-color.js.map +1 -1
  21. package/build/components/global-styles/screen-text-color.js +2 -1
  22. package/build/components/global-styles/screen-text-color.js.map +1 -1
  23. package/build/components/global-styles/screen-typography-element.js +54 -0
  24. package/build/components/global-styles/screen-typography-element.js.map +1 -0
  25. package/build/components/global-styles/screen-typography.js +74 -6
  26. package/build/components/global-styles/screen-typography.js.map +1 -1
  27. package/build/components/global-styles/typography-panel.js +28 -8
  28. package/build/components/global-styles/typography-panel.js.map +1 -1
  29. package/build/components/global-styles/ui.js +12 -0
  30. package/build/components/global-styles/ui.js.map +1 -1
  31. package/build/components/global-styles/use-global-styles-output.js +2 -2
  32. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  33. package/build/components/global-styles/utils.js +1 -1
  34. package/build/components/global-styles/utils.js.map +1 -1
  35. package/build/components/list/actions/index.js +104 -0
  36. package/build/components/list/actions/index.js.map +1 -0
  37. package/build/components/list/actions/rename-menu-item.js +112 -0
  38. package/build/components/list/actions/rename-menu-item.js.map +1 -0
  39. package/build/components/list/added-by.js +180 -0
  40. package/build/components/list/added-by.js.map +1 -0
  41. package/build/components/list/index.js +18 -3
  42. package/build/components/list/index.js.map +1 -1
  43. package/build/components/list/table.js +54 -67
  44. package/build/components/list/table.js.map +1 -1
  45. package/build/components/navigation-sidebar/index.js +12 -11
  46. package/build/components/navigation-sidebar/index.js.map +1 -1
  47. package/build/components/navigation-sidebar/navigation-panel/index.js +28 -11
  48. package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
  49. package/build/components/navigation-sidebar/navigation-toggle/index.js +14 -5
  50. package/build/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
  51. package/build/index.js +8 -2
  52. package/build/index.js.map +1 -1
  53. package/build/store/actions.js +47 -18
  54. package/build/store/actions.js.map +1 -1
  55. package/build/store/selectors.js +25 -5
  56. package/build/store/selectors.js.map +1 -1
  57. package/build-module/components/add-new-template/new-template-part.js +30 -16
  58. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  59. package/build-module/components/add-new-template/new-template.js +40 -23
  60. package/build-module/components/add-new-template/new-template.js.map +1 -1
  61. package/build-module/components/block-editor/index.js +2 -1
  62. package/build-module/components/block-editor/index.js.map +1 -1
  63. package/build-module/components/global-styles/color-palette-panel.js +5 -5
  64. package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
  65. package/build-module/components/global-styles/gradients-palette-panel.js +46 -0
  66. package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -0
  67. package/build-module/components/global-styles/hooks.js +5 -5
  68. package/build-module/components/global-styles/hooks.js.map +1 -1
  69. package/build-module/components/global-styles/palette.js +12 -5
  70. package/build-module/components/global-styles/palette.js.map +1 -1
  71. package/build-module/components/global-styles/screen-background-color.js +2 -1
  72. package/build-module/components/global-styles/screen-background-color.js.map +1 -1
  73. package/build-module/components/global-styles/screen-color-palette.js +22 -3
  74. package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
  75. package/build-module/components/global-styles/screen-link-color.js +2 -1
  76. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  77. package/build-module/components/global-styles/screen-text-color.js +2 -1
  78. package/build-module/components/global-styles/screen-text-color.js.map +1 -1
  79. package/build-module/components/global-styles/screen-typography-element.js +41 -0
  80. package/build-module/components/global-styles/screen-typography-element.js.map +1 -0
  81. package/build-module/components/global-styles/screen-typography.js +70 -6
  82. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  83. package/build-module/components/global-styles/typography-panel.js +28 -8
  84. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  85. package/build-module/components/global-styles/ui.js +11 -0
  86. package/build-module/components/global-styles/ui.js.map +1 -1
  87. package/build-module/components/global-styles/use-global-styles-output.js +2 -2
  88. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  89. package/build-module/components/global-styles/utils.js +1 -1
  90. package/build-module/components/global-styles/utils.js.map +1 -1
  91. package/build-module/components/list/actions/index.js +85 -0
  92. package/build-module/components/list/actions/index.js.map +1 -0
  93. package/build-module/components/list/actions/rename-menu-item.js +101 -0
  94. package/build-module/components/list/actions/rename-menu-item.js.map +1 -0
  95. package/build-module/components/list/added-by.js +166 -0
  96. package/build-module/components/list/added-by.js.map +1 -0
  97. package/build-module/components/list/index.js +15 -3
  98. package/build-module/components/list/index.js.map +1 -1
  99. package/build-module/components/list/table.js +56 -69
  100. package/build-module/components/list/table.js.map +1 -1
  101. package/build-module/components/navigation-sidebar/index.js +11 -12
  102. package/build-module/components/navigation-sidebar/index.js.map +1 -1
  103. package/build-module/components/navigation-sidebar/navigation-panel/index.js +26 -12
  104. package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
  105. package/build-module/components/navigation-sidebar/navigation-toggle/index.js +14 -6
  106. package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
  107. package/build-module/index.js +8 -3
  108. package/build-module/index.js.map +1 -1
  109. package/build-module/store/actions.js +48 -19
  110. package/build-module/store/actions.js.map +1 -1
  111. package/build-module/store/selectors.js +21 -3
  112. package/build-module/store/selectors.js.map +1 -1
  113. package/build-style/style-rtl.css +136 -17
  114. package/build-style/style.css +136 -17
  115. package/package.json +10 -8
  116. package/src/components/add-new-template/new-template-part.js +32 -17
  117. package/src/components/add-new-template/new-template.js +39 -19
  118. package/src/components/block-editor/index.js +2 -0
  119. package/src/components/global-styles/color-palette-panel.js +5 -5
  120. package/src/components/global-styles/gradients-palette-panel.js +79 -0
  121. package/src/components/global-styles/hooks.js +4 -4
  122. package/src/components/global-styles/palette.js +30 -10
  123. package/src/components/global-styles/screen-background-color.js +1 -0
  124. package/src/components/global-styles/screen-color-palette.js +30 -3
  125. package/src/components/global-styles/screen-link-color.js +1 -0
  126. package/src/components/global-styles/screen-text-color.js +1 -0
  127. package/src/components/global-styles/screen-typography-element.js +39 -0
  128. package/src/components/global-styles/screen-typography.js +84 -3
  129. package/src/components/global-styles/style.scss +33 -0
  130. package/src/components/global-styles/test/use-global-styles-output.js +1 -1
  131. package/src/components/global-styles/test/utils.js +1 -1
  132. package/src/components/global-styles/typography-panel.js +37 -7
  133. package/src/components/global-styles/ui.js +9 -0
  134. package/src/components/global-styles/use-global-styles-output.js +2 -2
  135. package/src/components/global-styles/utils.js +1 -1
  136. package/src/components/list/actions/index.js +95 -0
  137. package/src/components/list/actions/rename-menu-item.js +134 -0
  138. package/src/components/list/added-by.js +179 -0
  139. package/src/components/list/index.js +27 -11
  140. package/src/components/list/style.scss +106 -11
  141. package/src/components/list/table.js +64 -75
  142. package/src/components/navigation-sidebar/index.js +9 -16
  143. package/src/components/navigation-sidebar/navigation-panel/index.js +25 -9
  144. package/src/components/navigation-sidebar/navigation-toggle/index.js +29 -17
  145. package/src/components/navigation-sidebar/navigation-toggle/test/index.js +2 -0
  146. package/src/components/sidebar/style.scss +2 -1
  147. package/src/index.js +10 -2
  148. package/src/store/actions.js +82 -34
  149. package/src/store/selectors.js +22 -4
  150. package/src/store/test/actions.js +0 -24
  151. package/src/store/test/selectors.js +24 -0
@@ -12,11 +12,13 @@ import {
12
12
  MenuItem,
13
13
  NavigableMenu,
14
14
  } from '@wordpress/components';
15
- import { useSelect } from '@wordpress/data';
15
+ import { useSelect, useDispatch } from '@wordpress/data';
16
16
  import { store as coreStore } from '@wordpress/core-data';
17
17
  import { store as editorStore } from '@wordpress/editor';
18
18
  import { addQueryArgs } from '@wordpress/url';
19
19
  import apiFetch from '@wordpress/api-fetch';
20
+ import { __ } from '@wordpress/i18n';
21
+ import { store as noticesStore } from '@wordpress/notices';
20
22
 
21
23
  const DEFAULT_TEMPLATE_SLUGS = [
22
24
  'front-page',
@@ -33,7 +35,8 @@ export default function NewTemplate( { postType } ) {
33
35
  ( select ) => ( {
34
36
  templates: select( coreStore ).getEntityRecords(
35
37
  'postType',
36
- 'wp_template'
38
+ 'wp_template',
39
+ { per_page: -1 }
37
40
  ),
38
41
  defaultTemplateTypes: select(
39
42
  editorStore
@@ -41,27 +44,44 @@ export default function NewTemplate( { postType } ) {
41
44
  } ),
42
45
  []
43
46
  );
47
+ const { createErrorNotice } = useDispatch( noticesStore );
44
48
 
45
49
  async function createTemplate( { slug } ) {
46
- const { title, description } = find( defaultTemplateTypes, { slug } );
50
+ try {
51
+ const { title, description } = find( defaultTemplateTypes, {
52
+ slug,
53
+ } );
47
54
 
48
- const template = await apiFetch( {
49
- path: '/wp/v2/templates',
50
- method: 'POST',
51
- data: {
52
- excerpt: description,
53
- // Slugs need to be strings, so this is for template `404`
54
- slug: slug.toString(),
55
- status: 'publish',
56
- title,
57
- },
58
- } );
55
+ const template = await apiFetch( {
56
+ path: '/wp/v2/templates',
57
+ method: 'POST',
58
+ data: {
59
+ excerpt: description,
60
+ // Slugs need to be strings, so this is for template `404`
61
+ slug: slug.toString(),
62
+ status: 'publish',
63
+ title,
64
+ },
65
+ } );
59
66
 
60
- // Navigate to the created template editor.
61
- window.location.href = addQueryArgs( window.location.href, {
62
- postId: template.id,
63
- postType: 'wp_template',
64
- } );
67
+ // Navigate to the created template editor.
68
+ window.location.href = addQueryArgs( window.location.href, {
69
+ postId: template.id,
70
+ postType: 'wp_template',
71
+ } );
72
+
73
+ // Wait for async navigation to happen before closing the modal.
74
+ await new Promise( () => {} );
75
+ } catch ( error ) {
76
+ const errorMessage =
77
+ error.message && error.code !== 'unknown_error'
78
+ ? error.message
79
+ : __( 'An error occurred while creating the template.' );
80
+
81
+ createErrorNotice( errorMessage, {
82
+ type: 'snackbar',
83
+ } );
84
+ }
65
85
  }
66
86
 
67
87
  const existingTemplateSlugs = map( templates, 'slug' );
@@ -20,6 +20,7 @@ import {
20
20
  store as blockEditorStore,
21
21
  } from '@wordpress/block-editor';
22
22
  import { useMergeRefs, useViewportMatch } from '@wordpress/compose';
23
+ import { ReusableBlocksMenuItems } from '@wordpress/reusable-blocks';
23
24
 
24
25
  /**
25
26
  * Internal dependencies
@@ -132,6 +133,7 @@ export default function BlockEditor( { setIsInserterOpen } ) {
132
133
  ) }
133
134
  </__unstableBlockSettingsMenuFirstItem>
134
135
  </BlockTools>
136
+ <ReusableBlocksMenuItems />
135
137
  </BlockEditorProvider>
136
138
  );
137
139
  }
@@ -2,7 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import {
5
- __experimentalColorEdit as ColorEdit,
5
+ __experimentalPaletteEdit as PaletteEdit,
6
6
  __experimentalVStack as VStack,
7
7
  } from '@wordpress/components';
8
8
  import { __ } from '@wordpress/i18n';
@@ -32,7 +32,7 @@ export default function ColorPalettePanel( { name } ) {
32
32
  'base'
33
33
  );
34
34
  const [ customColors, setCustomColors ] = useSetting(
35
- 'color.palette.user',
35
+ 'color.palette.custom',
36
36
  name
37
37
  );
38
38
 
@@ -46,7 +46,7 @@ export default function ColorPalettePanel( { name } ) {
46
46
  spacing={ 10 }
47
47
  >
48
48
  { !! themeColors && !! themeColors.length && (
49
- <ColorEdit
49
+ <PaletteEdit
50
50
  canReset={ themeColors !== baseThemeColors }
51
51
  canOnlyChangeValues
52
52
  colors={ themeColors }
@@ -57,7 +57,7 @@ export default function ColorPalettePanel( { name } ) {
57
57
  { !! defaultColors &&
58
58
  !! defaultColors.length &&
59
59
  !! defaultPaletteEnabled && (
60
- <ColorEdit
60
+ <PaletteEdit
61
61
  canReset={ defaultColors !== baseDefaultColors }
62
62
  canOnlyChangeValues
63
63
  colors={ defaultColors }
@@ -65,7 +65,7 @@ export default function ColorPalettePanel( { name } ) {
65
65
  paletteLabel={ __( 'Default' ) }
66
66
  />
67
67
  ) }
68
- <ColorEdit
68
+ <PaletteEdit
69
69
  colors={ customColors }
70
70
  onChange={ setCustomColors }
71
71
  paletteLabel={ __( 'Custom' ) }
@@ -0,0 +1,79 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ __experimentalVStack as VStack,
6
+ __experimentalPaletteEdit as PaletteEdit,
7
+ } from '@wordpress/components';
8
+ import { __ } from '@wordpress/i18n';
9
+
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+ import { useSetting } from './hooks';
14
+
15
+ export default function GradientPalettePanel( { name } ) {
16
+ const [ themeGradients, setThemeGradients ] = useSetting(
17
+ 'color.gradients.theme',
18
+ name
19
+ );
20
+ const [ baseThemeGradients ] = useSetting(
21
+ 'color.gradients.theme',
22
+ name,
23
+ 'base'
24
+ );
25
+ const [ defaultGradients, setDefaultGradients ] = useSetting(
26
+ 'color.gradients.default',
27
+ name
28
+ );
29
+ const [ baseDefaultGradients ] = useSetting(
30
+ 'color.gradients.default',
31
+ name,
32
+ 'base'
33
+ );
34
+ const [ customGradients, setCustomGradients ] = useSetting(
35
+ 'color.gradients.custom',
36
+ name
37
+ );
38
+
39
+ const [ defaultPaletteEnabled ] = useSetting(
40
+ 'color.defaultGradients',
41
+ name
42
+ );
43
+ return (
44
+ <VStack
45
+ className="edit-site-global-styles-gradient-palette-panel"
46
+ spacing={ 10 }
47
+ >
48
+ { !! themeGradients && !! themeGradients.length && (
49
+ <PaletteEdit
50
+ canReset={ themeGradients !== baseThemeGradients }
51
+ canOnlyChangeValues
52
+ gradients={ themeGradients }
53
+ onChange={ setThemeGradients }
54
+ paletteLabel={ __( 'Theme' ) }
55
+ />
56
+ ) }
57
+ { !! defaultGradients &&
58
+ !! defaultGradients.length &&
59
+ !! defaultPaletteEnabled && (
60
+ <PaletteEdit
61
+ canReset={ defaultGradients !== baseDefaultGradients }
62
+ canOnlyChangeValues
63
+ gradients={ defaultGradients }
64
+ onChange={ setDefaultGradients }
65
+ paletteLabel={ __( 'Default' ) }
66
+ />
67
+ ) }
68
+ <PaletteEdit
69
+ gradients={ customGradients }
70
+ onChange={ setCustomGradients }
71
+ paletteLabel={ __( 'Custom' ) }
72
+ emptyMessage={ __(
73
+ 'Custom gradients are empty! Add some gradients to create your own palette.'
74
+ ) }
75
+ slugPrefix="custom-"
76
+ />
77
+ </VStack>
78
+ );
79
+ }
@@ -49,7 +49,7 @@ export function useSetting( path, blockName, source = 'all' ) {
49
49
  setUserConfig( ( currentConfig ) => {
50
50
  const newUserConfig = cloneDeep( currentConfig );
51
51
  const pathToSet = PATHS_WITH_MERGE[ path ]
52
- ? fullPath + '.user'
52
+ ? fullPath + '.custom'
53
53
  : fullPath;
54
54
  set( newUserConfig, pathToSet, newValue );
55
55
 
@@ -65,7 +65,7 @@ export function useSetting( path, blockName, source = 'all' ) {
65
65
  const getSettingValue = ( configToUse ) => {
66
66
  const result = get( configToUse, currentPath );
67
67
  if ( PATHS_WITH_MERGE[ path ] ) {
68
- return result?.user ?? result?.theme ?? result?.default;
68
+ return result?.custom ?? result?.theme ?? result?.default;
69
69
  }
70
70
  return result;
71
71
  };
@@ -218,7 +218,7 @@ export function getSupportedGlobalStylesPanels( name ) {
218
218
  }
219
219
 
220
220
  export function useColorsPerOrigin( name ) {
221
- const [ customColors ] = useSetting( 'color.palette.user', name );
221
+ const [ customColors ] = useSetting( 'color.palette.custom', name );
222
222
  const [ themeColors ] = useSetting( 'color.palette.theme', name );
223
223
  const [ defaultColors ] = useSetting( 'color.palette.default', name );
224
224
  const [ shouldDisplayDefaultColors ] = useSetting( 'color.defaultPalette' );
@@ -261,7 +261,7 @@ export function useColorsPerOrigin( name ) {
261
261
  }
262
262
 
263
263
  export function useGradientsPerOrigin( name ) {
264
- const [ customGradients ] = useSetting( 'color.gradients.user', name );
264
+ const [ customGradients ] = useSetting( 'color.gradients.custom', name );
265
265
  const [ themeGradients ] = useSetting( 'color.gradients.theme', name );
266
266
  const [ defaultGradients ] = useSetting( 'color.gradients.default', name );
267
267
  const [ shouldDisplayDefaultGradients ] = useSetting(
@@ -11,6 +11,7 @@ import {
11
11
  ColorIndicator,
12
12
  } from '@wordpress/components';
13
13
  import { __, _n, sprintf } from '@wordpress/i18n';
14
+ import { useMemo } from '@wordpress/element';
14
15
 
15
16
  /**
16
17
  * Internal dependencies
@@ -22,18 +23,43 @@ import { useSetting } from './hooks';
22
23
  const EMPTY_COLORS = [];
23
24
 
24
25
  function Palette( { name } ) {
25
- const [ colorsSetting ] = useSetting( 'color.palette.user', name );
26
- const colors = colorsSetting || EMPTY_COLORS;
26
+ const [ customColors ] = useSetting( 'color.palette.custom' );
27
+ const [ themeColors ] = useSetting( 'color.palette.theme' );
28
+ const [ defaultColors ] = useSetting( 'color.palette.default' );
29
+
30
+ const [ defaultPaletteEnabled ] = useSetting(
31
+ 'color.defaultPalette',
32
+ name
33
+ );
34
+ const colors = useMemo(
35
+ () => [
36
+ ...( customColors || EMPTY_COLORS ),
37
+ ...( themeColors || EMPTY_COLORS ),
38
+ ...( defaultColors && defaultPaletteEnabled
39
+ ? defaultColors
40
+ : EMPTY_COLORS ),
41
+ ],
42
+ [ customColors, themeColors, defaultColors, defaultPaletteEnabled ]
43
+ );
44
+
27
45
  const screenPath = ! name
28
46
  ? '/colors/palette'
29
47
  : '/blocks/' + name + '/colors/palette';
48
+ const paletteButtonText =
49
+ colors.length > 0
50
+ ? sprintf(
51
+ // Translators: %d: Number of palette colors.
52
+ _n( '%d color', '%d colors', colors.length ),
53
+ colors.length
54
+ )
55
+ : __( 'Add custom colors' );
30
56
 
31
57
  return (
32
58
  <VStack spacing={ 3 }>
33
59
  <Subtitle>{ __( 'Palette' ) }</Subtitle>
34
60
  <ItemGroup isBordered isSeparated>
35
61
  <NavigationButton path={ screenPath }>
36
- <HStack>
62
+ <HStack isReversed={ colors.length === 0 }>
37
63
  <FlexBlock>
38
64
  <ZStack isLayered={ false } offset={ -8 }>
39
65
  { colors.slice( 0, 5 ).map( ( { color } ) => (
@@ -44,13 +70,7 @@ function Palette( { name } ) {
44
70
  ) ) }
45
71
  </ZStack>
46
72
  </FlexBlock>
47
- <FlexItem>
48
- { sprintf(
49
- // Translators: %d: Number of palette colors.
50
- _n( '%d color', '%d colors', colors.length ),
51
- colors.length
52
- ) }
53
- </FlexItem>
73
+ <FlexItem>{ paletteButtonText }</FlexItem>
54
74
  </HStack>
55
75
  </NavigationButton>
56
76
  </ItemGroup>
@@ -104,6 +104,7 @@ function ScreenBackgroundColor( { name } ) {
104
104
  disableCustomGradients={ ! areCustomGradientsEnabled }
105
105
  __experimentalHasMultipleOrigins
106
106
  showTitle={ false }
107
+ enableAlpha
107
108
  />
108
109
  </>
109
110
  );
@@ -2,26 +2,53 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
+ import {
6
+ __experimentalToggleGroupControl as ToggleGroupControl,
7
+ __experimentalToggleGroupControlOption as ToggleGroupControlOption,
8
+ } from '@wordpress/components';
9
+ import { useState } from '@wordpress/element';
5
10
 
6
11
  /**
7
12
  * Internal dependencies
8
13
  */
9
14
  import ColorPalettePanel from './color-palette-panel';
15
+ import GradientPalettePanel from './gradients-palette-panel';
10
16
  import ScreenHeader from './header';
11
17
 
12
18
  function ScreenColorPalette( { name } ) {
19
+ const [ currentTab, setCurrentTab ] = useState( 'solid' );
13
20
  const parentMenu = name === undefined ? '' : '/blocks/' + name;
14
21
 
15
22
  return (
16
23
  <>
17
24
  <ScreenHeader
18
25
  back={ parentMenu + '/colors' }
19
- title={ __( 'Color Palette' ) }
26
+ title={ __( 'Palette' ) }
20
27
  description={ __(
21
- 'Color palettes are used to provide default color options for blocks and various design tools. Here you can edit the colors with their labels.'
28
+ 'Palettes are used to provide default color options for blocks and various design tools. Here you can edit the colors with their labels.'
22
29
  ) }
23
30
  />
24
- <ColorPalettePanel name={ name } />
31
+ <ToggleGroupControl
32
+ className="edit-site-screen-color-palette-toggle"
33
+ value={ currentTab }
34
+ onChange={ setCurrentTab }
35
+ label={ __( 'Select palette type' ) }
36
+ hideLabelFromVision
37
+ isBlock
38
+ >
39
+ <ToggleGroupControlOption
40
+ value="solid"
41
+ label={ __( 'Solid' ) }
42
+ />
43
+ <ToggleGroupControlOption
44
+ value="gradient"
45
+ label={ __( 'Gradient' ) }
46
+ />
47
+ </ToggleGroupControl>
48
+ { currentTab === 'solid' && <ColorPalettePanel name={ name } /> }
49
+ { currentTab === 'gradient' && (
50
+ <GradientPalettePanel name={ name } />
51
+ ) }
25
52
  </>
26
53
  );
27
54
  }
@@ -70,6 +70,7 @@ function ScreenLinkColor( { name } ) {
70
70
  disableCustomColors={ ! areCustomSolidsEnabled }
71
71
  __experimentalHasMultipleOrigins
72
72
  showTitle={ false }
73
+ enableAlpha
73
74
  />
74
75
  </>
75
76
  );
@@ -62,6 +62,7 @@ function ScreenTextColor( { name } ) {
62
62
  disableCustomColors={ ! areCustomSolidsEnabled }
63
63
  __experimentalHasMultipleOrigins
64
64
  showTitle={ false }
65
+ enableAlpha
65
66
  />
66
67
  </>
67
68
  );
@@ -0,0 +1,39 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import TypographyPanel from './typography-panel';
10
+ import ScreenHeader from './header';
11
+
12
+ const elements = {
13
+ text: {
14
+ description: __( 'Manage the fonts used on the site.' ),
15
+ title: __( 'Text' ),
16
+ },
17
+ link: {
18
+ description: __( 'Manage the fonts and typography used on the links.' ),
19
+ title: __( 'Links' ),
20
+ },
21
+ };
22
+
23
+ function ScreenTypographyElement( { name, element } ) {
24
+ const parentMenu =
25
+ name === undefined ? '/typography' : '/blocks/' + name + '/typography';
26
+
27
+ return (
28
+ <>
29
+ <ScreenHeader
30
+ back={ parentMenu }
31
+ title={ elements[ element ].title }
32
+ description={ elements[ element ].description }
33
+ />
34
+ <TypographyPanel name={ name } element={ element } />
35
+ </>
36
+ );
37
+ }
38
+
39
+ export default ScreenTypographyElement;
@@ -2,12 +2,69 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
+ import {
6
+ __experimentalItemGroup as ItemGroup,
7
+ __experimentalVStack as VStack,
8
+ __experimentalHStack as HStack,
9
+ FlexItem,
10
+ } from '@wordpress/components';
5
11
 
6
12
  /**
7
13
  * Internal dependencies
8
14
  */
9
- import TypographyPanel from './typography-panel';
10
15
  import ScreenHeader from './header';
16
+ import NavigationButton from './navigation-button';
17
+ import { useStyle } from './hooks';
18
+ import Subtitle from './subtitle';
19
+ import TypographyPanel from './typography-panel';
20
+
21
+ function Item( { name, parentMenu, element, label } ) {
22
+ const hasSupport = ! name;
23
+ const prefix =
24
+ element === 'text' || ! element ? '' : `elements.${ element }.`;
25
+ const extraStyles =
26
+ element === 'link'
27
+ ? {
28
+ textDecoration: 'underline',
29
+ }
30
+ : {};
31
+ const [ fontFamily ] = useStyle( prefix + 'typography.fontFamily', name );
32
+ const [ fontStyle ] = useStyle( prefix + 'typography.fontStyle', name );
33
+ const [ fontWeight ] = useStyle( prefix + 'typography.fontWeight', name );
34
+ const [ letterSpacing ] = useStyle(
35
+ prefix + 'typography.letterSpacing',
36
+ name
37
+ );
38
+ const [ backgroundColor ] = useStyle( prefix + 'color.background', name );
39
+ const [ gradientValue ] = useStyle( prefix + 'color.gradient', name );
40
+ const [ color ] = useStyle( prefix + 'color.text', name );
41
+
42
+ if ( ! hasSupport ) {
43
+ return null;
44
+ }
45
+
46
+ return (
47
+ <NavigationButton path={ parentMenu + '/typography/' + element }>
48
+ <HStack justify="flex-start">
49
+ <FlexItem
50
+ className="edit-site-global-styles-screen-typography__indicator"
51
+ style={ {
52
+ fontFamily: fontFamily ?? 'serif',
53
+ background: gradientValue ?? backgroundColor,
54
+ color,
55
+ fontStyle,
56
+ fontWeight,
57
+ letterSpacing,
58
+ ...extraStyles,
59
+ } }
60
+ >
61
+ { __( 'Aa' ) }
62
+ </FlexItem>
63
+ <FlexItem>{ label }</FlexItem>
64
+ </HStack>
65
+ </NavigationButton>
66
+ );
67
+ }
11
68
 
12
69
  function ScreenTypography( { name } ) {
13
70
  const parentMenu = name === undefined ? '' : '/blocks/' + name;
@@ -18,10 +75,34 @@ function ScreenTypography( { name } ) {
18
75
  back={ parentMenu ? parentMenu : '/' }
19
76
  title={ __( 'Typography' ) }
20
77
  description={ __(
21
- 'Manage the fonts used on the website and the default aspect of different global elements.'
78
+ 'Manage the typography settings for different elements.'
22
79
  ) }
23
80
  />
24
- <TypographyPanel name={ name } />
81
+
82
+ { ! name && (
83
+ <div className="edit-site-global-styles-screen-typography">
84
+ <VStack spacing={ 3 }>
85
+ <Subtitle>{ __( 'Elements' ) }</Subtitle>
86
+ <ItemGroup isBordered isSeparated>
87
+ <Item
88
+ name={ name }
89
+ parentMenu={ parentMenu }
90
+ element="text"
91
+ label={ __( 'Text' ) }
92
+ />
93
+ <Item
94
+ name={ name }
95
+ parentMenu={ parentMenu }
96
+ element="link"
97
+ label={ __( 'Links' ) }
98
+ />
99
+ </ItemGroup>
100
+ </VStack>
101
+ </div>
102
+ ) }
103
+
104
+ { /* no typogrpahy elements support yet for blocks */ }
105
+ { !! name && <TypographyPanel name={ name } element="text" /> }
25
106
  </>
26
107
  );
27
108
  }
@@ -15,6 +15,30 @@
15
15
  }
16
16
  }
17
17
 
18
+ .edit-site-typography-panel__preview {
19
+ display: flex;
20
+ align-items: center;
21
+ justify-content: center;
22
+ min-height: 100px;
23
+ margin-bottom: $grid-unit-20;
24
+ background: $gray-100;
25
+ border-radius: $radius-block-ui;
26
+ }
27
+
28
+ .edit-site-global-styles-screen-typography {
29
+ margin: $grid-unit-20;
30
+ }
31
+
32
+ .edit-site-global-styles-screen-typography__indicator {
33
+ height: 24px;
34
+ width: 24px;
35
+ font-size: 14px;
36
+ display: flex !important;
37
+ align-items: center;
38
+ justify-content: center;
39
+ border-radius: $radius-block-ui;
40
+ }
41
+
18
42
  .edit-site-global-styles-screen-colors {
19
43
  margin: $grid-unit-20;
20
44
 
@@ -44,3 +68,12 @@
44
68
  text-transform: uppercase;
45
69
  font-weight: 500;
46
70
  }
71
+
72
+ .edit-site-screen-color-palette-toggle.edit-site-screen-color-palette-toggle {
73
+ margin-right: $grid-unit-20;
74
+ margin-left: $grid-unit-20;
75
+ width: unset;
76
+ .components-toggle-group-control {
77
+ min-height: $grid-unit-40;
78
+ }
79
+ }
@@ -206,7 +206,7 @@ describe( 'global styles renderer', () => {
206
206
  settings: {
207
207
  color: {
208
208
  palette: {
209
- user: [
209
+ custom: [
210
210
  {
211
211
  name: 'White',
212
212
  slug: 'white',
@@ -21,7 +21,7 @@ describe( 'editor utils', () => {
21
21
  name: 'Secondary',
22
22
  },
23
23
  ],
24
- user: [
24
+ custom: [
25
25
  {
26
26
  slug: 'primary',
27
27
  color: '#007cba',