@wordpress/edit-site 5.6.0 → 5.7.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.
Files changed (122) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/add-new-template/new-template-part.js +3 -11
  3. package/build/components/add-new-template/new-template-part.js.map +1 -1
  4. package/build/components/add-new-template/new-template.js +7 -7
  5. package/build/components/add-new-template/new-template.js.map +1 -1
  6. package/build/components/add-new-template/utils.js +1 -1
  7. package/build/components/add-new-template/utils.js.map +1 -1
  8. package/build/components/block-editor/editor-canvas.js +7 -10
  9. package/build/components/block-editor/editor-canvas.js.map +1 -1
  10. package/build/components/global-styles/context-menu.js +2 -3
  11. package/build/components/global-styles/context-menu.js.map +1 -1
  12. package/build/components/global-styles/hooks.js +1 -58
  13. package/build/components/global-styles/hooks.js.map +1 -1
  14. package/build/components/global-styles/preview.js +3 -4
  15. package/build/components/global-styles/preview.js.map +1 -1
  16. package/build/components/global-styles/screen-block-list.js +3 -4
  17. package/build/components/global-styles/screen-block-list.js.map +1 -1
  18. package/build/components/global-styles/screen-colors.js +22 -211
  19. package/build/components/global-styles/screen-colors.js.map +1 -1
  20. package/build/components/global-styles/screen-typography-element.js +4 -0
  21. package/build/components/global-styles/screen-typography-element.js.map +1 -1
  22. package/build/components/global-styles/screen-typography.js +5 -0
  23. package/build/components/global-styles/screen-typography.js.map +1 -1
  24. package/build/components/global-styles/ui.js +5 -35
  25. package/build/components/global-styles/ui.js.map +1 -1
  26. package/build/components/global-styles-renderer/index.js +1 -2
  27. package/build/components/global-styles-renderer/index.js.map +1 -1
  28. package/build/components/secondary-sidebar/list-view-sidebar.js +6 -1
  29. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  30. package/build/components/start-template-options/index.js +44 -9
  31. package/build/components/start-template-options/index.js.map +1 -1
  32. package/build/components/style-book/index.js +6 -7
  33. package/build/components/style-book/index.js.map +1 -1
  34. package/build/hooks/push-changes-to-global-styles/index.js +1 -0
  35. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  36. package/build-module/components/add-new-template/new-template-part.js +3 -9
  37. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  38. package/build-module/components/add-new-template/new-template.js +7 -7
  39. package/build-module/components/add-new-template/new-template.js.map +1 -1
  40. package/build-module/components/add-new-template/utils.js +1 -1
  41. package/build-module/components/add-new-template/utils.js.map +1 -1
  42. package/build-module/components/block-editor/editor-canvas.js +8 -11
  43. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  44. package/build-module/components/global-styles/context-menu.js +2 -2
  45. package/build-module/components/global-styles/context-menu.js.map +1 -1
  46. package/build-module/components/global-styles/hooks.js +1 -52
  47. package/build-module/components/global-styles/hooks.js.map +1 -1
  48. package/build-module/components/global-styles/preview.js +3 -4
  49. package/build-module/components/global-styles/preview.js.map +1 -1
  50. package/build-module/components/global-styles/screen-block-list.js +3 -3
  51. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  52. package/build-module/components/global-styles/screen-colors.js +23 -208
  53. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  54. package/build-module/components/global-styles/screen-typography-element.js +4 -0
  55. package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
  56. package/build-module/components/global-styles/screen-typography.js +5 -0
  57. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  58. package/build-module/components/global-styles/ui.js +5 -30
  59. package/build-module/components/global-styles/ui.js.map +1 -1
  60. package/build-module/components/global-styles-renderer/index.js +1 -2
  61. package/build-module/components/global-styles-renderer/index.js.map +1 -1
  62. package/build-module/components/secondary-sidebar/list-view-sidebar.js +6 -2
  63. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  64. package/build-module/components/start-template-options/index.js +45 -10
  65. package/build-module/components/start-template-options/index.js.map +1 -1
  66. package/build-module/components/style-book/index.js +7 -8
  67. package/build-module/components/style-book/index.js.map +1 -1
  68. package/build-module/hooks/push-changes-to-global-styles/index.js +1 -0
  69. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  70. package/build-style/style-rtl.css +4 -17
  71. package/build-style/style.css +4 -17
  72. package/package.json +31 -31
  73. package/src/components/add-new-template/new-template-part.js +1 -6
  74. package/src/components/add-new-template/new-template.js +3 -6
  75. package/src/components/add-new-template/utils.js +1 -1
  76. package/src/components/block-editor/editor-canvas.js +13 -23
  77. package/src/components/global-styles/context-menu.js +2 -2
  78. package/src/components/global-styles/hooks.js +1 -78
  79. package/src/components/global-styles/preview.js +1 -1
  80. package/src/components/global-styles/screen-block-list.js +2 -2
  81. package/src/components/global-styles/screen-colors.js +25 -229
  82. package/src/components/global-styles/screen-typography-element.js +4 -0
  83. package/src/components/global-styles/screen-typography.js +6 -0
  84. package/src/components/global-styles/stories/index.js +425 -0
  85. package/src/components/global-styles/style.scss +4 -18
  86. package/src/components/global-styles/ui.js +6 -31
  87. package/src/components/global-styles-renderer/index.js +1 -2
  88. package/src/components/secondary-sidebar/list-view-sidebar.js +4 -3
  89. package/src/components/start-template-options/index.js +40 -8
  90. package/src/components/style-book/index.js +10 -16
  91. package/src/components/style-book/style.scss +1 -1
  92. package/src/hooks/push-changes-to-global-styles/index.js +1 -0
  93. package/build/components/global-styles/color-utils.js +0 -17
  94. package/build/components/global-styles/color-utils.js.map +0 -1
  95. package/build/components/global-styles/screen-background-color.js +0 -114
  96. package/build/components/global-styles/screen-background-color.js.map +0 -1
  97. package/build/components/global-styles/screen-button-color.js +0 -88
  98. package/build/components/global-styles/screen-button-color.js.map +0 -1
  99. package/build/components/global-styles/screen-heading-color.js +0 -165
  100. package/build/components/global-styles/screen-heading-color.js.map +0 -1
  101. package/build/components/global-styles/screen-link-color.js +0 -105
  102. package/build/components/global-styles/screen-link-color.js.map +0 -1
  103. package/build/components/global-styles/screen-text-color.js +0 -71
  104. package/build/components/global-styles/screen-text-color.js.map +0 -1
  105. package/build-module/components/global-styles/color-utils.js +0 -9
  106. package/build-module/components/global-styles/color-utils.js.map +0 -1
  107. package/build-module/components/global-styles/screen-background-color.js +0 -97
  108. package/build-module/components/global-styles/screen-background-color.js.map +0 -1
  109. package/build-module/components/global-styles/screen-button-color.js +0 -73
  110. package/build-module/components/global-styles/screen-button-color.js.map +0 -1
  111. package/build-module/components/global-styles/screen-heading-color.js +0 -149
  112. package/build-module/components/global-styles/screen-heading-color.js.map +0 -1
  113. package/build-module/components/global-styles/screen-link-color.js +0 -89
  114. package/build-module/components/global-styles/screen-link-color.js.map +0 -1
  115. package/build-module/components/global-styles/screen-text-color.js +0 -56
  116. package/build-module/components/global-styles/screen-text-color.js.map +0 -1
  117. package/src/components/global-styles/color-utils.js +0 -14
  118. package/src/components/global-styles/screen-background-color.js +0 -132
  119. package/src/components/global-styles/screen-button-color.js +0 -104
  120. package/src/components/global-styles/screen-heading-color.js +0 -206
  121. package/src/components/global-styles/screen-link-color.js +0 -124
  122. package/src/components/global-styles/screen-text-color.js +0 -62
