@wordpress/edit-site 3.0.26 → 3.1.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 (274) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/LICENSE.md +1 -1
  3. package/build/components/block-editor/resizable-editor.js +1 -0
  4. package/build/components/block-editor/resizable-editor.js.map +1 -1
  5. package/build/components/code-editor/code-editor-text-area.js +95 -0
  6. package/build/components/code-editor/code-editor-text-area.js.map +1 -0
  7. package/build/components/code-editor/index.js +79 -0
  8. package/build/components/code-editor/index.js.map +1 -0
  9. package/build/components/editor/index.js +10 -5
  10. package/build/components/editor/index.js.map +1 -1
  11. package/build/components/global-styles/border-panel.js +81 -22
  12. package/build/components/global-styles/border-panel.js.map +1 -1
  13. package/build/components/global-styles/context-menu.js +4 -6
  14. package/build/components/global-styles/context-menu.js.map +1 -1
  15. package/build/components/global-styles/global-styles-provider.js +1 -0
  16. package/build/components/global-styles/global-styles-provider.js.map +1 -1
  17. package/build/components/global-styles/header.js +2 -7
  18. package/build/components/global-styles/header.js.map +1 -1
  19. package/build/components/global-styles/navigation-button.js +27 -12
  20. package/build/components/global-styles/navigation-button.js.map +1 -1
  21. package/build/components/global-styles/palette.js +2 -2
  22. package/build/components/global-styles/palette.js.map +1 -1
  23. package/build/components/global-styles/preview.js +46 -15
  24. package/build/components/global-styles/preview.js.map +1 -1
  25. package/build/components/global-styles/screen-background-color.js +9 -12
  26. package/build/components/global-styles/screen-background-color.js.map +1 -1
  27. package/build/components/global-styles/screen-block-list.js +2 -3
  28. package/build/components/global-styles/screen-block-list.js.map +1 -1
  29. package/build/components/global-styles/screen-block.js +0 -1
  30. package/build/components/global-styles/screen-block.js.map +1 -1
  31. package/build/components/global-styles/screen-color-palette.js +0 -2
  32. package/build/components/global-styles/screen-color-palette.js.map +1 -1
  33. package/build/components/global-styles/screen-colors.js +5 -6
  34. package/build/components/global-styles/screen-colors.js.map +1 -1
  35. package/build/components/global-styles/screen-layout.js +0 -2
  36. package/build/components/global-styles/screen-layout.js.map +1 -1
  37. package/build/components/global-styles/screen-link-color.js +6 -12
  38. package/build/components/global-styles/screen-link-color.js.map +1 -1
  39. package/build/components/global-styles/screen-root.js +22 -3
  40. package/build/components/global-styles/screen-root.js.map +1 -1
  41. package/build/components/global-styles/screen-style-variations.js +138 -0
  42. package/build/components/global-styles/screen-style-variations.js.map +1 -0
  43. package/build/components/global-styles/screen-text-color.js +6 -12
  44. package/build/components/global-styles/screen-text-color.js.map +1 -1
  45. package/build/components/global-styles/screen-typography-element.js +0 -2
  46. package/build/components/global-styles/screen-typography-element.js.map +1 -1
  47. package/build/components/global-styles/screen-typography.js +2 -3
  48. package/build/components/global-styles/screen-typography.js.map +1 -1
  49. package/build/components/global-styles/ui.js +31 -14
  50. package/build/components/global-styles/ui.js.map +1 -1
  51. package/build/components/header/index.js +12 -4
  52. package/build/components/header/index.js.map +1 -1
  53. package/build/components/header/mode-switcher/index.js +78 -0
  54. package/build/components/header/mode-switcher/index.js.map +1 -0
  55. package/build/components/header/more-menu/copy-content-menu-item.js +74 -0
  56. package/build/components/header/more-menu/copy-content-menu-item.js.map +1 -0
  57. package/build/components/header/more-menu/index.js +72 -39
  58. package/build/components/header/more-menu/index.js.map +1 -1
  59. package/build/{plugins → components/header/more-menu}/site-export.js +0 -0
  60. package/build/components/header/more-menu/site-export.js.map +1 -0
  61. package/build/{plugins → components/header/more-menu}/welcome-guide-menu-item.js +1 -1
  62. package/build/components/header/more-menu/welcome-guide-menu-item.js.map +1 -0
  63. package/build/components/header/tools-more-menu-group/index.js +1 -5
  64. package/build/components/header/tools-more-menu-group/index.js.map +1 -1
  65. package/build/components/keyboard-shortcut-help-modal/config.js +45 -0
  66. package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -0
  67. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +56 -0
  68. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -0
  69. package/build/components/keyboard-shortcut-help-modal/index.js +137 -0
  70. package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -0
  71. package/build/components/keyboard-shortcut-help-modal/shortcut.js +65 -0
  72. package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -0
  73. package/build/components/keyboard-shortcuts/index.js +26 -1
  74. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  75. package/build/components/list/actions/index.js +5 -4
  76. package/build/components/list/actions/index.js.map +1 -1
  77. package/build/components/list/actions/rename-menu-item.js +3 -3
  78. package/build/components/list/actions/rename-menu-item.js.map +1 -1
  79. package/build/components/list/added-by.js +51 -50
  80. package/build/components/list/added-by.js.map +1 -1
  81. package/build/components/routes/redirect-to-homepage.js +87 -0
  82. package/build/components/routes/redirect-to-homepage.js.map +1 -0
  83. package/build/components/secondary-sidebar/inserter-sidebar.js +13 -3
  84. package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
  85. package/build/components/secondary-sidebar/list-view-sidebar.js +7 -5
  86. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  87. package/build/components/sidebar/default-sidebar.js +4 -2
  88. package/build/components/sidebar/default-sidebar.js.map +1 -1
  89. package/build/components/sidebar/global-styles-sidebar.js +1 -0
  90. package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
  91. package/build/components/url-query-controller/index.js +1 -38
  92. package/build/components/url-query-controller/index.js.map +1 -1
  93. package/build/index.js +9 -4
  94. package/build/index.js.map +1 -1
  95. package/build/store/actions.js +26 -25
  96. package/build/store/actions.js.map +1 -1
  97. package/build/store/defaults.js +2 -1
  98. package/build/store/defaults.js.map +1 -1
  99. package/build/store/reducer.js +11 -0
  100. package/build/store/reducer.js.map +1 -1
  101. package/build/store/selectors.js +13 -0
  102. package/build/store/selectors.js.map +1 -1
  103. package/build-module/components/block-editor/resizable-editor.js +1 -0
  104. package/build-module/components/block-editor/resizable-editor.js.map +1 -1
  105. package/build-module/components/code-editor/code-editor-text-area.js +83 -0
  106. package/build-module/components/code-editor/code-editor-text-area.js.map +1 -0
  107. package/build-module/components/code-editor/index.js +62 -0
  108. package/build-module/components/code-editor/index.js.map +1 -0
  109. package/build-module/components/editor/index.js +9 -5
  110. package/build-module/components/editor/index.js.map +1 -1
  111. package/build-module/components/global-styles/border-panel.js +82 -23
  112. package/build-module/components/global-styles/border-panel.js.map +1 -1
  113. package/build-module/components/global-styles/context-menu.js +1 -1
  114. package/build-module/components/global-styles/context-menu.js.map +1 -1
  115. package/build-module/components/global-styles/global-styles-provider.js +1 -1
  116. package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
  117. package/build-module/components/global-styles/header.js +2 -5
  118. package/build-module/components/global-styles/header.js.map +1 -1
  119. package/build-module/components/global-styles/navigation-button.js +27 -10
  120. package/build-module/components/global-styles/navigation-button.js.map +1 -1
  121. package/build-module/components/global-styles/palette.js +1 -1
  122. package/build-module/components/global-styles/palette.js.map +1 -1
  123. package/build-module/components/global-styles/preview.js +45 -15
  124. package/build-module/components/global-styles/preview.js.map +1 -1
  125. package/build-module/components/global-styles/screen-background-color.js +9 -13
  126. package/build-module/components/global-styles/screen-background-color.js.map +1 -1
  127. package/build-module/components/global-styles/screen-block-list.js +1 -2
  128. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  129. package/build-module/components/global-styles/screen-block.js +0 -1
  130. package/build-module/components/global-styles/screen-block.js.map +1 -1
  131. package/build-module/components/global-styles/screen-color-palette.js +0 -2
  132. package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
  133. package/build-module/components/global-styles/screen-colors.js +2 -3
  134. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  135. package/build-module/components/global-styles/screen-layout.js +0 -2
  136. package/build-module/components/global-styles/screen-layout.js.map +1 -1
  137. package/build-module/components/global-styles/screen-link-color.js +7 -13
  138. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  139. package/build-module/components/global-styles/screen-root.js +21 -4
  140. package/build-module/components/global-styles/screen-root.js.map +1 -1
  141. package/build-module/components/global-styles/screen-style-variations.js +119 -0
  142. package/build-module/components/global-styles/screen-style-variations.js.map +1 -0
  143. package/build-module/components/global-styles/screen-text-color.js +7 -13
  144. package/build-module/components/global-styles/screen-text-color.js.map +1 -1
  145. package/build-module/components/global-styles/screen-typography-element.js +0 -2
  146. package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
  147. package/build-module/components/global-styles/screen-typography.js +1 -2
  148. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  149. package/build-module/components/global-styles/ui.js +29 -14
  150. package/build-module/components/global-styles/ui.js.map +1 -1
  151. package/build-module/components/header/index.js +13 -5
  152. package/build-module/components/header/index.js.map +1 -1
  153. package/build-module/components/header/mode-switcher/index.js +65 -0
  154. package/build-module/components/header/mode-switcher/index.js.map +1 -0
  155. package/build-module/components/header/more-menu/copy-content-menu-item.js +59 -0
  156. package/build-module/components/header/more-menu/copy-content-menu-item.js.map +1 -0
  157. package/build-module/components/header/more-menu/index.js +67 -40
  158. package/build-module/components/header/more-menu/index.js.map +1 -1
  159. package/build-module/{plugins → components/header/more-menu}/site-export.js +0 -0
  160. package/build-module/components/header/more-menu/site-export.js.map +1 -0
  161. package/build-module/{plugins → components/header/more-menu}/welcome-guide-menu-item.js +1 -1
  162. package/build-module/components/header/more-menu/welcome-guide-menu-item.js.map +1 -0
  163. package/build-module/components/header/tools-more-menu-group/index.js +2 -5
  164. package/build-module/components/header/tools-more-menu-group/index.js.map +1 -1
  165. package/build-module/components/keyboard-shortcut-help-modal/config.js +36 -0
  166. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -0
  167. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +44 -0
  168. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -0
  169. package/build-module/components/keyboard-shortcut-help-modal/index.js +120 -0
  170. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -0
  171. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +58 -0
  172. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -0
  173. package/build-module/components/keyboard-shortcuts/index.js +26 -1
  174. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  175. package/build-module/components/list/actions/index.js +5 -4
  176. package/build-module/components/list/actions/index.js.map +1 -1
  177. package/build-module/components/list/actions/rename-menu-item.js +3 -3
  178. package/build-module/components/list/actions/rename-menu-item.js.map +1 -1
  179. package/build-module/components/list/added-by.js +52 -51
  180. package/build-module/components/list/added-by.js.map +1 -1
  181. package/build-module/components/routes/redirect-to-homepage.js +75 -0
  182. package/build-module/components/routes/redirect-to-homepage.js.map +1 -0
  183. package/build-module/components/secondary-sidebar/inserter-sidebar.js +14 -4
  184. package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
  185. package/build-module/components/secondary-sidebar/list-view-sidebar.js +7 -5
  186. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  187. package/build-module/components/sidebar/default-sidebar.js +4 -2
  188. package/build-module/components/sidebar/default-sidebar.js.map +1 -1
  189. package/build-module/components/sidebar/global-styles-sidebar.js +1 -0
  190. package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
  191. package/build-module/components/url-query-controller/index.js +3 -40
  192. package/build-module/components/url-query-controller/index.js.map +1 -1
  193. package/build-module/index.js +8 -3
  194. package/build-module/index.js.map +1 -1
  195. package/build-module/store/actions.js +22 -23
  196. package/build-module/store/actions.js.map +1 -1
  197. package/build-module/store/defaults.js +2 -1
  198. package/build-module/store/defaults.js.map +1 -1
  199. package/build-module/store/reducer.js +11 -0
  200. package/build-module/store/reducer.js.map +1 -1
  201. package/build-module/store/selectors.js +11 -0
  202. package/build-module/store/selectors.js.map +1 -1
  203. package/build-style/style-rtl.css +199 -68
  204. package/build-style/style.css +199 -68
  205. package/package.json +29 -28
  206. package/src/components/block-editor/resizable-editor.js +1 -0
  207. package/src/components/block-editor/style.scss +10 -18
  208. package/src/components/code-editor/code-editor-text-area.js +79 -0
  209. package/src/components/code-editor/index.js +65 -0
  210. package/src/components/code-editor/style.scss +100 -0
  211. package/src/components/editor/index.js +16 -7
  212. package/src/components/global-styles/border-panel.js +106 -42
  213. package/src/components/global-styles/context-menu.js +1 -1
  214. package/src/components/global-styles/global-styles-provider.js +1 -2
  215. package/src/components/global-styles/header.js +3 -5
  216. package/src/components/global-styles/navigation-button.js +14 -10
  217. package/src/components/global-styles/palette.js +1 -1
  218. package/src/components/global-styles/preview.js +46 -18
  219. package/src/components/global-styles/screen-background-color.js +7 -12
  220. package/src/components/global-styles/screen-block-list.js +1 -2
  221. package/src/components/global-styles/screen-block.js +1 -1
  222. package/src/components/global-styles/screen-color-palette.js +0 -2
  223. package/src/components/global-styles/screen-colors.js +2 -3
  224. package/src/components/global-styles/screen-layout.js +1 -5
  225. package/src/components/global-styles/screen-link-color.js +6 -16
  226. package/src/components/global-styles/screen-root.js +32 -3
  227. package/src/components/global-styles/screen-style-variations.js +130 -0
  228. package/src/components/global-styles/screen-text-color.js +6 -16
  229. package/src/components/global-styles/screen-typography-element.js +0 -4
  230. package/src/components/global-styles/screen-typography.js +2 -3
  231. package/src/components/global-styles/style.scss +24 -25
  232. package/src/components/global-styles/ui.js +55 -25
  233. package/src/components/header/document-actions/style.scss +1 -9
  234. package/src/components/header/index.js +10 -2
  235. package/src/components/header/mode-switcher/index.js +67 -0
  236. package/src/components/header/more-menu/copy-content-menu-item.js +53 -0
  237. package/src/components/header/more-menu/index.js +107 -44
  238. package/src/{plugins → components/header/more-menu}/site-export.js +0 -0
  239. package/src/{plugins → components/header/more-menu}/welcome-guide-menu-item.js +1 -1
  240. package/src/components/header/style.scss +2 -1
  241. package/src/components/header/tools-more-menu-group/index.js +2 -7
  242. package/src/components/keyboard-shortcut-help-modal/config.js +27 -0
  243. package/src/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +41 -0
  244. package/src/components/keyboard-shortcut-help-modal/index.js +135 -0
  245. package/src/components/keyboard-shortcut-help-modal/shortcut.js +73 -0
  246. package/src/components/keyboard-shortcut-help-modal/style.scss +66 -0
  247. package/src/components/keyboard-shortcuts/index.js +27 -1
  248. package/src/components/list/actions/index.js +5 -4
  249. package/src/components/list/actions/rename-menu-item.js +3 -3
  250. package/src/components/list/added-by.js +57 -63
  251. package/src/components/routes/redirect-to-homepage.js +71 -0
  252. package/src/components/secondary-sidebar/inserter-sidebar.js +14 -3
  253. package/src/components/secondary-sidebar/list-view-sidebar.js +12 -5
  254. package/src/components/secondary-sidebar/style.scss +0 -4
  255. package/src/components/sidebar/default-sidebar.js +2 -0
  256. package/src/components/sidebar/global-styles-sidebar.js +1 -0
  257. package/src/components/sidebar/style.scss +21 -14
  258. package/src/components/url-query-controller/index.js +3 -35
  259. package/src/index.js +9 -2
  260. package/src/store/actions.js +22 -35
  261. package/src/store/defaults.js +1 -0
  262. package/src/store/reducer.js +6 -0
  263. package/src/store/selectors.js +11 -0
  264. package/src/store/test/actions.js +2 -92
  265. package/src/style.scss +2 -0
  266. package/build/plugins/index.js +0 -28
  267. package/build/plugins/index.js.map +0 -1
  268. package/build/plugins/site-export.js.map +0 -1
  269. package/build/plugins/welcome-guide-menu-item.js.map +0 -1
  270. package/build-module/plugins/index.js +0 -20
  271. package/build-module/plugins/index.js.map +0 -1
  272. package/build-module/plugins/site-export.js.map +0 -1
  273. package/build-module/plugins/welcome-guide-menu-item.js.map +0 -1
  274. package/src/plugins/index.js +0 -24