@@ -1,132 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import classnames from 'classnames';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { __ } from '@wordpress/i18n';
10
- import {
11
- __experimentalColorGradientControl as ColorGradientControl,
12
- privateApis as blockEditorPrivateApis,
13
- } from '@wordpress/block-editor';
14
-
15
- /**
16
- * Internal dependencies
17
- */
18
- import ScreenHeader from './header';
19
- import {
20
- useSupportedStyles,
21
- useColorsPerOrigin,
22
- useGradientsPerOrigin,
23
- } from './hooks';
24
- import { unlock } from '../../private-apis';
25
-
26
- const { useGlobalSetting, useGlobalStyle } = unlock( blockEditorPrivateApis );
27
-
28
- function ScreenBackgroundColor( { name, variation = '' } ) {
29
- const prefix = variation ? `variations.${ variation }.` : '';
30
- const supports = useSupportedStyles( name );
31
- const [ areCustomSolidsEnabled ] = useGlobalSetting( 'color.custom', name );
32
- const [ areCustomGradientsEnabled ] = useGlobalSetting(
33
- 'color.customGradient',
34
- name
35
- );
36
- const colorsPerOrigin = useColorsPerOrigin( name );
37
- const gradientsPerOrigin = useGradientsPerOrigin( name );
38
-
39
- const [ isBackgroundEnabled ] = useGlobalSetting(
40
- 'color.background',
41
- name
42
- );
43
-
44
- const hasBackgroundColor =
45
- supports.includes( 'backgroundColor' ) &&
46
- isBackgroundEnabled &&
47
- ( colorsPerOrigin.length > 0 || areCustomSolidsEnabled );
48
- const hasGradientColor =
49
- supports.includes( 'background' ) &&
50
- ( gradientsPerOrigin.length > 0 || areCustomGradientsEnabled );
51
- const [ backgroundColor, setBackgroundColor ] = useGlobalStyle(
52
- prefix + 'color.background',
53
- name
54
- );
55
- const [ userBackgroundColor ] = useGlobalStyle(
56
- prefix + 'color.background',
57
- name,
58
- 'user'
59
- );
60
- const [ gradient, setGradient ] = useGlobalStyle(
61
- prefix + 'color.gradient',
62
- name
63
- );
64
- const [ userGradient ] = useGlobalStyle(
65
- prefix + 'color.gradient',
66
- name,
67
- 'user'
68
- );
69
-
70
- if ( ! hasBackgroundColor && ! hasGradientColor ) {
71
- return null;
72
- }
73
-
74
- let backgroundSettings = {};
75
- if ( hasBackgroundColor ) {
76
- backgroundSettings = {
77
- colorValue: backgroundColor,
78
- onColorChange: setBackgroundColor,
79
- };
80
- if ( backgroundColor ) {
81
- backgroundSettings.clearable =
82
- backgroundColor === userBackgroundColor;
83
- }
84
- }
85
-
86
- let gradientSettings = {};
87
- if ( hasGradientColor ) {
88
- gradientSettings = {
89
- gradientValue: gradient,
90
- onGradientChange: setGradient,
91
- };
92
- if ( gradient ) {
93
- gradientSettings.clearable = gradient === userGradient;
94
- }
95
- }
96
-
97
- const controlProps = {
98
- ...backgroundSettings,
99
- ...gradientSettings,
100
- };
101
-
102
- return (
103
- <>
104
- <ScreenHeader
105
- title={ __( 'Background' ) }
106
- description={ __(
107
- 'Set a background color or gradient for the whole site.'
108
- ) }
109
- />
110
- <ColorGradientControl
111
- className={ classnames(
112
- 'edit-site-screen-background-color__control',
113
- {
114
- 'has-no-tabs':
115
- ! hasBackgroundColor || ! hasGradientColor,
116
- }
117
- ) }
118
- colors={ colorsPerOrigin }
119
- gradients={ gradientsPerOrigin }
120
- disableCustomColors={ ! areCustomSolidsEnabled }
121
- disableCustomGradients={ ! areCustomGradientsEnabled }
122
- showTitle={ false }
123
- enableAlpha
124
- __experimentalIsRenderedInSidebar
125
- headingLevel={ 3 }
126
- { ...controlProps }
127
- />
128
- </>
129
- );
130
- }
131
-
132
- export default ScreenBackgroundColor;
@@ -1,104 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { __ } from '@wordpress/i18n';
5
- import {
6
- __experimentalColorGradientControl as ColorGradientControl,
7
- privateApis as blockEditorPrivateApis,
8
- } from '@wordpress/block-editor';
9
-
10
- /**
11
- * Internal dependencies
12
- */
13
- import ScreenHeader from './header';
14
- import { useSupportedStyles, useColorsPerOrigin } from './hooks';
15
- import { unlock } from '../../private-apis';
16
-
17
- const { useGlobalSetting, useGlobalStyle } = unlock( blockEditorPrivateApis );
18
-
19
- function ScreenButtonColor( { name, variation = '' } ) {
20
- const prefix = variation ? `variations.${ variation }.` : '';
21
- const supports = useSupportedStyles( name );
22
- const colorsPerOrigin = useColorsPerOrigin( name );
23
- const [ areCustomSolidsEnabled ] = useGlobalSetting( 'color.custom', name );
24
- const [ isBackgroundEnabled ] = useGlobalSetting(
25
- 'color.background',
26
- name
27
- );
28
-
29
- const hasButtonColor =
30
- supports.includes( 'buttonColor' ) &&
31
- isBackgroundEnabled &&
32
- ( colorsPerOrigin.length > 0 || areCustomSolidsEnabled );
33
-
34
- const [ buttonTextColor, setButtonTextColor ] = useGlobalStyle(
35
- prefix + 'elements.button.color.text',
36
- name
37
- );
38
- const [ userButtonTextColor ] = useGlobalStyle(
39
- 'elements.button.color.text',
40
- name,
41
- 'user'
42
- );
43
-
44
- const [ buttonBgColor, setButtonBgColor ] = useGlobalStyle(
45
- 'elements.button.color.background',
46
- name
47
- );
48
- const [ userButtonBgColor ] = useGlobalStyle(
49
- 'elements.button.color.background',
50
- name,
51
- 'user'
52
- );
53
-
54
- if ( ! hasButtonColor ) {
55
- return null;
56
- }
57
-
58
- return (
59
- <>
60
- <ScreenHeader
61
- title={ __( 'Buttons' ) }
62
- description={ __(
63
- 'Set the default colors used for buttons across the site.'
64
- ) }
65
- />
66
-
67
- <h3 className="edit-site-global-styles-section-title">
68
- { __( 'Text color' ) }
69
- </h3>
70
-
71
- <ColorGradientControl
72
- className="edit-site-screen-button-color__control"
73
- colors={ colorsPerOrigin }
74
- disableCustomColors={ ! areCustomSolidsEnabled }
75
- showTitle={ false }
76
- enableAlpha
77
- __experimentalIsRenderedInSidebar
78
- colorValue={ buttonTextColor }
79
- onColorChange={ setButtonTextColor }
80
- clearable={ buttonTextColor === userButtonTextColor }
81
- headingLevel={ 4 }
82
- />
83
-
84
- <h3 className="edit-site-global-styles-section-title">
85
- { __( 'Background color' ) }
86
- </h3>
87
-
88
- <ColorGradientControl
89
- className="edit-site-screen-button-color__control"
90
- colors={ colorsPerOrigin }
91
- disableCustomColors={ ! areCustomSolidsEnabled }
92
- showTitle={ false }
93
- enableAlpha
94
- __experimentalIsRenderedInSidebar
95
- colorValue={ buttonBgColor }
96
- onColorChange={ setButtonBgColor }
97
- clearable={ buttonBgColor === userButtonBgColor }
98
- headingLevel={ 4 }
99
- />
100
- </>
101
- );
102
- }
103
-
104
- export default ScreenButtonColor;
@@ -1,206 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { sprintf, __ } from '@wordpress/i18n';
5
- import {
6
- __experimentalToggleGroupControl as ToggleGroupControl,
7
- __experimentalToggleGroupControlOption as ToggleGroupControlOption,
8
- } from '@wordpress/components';
9
- import {
10
- __experimentalColorGradientControl as ColorGradientControl,
11
- privateApis as blockEditorPrivateApis,
12
- } from '@wordpress/block-editor';
13
- import { useState } from '@wordpress/element';
14
-
15
- /**
16
- * Internal dependencies
17
- */
18
- import ScreenHeader from './header';
19
- import {
20
- useSupportedStyles,
21
- useColorsPerOrigin,
22
- useGradientsPerOrigin,
23
- } from './hooks';
24
- import { unlock } from '../../private-apis';
25
-
26
- const { useGlobalSetting, useGlobalStyle } = unlock( blockEditorPrivateApis );
27
-
28
- function ScreenHeadingColor( { name, variation = '' } ) {
29
- const prefix = variation ? `variations.${ variation }.` : '';
30
- const [ selectedLevel, setCurrentTab ] = useState( 'heading' );
31
- const supports = useSupportedStyles( name );
32
- const [ areCustomSolidsEnabled ] = useGlobalSetting( 'color.custom', name );
33
- const [ areCustomGradientsEnabled ] = useGlobalSetting(
34
- 'color.customGradient',
35
- name
36
- );
37
- const [ isTextEnabled ] = useGlobalSetting( 'color.text', name );
38
- const [ isBackgroundEnabled ] = useGlobalSetting(
39
- 'color.background',
40
- name
41
- );
42
- const colorsPerOrigin = useColorsPerOrigin( name );
43
- const gradientsPerOrigin = useGradientsPerOrigin( name );
44
-
45
- const hasTextColor =
46
- supports.includes( 'color' ) &&
47
- isTextEnabled &&
48
- ( colorsPerOrigin.length > 0 || areCustomSolidsEnabled );
49
-
50
- const hasBackgroundColor =
51
- supports.includes( 'backgroundColor' ) &&
52
- isBackgroundEnabled &&
53
- ( colorsPerOrigin.length > 0 || areCustomSolidsEnabled );
54
- const hasGradientColor =
55
- supports.includes( 'background' ) &&
56
- ( gradientsPerOrigin.length > 0 || areCustomGradientsEnabled );
57
-
58
- const [ color, setColor ] = useGlobalStyle(
59
- prefix + 'elements.' + selectedLevel + '.color.text',
60
- name
61
- );
62
- const [ userColor ] = useGlobalStyle(
63
- prefix + 'elements.' + selectedLevel + '.color.text',
64
- name,
65
- 'user'
66
- );
67
-
68
- const [ backgroundColor, setBackgroundColor ] = useGlobalStyle(
69
- prefix + 'elements.' + selectedLevel + '.color.background',
70
- name
71
- );
72
- const [ userBackgroundColor ] = useGlobalStyle(
73
- prefix + 'elements.' + selectedLevel + '.color.background',
74
- name,
75
- 'user'
76
- );
77
- const [ gradient, setGradient ] = useGlobalStyle(
78
- prefix + 'elements.' + selectedLevel + '.color.gradient',
79
- name
80
- );
81
- const [ userGradient ] = useGlobalStyle(
82
- prefix + 'elements.' + selectedLevel + '.color.gradient',
83
- name,
84
- 'user'
85
- );
86
-
87
- if ( ! hasTextColor && ! hasBackgroundColor && ! hasGradientColor ) {
88
- return null;
89
- }
90
-
91
- let backgroundSettings = {};
92
- if ( hasBackgroundColor ) {
93
- backgroundSettings = {
94
- colorValue: backgroundColor,
95
- onColorChange: setBackgroundColor,
96
- };
97
- if ( backgroundColor ) {
98
- backgroundSettings.clearable =
99
- backgroundColor === userBackgroundColor;
100
- }
101
- }
102
-
103
- let gradientSettings = {};
104
- if ( hasGradientColor ) {
105
- gradientSettings = {
106
- gradientValue: gradient,
107
- onGradientChange: setGradient,
108
- };
109
- if ( gradient ) {
110
- gradientSettings.clearable = gradient === userGradient;
111
- }
112
- }
113
-
114
- const controlProps = {
115
- ...backgroundSettings,
116
- ...gradientSettings,
117
- };
118
-
119
- return (
120
- <>
121
- <ScreenHeader
122
- title={ __( 'Headings' ) }
123
- description={ __(
124
- 'Set the default color used for headings across the site.'
125
- ) }
126
- />
127
- <div className="edit-site-global-styles-screen-heading-color">
128
- <h3>{ __( 'Select heading level' ) }</h3>
129
-
130
- <ToggleGroupControl
131
- __nextHasNoMarginBottom
132
- label={ __( 'Select heading level' ) }
133
- hideLabelFromVision={ true }
134
- value={ selectedLevel }
135
- onChange={ setCurrentTab }
136
- isBlock
137
- >
138
- <ToggleGroupControlOption
139
- value="heading"
140
- /* translators: 'All' refers to selecting all heading levels
141
- and applying the same style to h1-h6. */
142
- label={ __( 'All' ) }
143
- />
144
- <ToggleGroupControlOption value="h1" label={ __( 'H1' ) } />
145
- <ToggleGroupControlOption value="h2" label={ __( 'H2' ) } />
146
- <ToggleGroupControlOption value="h3" label={ __( 'H3' ) } />
147
- <ToggleGroupControlOption value="h4" label={ __( 'H4' ) } />
148
- <ToggleGroupControlOption value="h5" label={ __( 'H5' ) } />
149
- <ToggleGroupControlOption value="h6" label={ __( 'H6' ) } />
150
- </ToggleGroupControl>
151
- </div>
152
- { hasTextColor && (
153
- <div className="edit-site-global-styles-screen-heading-color">
154
- <h3>
155
- { selectedLevel === 'heading'
156
- ? __( 'Text color for all heading levels' )
157
- : sprintf(
158
- /* translators: %s: heading level (h1-h6) */
159
- __( 'Text color for %s' ),
160
- selectedLevel.toUpperCase()
161
- ) }
162
- </h3>
163
- <ColorGradientControl
164
- className="edit-site-screen-heading-text-color__control"
165
- colors={ colorsPerOrigin }
166
- disableCustomColors={ ! areCustomSolidsEnabled }
167
- showTitle={ false }
168
- enableAlpha
169
- __experimentalIsRenderedInSidebar
170
- colorValue={ color }
171
- onColorChange={ setColor }
172
- clearable={ color === userColor }
173
- headingLevel={ 4 }
174
- />
175
- </div>
176
- ) }
177
- { hasBackgroundColor && (
178
- <div className="edit-site-global-styles-screen-heading-color">
179
- <h3>
180
- { selectedLevel === 'heading'
181
- ? __( 'Background color for all heading levels' )
182
- : sprintf(
183
- /* translators: %s: heading level (h1-h6) */
184
- __( 'Background color for %s' ),
185
- selectedLevel.toUpperCase()
186
- ) }
187
- </h3>
188
- <ColorGradientControl
189
- className="edit-site-screen-heading-background-color__control"
190
- colors={ colorsPerOrigin }
191
- gradients={ gradientsPerOrigin }
192
- disableCustomColors={ ! areCustomSolidsEnabled }
193
- disableCustomGradients={ ! areCustomGradientsEnabled }
194
- showTitle={ false }
195
- enableAlpha
196
- __experimentalIsRenderedInSidebar
197
- headingLevel={ 4 }
198
- { ...controlProps }
199
- />
200
- </div>
201
- ) }
202
- </>
203
- );
204
- }
205
-
206
- export default ScreenHeadingColor;
@@ -1,124 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { __ } from '@wordpress/i18n';
5
- import {
6
- __experimentalColorGradientControl as ColorGradientControl,
7
- privateApis as blockEditorPrivateApis,
8
- } from '@wordpress/block-editor';
9
- import { TabPanel } from '@wordpress/components';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
- import ScreenHeader from './header';
15
- import { useSupportedStyles, useColorsPerOrigin } from './hooks';
16
- import { unlock } from '../../private-apis';
17
-
18
- const { useGlobalSetting, useGlobalStyle } = unlock( blockEditorPrivateApis );
19
-
20
- function ScreenLinkColor( { name, variation = '' } ) {
21
- const prefix = variation ? `variations.${ variation }.` : '';
22
- const supports = useSupportedStyles( name );
23
- const [ areCustomSolidsEnabled ] = useGlobalSetting( 'color.custom', name );
24
- const colorsPerOrigin = useColorsPerOrigin( name );
25
- const [ isLinkEnabled ] = useGlobalSetting( 'color.link', name );
26
-
27
- const hasLinkColor =
28
- supports.includes( 'linkColor' ) &&
29
- isLinkEnabled &&
30
- ( colorsPerOrigin.length > 0 || areCustomSolidsEnabled );
31
-
32
- const pseudoStates = {
33
- default: {
34
- label: __( 'Default' ),
35
- value: useGlobalStyle(
36
- prefix + 'elements.link.color.text',
37
- name
38
- )[ 0 ],
39
- handler: useGlobalStyle(
40
- prefix + 'elements.link.color.text',
41
- name
42
- )[ 1 ],
43
- userValue: useGlobalStyle(
44
- prefix + 'elements.link.color.text',
45
- name,
46
- 'user'
47
- )[ 0 ],
48
- },
49
- hover: {
50
- label: __( 'Hover' ),
51
- value: useGlobalStyle(
52
- prefix + 'elements.link.:hover.color.text',
53
- name
54
- )[ 0 ],
55
- handler: useGlobalStyle(
56
- prefix + 'elements.link.:hover.color.text',
57
- name
58
- )[ 1 ],
59
- userValue: useGlobalStyle(
60
- prefix + 'elements.link.:hover.color.text',
61
- name,
62
- 'user'
63
- )[ 0 ],
64
- },
65
- };
66
-
67
- if ( ! hasLinkColor ) {
68
- return null;
69
- }
70
-
71
- const tabs = Object.entries( pseudoStates ).map(
72
- ( [ selector, config ] ) => {
73
- return {
74
- name: selector,
75
- title: config.label,
76
- className: `color-text-${ selector }`,
77
- };
78
- }
79
- );
80
-
81
- return (
82
- <>
83
- <ScreenHeader
84
- title={ __( 'Links' ) }
85
- description={ __(
86
- 'Set the colors used for links across the site.'
87
- ) }
88
- />
89
-
90
- <TabPanel tabs={ tabs }>
91
- { ( tab ) => {
92
- const pseudoSelectorConfig =
93
- pseudoStates[ tab.name ] ?? null;
94
-
95
- if ( ! pseudoSelectorConfig ) {
96
- return null;
97
- }
98
-
99
- return (
100
- <>
101
- <ColorGradientControl
102
- className="edit-site-screen-link-color__control"
103
- colors={ colorsPerOrigin }
104
- disableCustomColors={ ! areCustomSolidsEnabled }
105
- showTitle={ false }
106
- enableAlpha
107
- __experimentalIsRenderedInSidebar
108
- colorValue={ pseudoSelectorConfig.value }
109
- onColorChange={ pseudoSelectorConfig.handler }
110
- clearable={
111
- pseudoSelectorConfig.value ===
112
- pseudoSelectorConfig.userValue
113
- }
114
- headingLevel={ 3 }
115
- />
116
- </>
117
- );
118
- } }
119
- </TabPanel>
120
- </>
121
- );
122
- }
123
-
124
- export default ScreenLinkColor;
@@ -1,62 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { __ } from '@wordpress/i18n';
5
- import {
6
- __experimentalColorGradientControl as ColorGradientControl,
7
- privateApis as blockEditorPrivateApis,
8
- } from '@wordpress/block-editor';
9
-
10
- /**
11
- * Internal dependencies
12
- */
13
- import ScreenHeader from './header';
14
- import { useSupportedStyles, useColorsPerOrigin } from './hooks';
15
- import { unlock } from '../../private-apis';
16
-
17
- const { useGlobalSetting, useGlobalStyle } = unlock( blockEditorPrivateApis );
18
-
19
- function ScreenTextColor( { name, variation = '' } ) {
20
- const prefix = variation ? `variations.${ variation }.` : '';
21
- const supports = useSupportedStyles( name );
22
- const [ areCustomSolidsEnabled ] = useGlobalSetting( 'color.custom', name );
23
- const [ isTextEnabled ] = useGlobalSetting( 'color.text', name );
24
- const colorsPerOrigin = useColorsPerOrigin( name );
25
-
26
- const hasTextColor =
27
- supports.includes( 'color' ) &&
28
- isTextEnabled &&
29
- ( colorsPerOrigin.length > 0 || areCustomSolidsEnabled );
30
-
31
- const [ color, setColor ] = useGlobalStyle( prefix + 'color.text', name );
32
- const [ userColor ] = useGlobalStyle( prefix + 'color.text', name, 'user' );
33
-
34
- if ( ! hasTextColor ) {
35
- return null;
36
- }
37
-
38
- return (
39
- <>
40
- <ScreenHeader
41
- title={ __( 'Text' ) }
42
- description={ __(
43
- 'Set the default color used for text across the site.'
44
- ) }
45
- />
46
- <ColorGradientControl
47
- className="edit-site-screen-text-color__control"
48
- colors={ colorsPerOrigin }
49
- disableCustomColors={ ! areCustomSolidsEnabled }
50
- showTitle={ false }
51
- enableAlpha
52
- __experimentalIsRenderedInSidebar
53
- colorValue={ color }
54
- onColorChange={ setColor }
55
- clearable={ color === userColor }
56
- headingLevel={ 3 }
57
- />
58
- </>
59
- );
60
- }
61
-
62
- export default ScreenTextColor;