@@ -0,0 +1,100 @@
1
+ .edit-site-code-editor {
2
+ position: relative;
3
+ width: 100%;
4
+ background-color: $white;
5
+ flex-grow: 1;
6
+
7
+ &__body {
8
+ width: 100%;
9
+ padding: 0 $grid-unit-15 $grid-unit-15 $grid-unit-15;
10
+ max-width: $break-xlarge;
11
+ margin-left: auto;
12
+ margin-right: auto;
13
+
14
+ @include break-large() {
15
+ padding: $grid-unit-20 $grid-unit-30 #{ $grid-unit-60 * 2 } $grid-unit-30;
16
+ padding: 0 $grid-unit-30 $grid-unit-30 $grid-unit-30;
17
+ }
18
+ }
19
+
20
+ // Exit code editor toolbar.
21
+ &__toolbar {
22
+ position: sticky;
23
+ z-index: z-index(".edit-site-code-editor__toolbar");
24
+ top: 0;
25
+ left: 0;
26
+ right: 0;
27
+ display: flex;
28
+ background: rgba($white, 0.8);
29
+ padding: $grid-unit-05 $grid-unit-15;
30
+
31
+ @include break-small() {
32
+ padding: $grid-unit-15;
33
+ }
34
+
35
+ @include break-large() {
36
+ padding: $grid-unit-15 $grid-unit-30;
37
+ }
38
+
39
+ h2 {
40
+ line-height: $button-size;
41
+ margin: 0 auto 0 0;
42
+ font-size: $default-font-size;
43
+ color: $gray-900;
44
+ }
45
+
46
+ .components-button svg {
47
+ order: 1;
48
+ }
49
+ }
50
+ }
51
+
52
+ textarea.edit-site-code-editor-text-area.edit-site-code-editor-text-area {
53
+ border: $border-width solid $gray-600;
54
+ border-radius: 0;
55
+ display: block;
56
+ margin: 0;
57
+ width: 100%;
58
+ box-shadow: none;
59
+ resize: none;
60
+ overflow: hidden;
61
+ font-family: $editor-html-font;
62
+ line-height: 2.4;
63
+ min-height: 200px;
64
+ transition: border 0.1s ease-out, box-shadow 0.1s linear;
65
+ @include reduce-motion("transition");
66
+
67
+ // Same padding as title.
68
+ padding: $grid-unit-20;
69
+ @include break-small() {
70
+ padding: $grid-unit-30;
71
+ }
72
+
73
+ /* Fonts smaller than 16px causes mobile safari to zoom. */
74
+ font-size: $mobile-text-min-font-size !important;
75
+ @include break-small {
76
+ font-size: $text-editor-font-size !important;
77
+ }
78
+
79
+ &:focus {
80
+ border-color: var(--wp-admin-theme-color);
81
+ box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
82
+
83
+ // Elevate the z-index on focus so the focus style is uncropped.
84
+ position: relative;
85
+ }
86
+
87
+ &::-webkit-input-placeholder {
88
+ color: $dark-gray-placeholder;
89
+ }
90
+
91
+ &::-moz-placeholder {
92
+ color: $dark-gray-placeholder;
93
+ // Override Firefox default.
94
+ opacity: 1;
95
+ }
96
+
97
+ &:-ms-input-placeholder {
98
+ color: $dark-gray-placeholder;
99
+ }
100
+ }
@@ -30,6 +30,7 @@ import Header from '../header';
30
30
  import { SidebarComplementaryAreaFills } from '../sidebar';
31
31
  import NavigationSidebar from '../navigation-sidebar';
32
32
  import BlockEditor from '../block-editor';
33
+ import CodeEditor from '../code-editor';
33
34
  import KeyboardShortcuts from '../keyboard-shortcuts';
34
35
  import URLQueryController from '../url-query-controller';
35
36
  import InserterSidebar from '../secondary-sidebar/inserter-sidebar';
@@ -60,6 +61,7 @@ function Editor( { onError } ) {
60
61
  isNavigationOpen,
61
62
  previousShortcut,
62
63
  nextShortcut,
64
+ editorMode,
63
65
  } = useSelect( ( select ) => {
64
66
  const {
65
67
  isInserterOpened,
@@ -69,6 +71,7 @@ function Editor( { onError } ) {
69
71
  getEditedPostId,
70
72
  getPage,
71
73
  isNavigationOpened,
74
+ getEditorMode,
72
75
  } = select( editSiteStore );
73
76
  const { hasFinishedResolution, getEntityRecord } = select( coreStore );
74
77
  const postType = getEditedPostType();
@@ -102,6 +105,7 @@ function Editor( { onError } ) {
102
105
  nextShortcut: select(
103
106
  keyboardShortcutsStore
104
107
  ).getAllShortcutKeyCombinations( 'core/edit-site/next-region' ),
108
+ editorMode: getEditorMode(),
105
109
  };
106
110
  }, [] );
107
111
  const { setPage, setIsInserterOpened } = useDispatch( editSiteStore );
@@ -220,13 +224,18 @@ function Editor( { onError } ) {
220
224
  content={
221
225
  <>
222
226
  <EditorNotices />
223
- { template && (
224
- <BlockEditor
225
- setIsInserterOpen={
226
- setIsInserterOpened
227
- }
228
- />
229
- ) }
227
+ { editorMode === 'visual' &&
228
+ template && (
229
+ <BlockEditor
230
+ setIsInserterOpen={
231
+ setIsInserterOpened
232
+ }
233
+ />
234
+ ) }
235
+ { editorMode === 'text' &&
236
+ template && (
237
+ <CodeEditor />
238
+ ) }
230
239
  { templateResolved &&
231
240
  ! template &&
232
241
  settings?.siteUrl &&
@@ -7,7 +7,8 @@ import {
7
7
  __experimentalColorGradientControl as ColorGradientControl,
8
8
  } from '@wordpress/block-editor';
9
9
  import {
10
- PanelBody,
10
+ __experimentalToolsPanel as ToolsPanel,
11
+ __experimentalToolsPanelItem as ToolsPanelItem,
11
12
  __experimentalUnitControl as UnitControl,
12
13
  __experimentalUseCustomUnits as useCustomUnits,
13
14
  } from '@wordpress/components';
@@ -68,6 +69,18 @@ function useHasBorderWidthControl( name ) {
68
69
  }
69
70
 
70
71
  export default function BorderPanel( { name } ) {
72
+ // To better reflect if the user has customized a value we need to
73
+ // ensure the style value being checked is from the `user` origin.
74
+ const [ userBorderStyles ] = useStyle( 'border', name, 'user' );
75
+ const createHasValueCallback = ( feature ) => () =>
76
+ !! userBorderStyles?.[ feature ];
77
+
78
+ const createResetCallback = ( setStyle ) => () => setStyle( undefined );
79
+
80
+ const handleOnChange = ( setStyle ) => ( value ) => {
81
+ setStyle( value || undefined );
82
+ };
83
+
71
84
  const units = useCustomUnits( {
72
85
  availableUnits: useSetting( 'spacing.units' )[ 0 ] || [
73
86
  'px',
@@ -77,70 +90,121 @@ export default function BorderPanel( { name } ) {
77
90
  } );
78
91
 
79
92
  // Border width.
80
- const hasBorderWidth = useHasBorderWidthControl( name );
93
+ const showBorderWidth = useHasBorderWidthControl( name );
81
94
  const [ borderWidthValue, setBorderWidth ] = useStyle(
82
95
  'border.width',
83
96
  name
84
97
  );
85
98
 
86
99
  // Border style.
87
- const hasBorderStyle = useHasBorderStyleControl( name );
100
+ const showBorderStyle = useHasBorderStyleControl( name );
88
101
  const [ borderStyle, setBorderStyle ] = useStyle( 'border.style', name );
89
102
 
90
103
  // Border color.
104
+ const showBorderColor = useHasBorderColorControl( name );
105
+ const [ borderColor, setBorderColor ] = useStyle( 'border.color', name );
91
106
  const [ colors = EMPTY_ARRAY ] = useSetting( 'color.palette' );
92
107
  const disableCustomColors = ! useSetting( 'color.custom' )[ 0 ];
93
108
  const disableCustomGradients = ! useSetting( 'color.customGradient' )[ 0 ];
94
- const hasBorderColor = useHasBorderColorControl( name );
95
- const [ borderColor, setBorderColor ] = useStyle( 'border.color', name );
96
109
 
97
110
  // Border radius.
98
- const hasBorderRadius = useHasBorderRadiusControl( name );
111
+ const showBorderRadius = useHasBorderRadiusControl( name );
99
112
  const [ borderRadiusValues, setBorderRadius ] = useStyle(
100
113
  'border.radius',
101
114
  name
102
115
  );
116
+ const hasBorderRadius = () => {
117
+ const borderValues = userBorderStyles?.radius;
118
+ if ( typeof borderValues === 'object' ) {
119
+ return Object.entries( borderValues ).some( Boolean );
120
+ }
121
+ return !! borderValues;
122
+ };
123
+
124
+ const resetAll = () => {
125
+ setBorderColor( undefined );
126
+ setBorderRadius( undefined );
127
+ setBorderStyle( undefined );
128
+ setBorderWidth( undefined );
129
+ };
130
+
131
+ // When we set a border color or width ensure we have a style so the user
132
+ // can see a visible border.
133
+ const handleOnChangeWithStyle = ( setStyle ) => ( value ) => {
134
+ if ( !! value && ! borderStyle ) {
135
+ setBorderStyle( 'solid' );
136
+ }
137
+
138
+ setStyle( value || undefined );
139
+ };
103
140
 
104
141
  return (
105
- <PanelBody title={ __( 'Border' ) } initialOpen={ true }>
106
- { ( hasBorderWidth || hasBorderStyle ) && (
107
- <div className="edit-site-global-styles-sidebar__border-controls-row">
108
- { hasBorderWidth && (
109
- <UnitControl
110
- value={ borderWidthValue }
111
- label={ __( 'Width' ) }
112
- min={ MIN_BORDER_WIDTH }
113
- onChange={ ( value ) => {
114
- setBorderWidth( value || undefined );
115
- } }
116
- units={ units }
117
- />
118
- ) }
119
- { hasBorderStyle && (
120
- <BorderStyleControl
121
- value={ borderStyle }
122
- onChange={ setBorderStyle }
123
- />
124
- ) }
125
- </div>
142
+ <ToolsPanel label={ __( 'Border' ) } resetAll={ resetAll }>
143
+ { showBorderWidth && (
144
+ <ToolsPanelItem
145
+ className="single-column"
146
+ hasValue={ createHasValueCallback( 'width' ) }
147
+ label={ __( 'Width' ) }
148
+ onDeselect={ createResetCallback( setBorderWidth ) }
149
+ isShownByDefault={ true }
150
+ >
151
+ <UnitControl
152
+ value={ borderWidthValue }
153
+ label={ __( 'Width' ) }
154
+ min={ MIN_BORDER_WIDTH }
155
+ onChange={ handleOnChangeWithStyle( setBorderWidth ) }
156
+ units={ units }
157
+ />
158
+ </ToolsPanelItem>
159
+ ) }
160
+ { showBorderStyle && (
161
+ <ToolsPanelItem
162
+ className="single-column"
163
+ hasValue={ createHasValueCallback( 'style' ) }
164
+ label={ __( 'Style' ) }
165
+ onDeselect={ createResetCallback( setBorderStyle ) }
166
+ isShownByDefault={ true }
167
+ >
168
+ <BorderStyleControl
169
+ value={ borderStyle }
170
+ onChange={ handleOnChange( setBorderStyle ) }
171
+ />
172
+ </ToolsPanelItem>
126
173
  ) }
127
- { hasBorderColor && (
128
- <ColorGradientControl
174
+ { showBorderColor && (
175
+ <ToolsPanelItem
176
+ hasValue={ createHasValueCallback( 'color' ) }
129
177
  label={ __( 'Color' ) }
130
- colorValue={ borderColor }
131
- colors={ colors }
132
- gradients={ undefined }
133
- disableCustomColors={ disableCustomColors }
134
- disableCustomGradients={ disableCustomGradients }
135
- onColorChange={ setBorderColor }
136
- />
178
+ onDeselect={ createResetCallback( setBorderColor ) }
179
+ isShownByDefault={ true }
180
+ >
181
+ <ColorGradientControl
182
+ label={ __( 'Color' ) }
183
+ colorValue={ borderColor }
184
+ colors={ colors }
185
+ gradients={ undefined }
186
+ disableCustomColors={ disableCustomColors }
187
+ disableCustomGradients={ disableCustomGradients }
188
+ onColorChange={ handleOnChangeWithStyle(
189
+ setBorderColor
190
+ ) }
191
+ clearable={ false }
192
+ />
193
+ </ToolsPanelItem>
137
194
  ) }
138
- { hasBorderRadius && (
139
- <BorderRadiusControl
140
- values={ borderRadiusValues }
141
- onChange={ setBorderRadius }
142
- />
195
+ { showBorderRadius && (
196
+ <ToolsPanelItem
197
+ hasValue={ hasBorderRadius }
198
+ label={ __( 'Radius' ) }
199
+ onDeselect={ createResetCallback( setBorderRadius ) }
200
+ isShownByDefault={ true }
201
+ >
202
+ <BorderRadiusControl
203
+ values={ borderRadiusValues }
204
+ onChange={ handleOnChange( setBorderRadius ) }
205
+ />
206
+ </ToolsPanelItem>
143
207
  ) }
144
- </PanelBody>
208
+ </ToolsPanel>
145
209
  );
146
210
  }
@@ -12,7 +12,7 @@ import { useHasBorderPanel } from './border-panel';
12
12
  import { useHasColorPanel } from './color-utils';
13
13
  import { useHasDimensionsPanel } from './dimensions-panel';
14
14
  import { useHasTypographyPanel } from './typography-panel';
15
- import NavigationButton from './navigation-button';
15
+ import { NavigationButton } from './navigation-button';
16
16
 
17
17
  function ContextMenu( { name, parentMenu = '' } ) {
18
18
  const hasTypographyPanel = useHasTypographyPanel( name );
@@ -31,7 +31,7 @@ function mergeTreesCustomizer( _, srcValue ) {
31
31
  }
32
32
  }
33
33
 
34
- function mergeBaseAndUserConfigs( base, user ) {
34
+ export function mergeBaseAndUserConfigs( base, user ) {
35
35
  return mergeWith( {}, base, user, mergeTreesCustomizer );
36
36
  }
37
37
 
@@ -67,7 +67,6 @@ function useGlobalStylesUserConfig() {
67
67
 
68
68
  const { getEditedEntityRecord } = useSelect( coreStore );
69
69
  const { editEntityRecord } = useDispatch( coreStore );
70
-
71
70
  const config = useMemo( () => {
72
71
  return {
73
72
  settings: settings ?? {},
@@ -14,15 +14,14 @@ import { chevronRight, chevronLeft, Icon } from '@wordpress/icons';
14
14
  /**
15
15
  * Internal dependencies
16
16
  */
17
- import NavigationButton from './navigation-button';
17
+ import { NavigationBackButton } from './navigation-button';
18
18
 
19
- function ScreenHeader( { back, title, description } ) {
19
+ function ScreenHeader( { title, description } ) {
20
20
  return (
21
21
  <VStack spacing={ 2 }>
22
22
  <HStack spacing={ 2 }>
23
23
  <View>
24
- <NavigationButton
25
- path={ back }
24
+ <NavigationBackButton
26
25
  icon={
27
26
  <Icon
28
27
  icon={ isRTL() ? chevronRight : chevronLeft }
@@ -30,7 +29,6 @@ function ScreenHeader( { back, title, description } ) {
30
29
  />
31
30
  }
32
31
  size="small"
33
- isBack
34
32
  aria-label={ __( 'Navigate to the previous view' ) }
35
33
  />
36
34
  </View>
@@ -9,16 +9,9 @@ import {
9
9
  } from '@wordpress/components';
10
10
  import { Icon } from '@wordpress/icons';
11
11
 
12
- function NavigationButton( {
13
- path,
14
- icon,
15
- children,
16
- isBack = false,
17
- ...props
18
- } ) {
19
- const navigator = useNavigator();
12
+ function GenericNavigationButton( { icon, children, ...props } ) {
20
13
  return (
21
- <Item onClick={ () => navigator.push( path, { isBack } ) } { ...props }>
14
+ <Item { ...props }>
22
15
  { icon && (
23
16
  <HStack justify="flex-start">
24
17
  <FlexItem>
@@ -31,5 +24,16 @@ function NavigationButton( {
31
24
  </Item>
32
25
  );
33
26
  }
27
+ function NavigationButton( { path, ...props } ) {
28
+ const { push } = useNavigator();
29
+ return (
30
+ <GenericNavigationButton onClick={ () => push( path ) } { ...props } />
31
+ );
32
+ }
33
+
34
+ function NavigationBackButton( { ...props } ) {
35
+ const { pop } = useNavigator();
36
+ return <GenericNavigationButton onClick={ pop } { ...props } />;
37
+ }
34
38
 
35
- export default NavigationButton;
39
+ export { NavigationButton, NavigationBackButton };
@@ -17,7 +17,7 @@ import { useMemo } from '@wordpress/element';
17
17
  * Internal dependencies
18
18
  */
19
19
  import Subtitle from './subtitle';
20
- import NavigationButton from './navigation-button';
20
+ import { NavigationButton } from './navigation-button';
21
21
  import { useSetting } from './hooks';
22
22
 
23
23
  const EMPTY_COLORS = [];
@@ -2,41 +2,69 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import {
5
- __experimentalHStack as HStack,
6
- __experimentalVStack as VStack,
7
- Card,
8
- ColorIndicator,
9
- } from '@wordpress/components';
5
+ __unstableIframe as Iframe,
6
+ __unstableEditorStyles as EditorStyles,
7
+ } from '@wordpress/block-editor';
10
8
 
11
9
  /**
12
10
  * Internal dependencies
13
11
  */
14
12
  import { useStyle } from './hooks';
13
+ import { useGlobalStylesOutput } from './use-global-styles-output';
15
14
 
16
- const StylesPreview = () => {
15
+ const StylesPreview = ( { height = 150 } ) => {
17
16
  const [ fontFamily = 'serif' ] = useStyle( 'typography.fontFamily' );
18
17
  const [ textColor = 'black' ] = useStyle( 'color.text' );
19
18
  const [ linkColor = 'blue' ] = useStyle( 'elements.link.color.text' );
20
19
  const [ backgroundColor = 'white' ] = useStyle( 'color.background' );
21
20
  const [ gradientValue ] = useStyle( 'color.gradient' );
21
+ const [ styles ] = useGlobalStylesOutput();
22
22
 
23
23
  return (
24
- <Card
25
- className="edit-site-global-styles-preview"
26
- style={ { background: gradientValue ?? backgroundColor } }
24
+ <Iframe
25
+ className="edit-site-global-styles-preview__iframe"
26
+ head={ <EditorStyles styles={ styles } /> }
27
+ style={ { height } }
27
28
  >
28
- <HStack spacing={ 5 }>
29
+ <div
30
+ style={ {
31
+ display: 'flex',
32
+ gap: 20,
33
+ alignItems: 'center',
34
+ justifyContent: 'center',
35
+ height: '100%',
36
+ transform: `scale(${ height / 150 })`,
37
+ background: gradientValue ?? backgroundColor,
38
+ cursor: 'pointer',
39
+ } }
40
+ >
41
+ <div style={ { fontFamily, fontSize: '80px' } }>Aa</div>
29
42
  <div
30
- style={ { fontFamily, fontSize: '80px', color: textColor } }
43
+ style={ {
44
+ display: 'flex',
45
+ gap: 20,
46
+ flexDirection: 'column',
47
+ } }
31
48
  >
32
- Aa
49
+ <div
50
+ style={ {
51
+ height: 40,
52
+ width: 40,
53
+ background: textColor,
54
+ borderRadius: 20,
55
+ } }
56
+ />{ ' ' }
57
+ <div
58
+ style={ {
59
+ height: 40,
60
+ width: 40,
61
+ background: linkColor,
62
+ borderRadius: 20,
63
+ } }
64
+ />
33
65
  </div>
34
- <VStack spacing={ 2 }>
35
- <ColorIndicator colorValue={ textColor } />
36
- <ColorIndicator colorValue={ linkColor } />
37
- </VStack>
38
- </HStack>
39
- </Card>
66
+ </div>
67
+ </Iframe>
40
68
  );
41
69
  };
42
70
 
@@ -2,7 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
- import { __experimentalPanelColorGradientSettings as PanelColorGradientSettings } from '@wordpress/block-editor';
5
+ import { __experimentalColorGradientControl as ColorGradientControl } from '@wordpress/block-editor';
6
6
 
7
7
  /**
8
8
  * Internal dependencies
@@ -17,7 +17,6 @@ import {
17
17
  } from './hooks';
18
18
 
19
19
  function ScreenBackgroundColor( { name } ) {
20
- const parentMenu = name === undefined ? '' : '/blocks/' + name;
21
20
  const supports = getSupportedGlobalStylesPanels( name );
22
21
  const [ solids ] = useSetting( 'color.palette', name );
23
22
  const [ gradients ] = useSetting( 'color.gradients', name );
@@ -55,7 +54,6 @@ function ScreenBackgroundColor( { name } ) {
55
54
  return null;
56
55
  }
57
56
 
58
- const settings = [];
59
57
  let backgroundSettings = {};
60
58
  if ( hasBackgroundColor ) {
61
59
  backgroundSettings = {
@@ -79,25 +77,21 @@ function ScreenBackgroundColor( { name } ) {
79
77
  }
80
78
  }
81
79
 
82
- settings.push( {
80
+ const controlProps = {
83
81
  ...backgroundSettings,
84
82
  ...gradientSettings,
85
- label: __( 'Background color' ),
86
- } );
83
+ };
87
84
 
88
85
  return (
89
86
  <>
90
87
  <ScreenHeader
91
- back={ parentMenu + '/colors' }
92
88
  title={ __( 'Background' ) }
93
89
  description={ __(
94
- 'Set a background color or gradient for the whole website.'
90
+ 'Set a background color or gradient for the whole site.'
95
91
  ) }
96
92
  />
97
-
98
- <PanelColorGradientSettings
99
- title={ __( 'Color' ) }
100
- settings={ settings }
93
+ <ColorGradientControl
94
+ className="edit-site-screen-background-color__control"
101
95
  colors={ colorsPerOrigin }
102
96
  gradients={ gradientsPerOrigin }
103
97
  disableCustomColors={ ! areCustomSolidsEnabled }
@@ -106,6 +100,7 @@ function ScreenBackgroundColor( { name } ) {
106
100
  showTitle={ false }
107
101
  enableAlpha
108
102
  __experimentalIsRenderedInSidebar
103
+ { ...controlProps }
109
104
  />
110
105
  </>
111
106
  );
@@ -17,7 +17,7 @@ import { useHasColorPanel } from './color-utils';
17
17
  import { useHasDimensionsPanel } from './dimensions-panel';
18
18
  import { useHasTypographyPanel } from './typography-panel';
19
19
  import ScreenHeader from './header';
20
- import NavigationButton from './navigation-button';
20
+ import { NavigationButton } from './navigation-button';
21
21
 
22
22
  function BlockMenuItem( { block } ) {
23
23
  const hasTypographyPanel = useHasTypographyPanel( block.name );
@@ -48,7 +48,6 @@ function ScreenBlockList() {
48
48
  return (
49
49
  <>
50
50
  <ScreenHeader
51
- back="/"
52
51
  title={ __( 'Blocks' ) }
53
52
  description={ __(
54
53
  'Customize the appearance of specific blocks and for the whole site.'
@@ -14,7 +14,7 @@ function ScreenBlock( { name } ) {
14
14
 
15
15
  return (
16
16
  <>
17
- <ScreenHeader back="/blocks" title={ blockType.title } />
17
+ <ScreenHeader title={ blockType.title } />
18
18
  <ContextMenu parentMenu={ '/blocks/' + name } name={ name } />
19
19
  </>
20
20
  );
@@ -17,12 +17,10 @@ import ScreenHeader from './header';
17
17
 
18
18
  function ScreenColorPalette( { name } ) {
19
19
  const [ currentTab, setCurrentTab ] = useState( 'solid' );
20
- const parentMenu = name === undefined ? '' : '/blocks/' + name;
21
20
 
22
21
  return (
23
22
  <>
24
23
  <ScreenHeader
25
- back={ parentMenu + '/colors' }
26
24
  title={ __( 'Palette' ) }
27
25
  description={ __(
28
26
  'Palettes are used to provide default color options for blocks and various design tools. Here you can edit the colors with their labels.'
@@ -15,7 +15,7 @@ import {
15
15
  */
16
16
  import ScreenHeader from './header';
17
17
  import Palette from './palette';
18
- import NavigationButton from './navigation-button';
18
+ import { NavigationButton } from './navigation-button';
19
19
  import { getSupportedGlobalStylesPanels, useStyle } from './hooks';
20
20
  import Subtitle from './subtitle';
21
21
 
@@ -93,10 +93,9 @@ function ScreenColors( { name } ) {
93
93
  return (
94
94
  <>
95
95
  <ScreenHeader
96
- back={ parentMenu ? parentMenu : '/' }
97
96
  title={ __( 'Colors' ) }
98
97
  description={ __(
99
- 'Manage palettes and the default color of different global elements on the website.'
98
+ 'Manage palettes and the default color of different global elements on the site.'
100
99
  ) }
101
100
  />
102
101