@wordpress/edit-site 5.12.6 → 5.12.8

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 (209) hide show
  1. package/build/components/block-editor/editor-canvas.js +1 -1
  2. package/build/components/block-editor/editor-canvas.js.map +1 -1
  3. package/build/components/block-editor/use-site-editor-settings.js +10 -5
  4. package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
  5. package/build/components/create-pattern-modal/index.js +8 -4
  6. package/build/components/create-pattern-modal/index.js.map +1 -1
  7. package/build/components/global-styles/palette.js +1 -1
  8. package/build/components/global-styles/palette.js.map +1 -1
  9. package/build/components/header-edit-mode/index.js +6 -2
  10. package/build/components/header-edit-mode/index.js.map +1 -1
  11. package/build/components/layout/index.js +1 -1
  12. package/build/components/layout/index.js.map +1 -1
  13. package/build/components/page/header.js +1 -1
  14. package/build/components/page/header.js.map +1 -1
  15. package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js +5 -5
  16. package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
  17. package/build/components/page-patterns/duplicate-menu-item.js +163 -0
  18. package/build/components/page-patterns/duplicate-menu-item.js.map +1 -0
  19. package/build/components/page-patterns/grid-item.js +84 -60
  20. package/build/components/page-patterns/grid-item.js.map +1 -1
  21. package/build/components/page-patterns/grid.js +21 -13
  22. package/build/components/page-patterns/grid.js.map +1 -1
  23. package/build/components/page-patterns/header.js +69 -0
  24. package/build/components/page-patterns/header.js.map +1 -0
  25. package/build/components/page-patterns/index.js +3 -1
  26. package/build/components/page-patterns/index.js.map +1 -1
  27. package/build/components/page-patterns/patterns-list.js +67 -27
  28. package/build/components/page-patterns/patterns-list.js.map +1 -1
  29. package/build/components/page-patterns/rename-menu-item.js +109 -0
  30. package/build/components/page-patterns/rename-menu-item.js.map +1 -0
  31. package/build/components/page-patterns/use-patterns.js +99 -126
  32. package/build/components/page-patterns/use-patterns.js.map +1 -1
  33. package/build/components/page-template-parts/index.js +1 -0
  34. package/build/components/page-template-parts/index.js.map +1 -1
  35. package/build/components/page-templates/index.js +1 -0
  36. package/build/components/page-templates/index.js.map +1 -1
  37. package/build/components/sidebar-edit-mode/page-panels/page-content.js +4 -3
  38. package/build/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
  39. package/build/components/sidebar-navigation-screen/index.js +1 -1
  40. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  41. package/build/components/sidebar-navigation-screen-global-styles/index.js +57 -17
  42. package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  43. package/build/components/sidebar-navigation-screen-main/index.js +4 -2
  44. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  45. package/build/components/sidebar-navigation-screen-main/template-part-hint.js +45 -0
  46. package/build/components/sidebar-navigation-screen-main/template-part-hint.js.map +1 -0
  47. package/build/components/sidebar-navigation-screen-navigation-menu/edit-button.js +10 -11
  48. package/build/components/sidebar-navigation-screen-navigation-menu/edit-button.js.map +1 -1
  49. package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +6 -2
  50. package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
  51. package/build/components/sidebar-navigation-screen-page/status-label.js +2 -35
  52. package/build/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
  53. package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js +3 -3
  54. package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
  55. package/build/components/sidebar-navigation-screen-patterns/index.js +68 -43
  56. package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  57. package/build/components/sidebar-navigation-screen-patterns/use-my-patterns.js +9 -5
  58. package/build/components/sidebar-navigation-screen-patterns/use-my-patterns.js.map +1 -1
  59. package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +20 -9
  60. package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
  61. package/build/components/site-hub/index.js +2 -2
  62. package/build/components/site-hub/index.js.map +1 -1
  63. package/build/components/template-actions/index.js +25 -7
  64. package/build/components/template-actions/index.js.map +1 -1
  65. package/build/components/template-actions/rename-menu-item.js +9 -6
  66. package/build/components/template-actions/rename-menu-item.js.map +1 -1
  67. package/build/components/welcome-guide/page.js +2 -2
  68. package/build/components/welcome-guide/page.js.map +1 -1
  69. package/build/components/welcome-guide/template.js +2 -2
  70. package/build/components/welcome-guide/template.js.map +1 -1
  71. package/build/hooks/commands/use-edit-mode-commands.js +1 -2
  72. package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
  73. package/build/hooks/push-changes-to-global-styles/index.js +3 -1
  74. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  75. package/build/store/private-actions.js +7 -1
  76. package/build/store/private-actions.js.map +1 -1
  77. package/build/utils/use-activate-theme.js +1 -1
  78. package/build/utils/use-activate-theme.js.map +1 -1
  79. package/build-module/components/block-editor/editor-canvas.js +1 -1
  80. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  81. package/build-module/components/block-editor/use-site-editor-settings.js +10 -5
  82. package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
  83. package/build-module/components/create-pattern-modal/index.js +7 -4
  84. package/build-module/components/create-pattern-modal/index.js.map +1 -1
  85. package/build-module/components/global-styles/palette.js +1 -1
  86. package/build-module/components/global-styles/palette.js.map +1 -1
  87. package/build-module/components/header-edit-mode/index.js +6 -2
  88. package/build-module/components/header-edit-mode/index.js.map +1 -1
  89. package/build-module/components/layout/index.js +1 -1
  90. package/build-module/components/layout/index.js.map +1 -1
  91. package/build-module/components/page/header.js +1 -1
  92. package/build-module/components/page/header.js.map +1 -1
  93. package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js +5 -3
  94. package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
  95. package/build-module/components/page-patterns/duplicate-menu-item.js +147 -0
  96. package/build-module/components/page-patterns/duplicate-menu-item.js.map +1 -0
  97. package/build-module/components/page-patterns/grid-item.js +85 -66
  98. package/build-module/components/page-patterns/grid-item.js.map +1 -1
  99. package/build-module/components/page-patterns/grid.js +22 -15
  100. package/build-module/components/page-patterns/grid.js.map +1 -1
  101. package/build-module/components/page-patterns/header.js +54 -0
  102. package/build-module/components/page-patterns/header.js.map +1 -0
  103. package/build-module/components/page-patterns/index.js +3 -1
  104. package/build-module/components/page-patterns/index.js.map +1 -1
  105. package/build-module/components/page-patterns/patterns-list.js +70 -31
  106. package/build-module/components/page-patterns/patterns-list.js.map +1 -1
  107. package/build-module/components/page-patterns/rename-menu-item.js +97 -0
  108. package/build-module/components/page-patterns/rename-menu-item.js.map +1 -0
  109. package/build-module/components/page-patterns/use-patterns.js +100 -127
  110. package/build-module/components/page-patterns/use-patterns.js.map +1 -1
  111. package/build-module/components/page-template-parts/index.js +1 -0
  112. package/build-module/components/page-template-parts/index.js.map +1 -1
  113. package/build-module/components/page-templates/index.js +1 -0
  114. package/build-module/components/page-templates/index.js.map +1 -1
  115. package/build-module/components/sidebar-edit-mode/page-panels/page-content.js +5 -2
  116. package/build-module/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
  117. package/build-module/components/sidebar-navigation-screen/index.js +1 -1
  118. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  119. package/build-module/components/sidebar-navigation-screen-global-styles/index.js +57 -17
  120. package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  121. package/build-module/components/sidebar-navigation-screen-main/index.js +4 -3
  122. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  123. package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js +33 -0
  124. package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js.map +1 -0
  125. package/build-module/components/sidebar-navigation-screen-navigation-menu/edit-button.js +10 -9
  126. package/build-module/components/sidebar-navigation-screen-navigation-menu/edit-button.js.map +1 -1
  127. package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +6 -3
  128. package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
  129. package/build-module/components/sidebar-navigation-screen-page/status-label.js +2 -33
  130. package/build-module/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
  131. package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js +3 -3
  132. package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
  133. package/build-module/components/sidebar-navigation-screen-patterns/index.js +71 -44
  134. package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  135. package/build-module/components/sidebar-navigation-screen-patterns/use-my-patterns.js +9 -5
  136. package/build-module/components/sidebar-navigation-screen-patterns/use-my-patterns.js.map +1 -1
  137. package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +18 -9
  138. package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
  139. package/build-module/components/site-hub/index.js +2 -2
  140. package/build-module/components/site-hub/index.js.map +1 -1
  141. package/build-module/components/template-actions/index.js +26 -8
  142. package/build-module/components/template-actions/index.js.map +1 -1
  143. package/build-module/components/template-actions/rename-menu-item.js +8 -6
  144. package/build-module/components/template-actions/rename-menu-item.js.map +1 -1
  145. package/build-module/components/welcome-guide/page.js +2 -2
  146. package/build-module/components/welcome-guide/page.js.map +1 -1
  147. package/build-module/components/welcome-guide/template.js +2 -2
  148. package/build-module/components/welcome-guide/template.js.map +1 -1
  149. package/build-module/hooks/commands/use-edit-mode-commands.js +1 -2
  150. package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
  151. package/build-module/hooks/push-changes-to-global-styles/index.js +4 -2
  152. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  153. package/build-module/store/private-actions.js +7 -1
  154. package/build-module/store/private-actions.js.map +1 -1
  155. package/build-module/utils/use-activate-theme.js +1 -1
  156. package/build-module/utils/use-activate-theme.js.map +1 -1
  157. package/build-style/style-rtl.css +149 -50
  158. package/build-style/style.css +149 -50
  159. package/package.json +19 -19
  160. package/src/components/block-editor/editor-canvas.js +1 -1
  161. package/src/components/block-editor/use-site-editor-settings.js +8 -4
  162. package/src/components/create-pattern-modal/index.js +6 -3
  163. package/src/components/global-styles/palette.js +10 -9
  164. package/src/components/header-edit-mode/document-actions/style.scss +12 -0
  165. package/src/components/header-edit-mode/index.js +17 -9
  166. package/src/components/layout/index.js +1 -1
  167. package/src/components/layout/style.scss +0 -11
  168. package/src/components/page/header.js +1 -1
  169. package/src/components/page-content-focus-manager/disable-non-page-content-blocks.js +12 -3
  170. package/src/components/page-patterns/duplicate-menu-item.js +196 -0
  171. package/src/components/page-patterns/grid-item.js +187 -132
  172. package/src/components/page-patterns/grid.js +35 -22
  173. package/src/components/page-patterns/header.js +69 -0
  174. package/src/components/page-patterns/index.js +6 -1
  175. package/src/components/page-patterns/patterns-list.js +89 -47
  176. package/src/components/page-patterns/rename-menu-item.js +115 -0
  177. package/src/components/page-patterns/style.scss +86 -26
  178. package/src/components/page-patterns/use-patterns.js +99 -176
  179. package/src/components/page-template-parts/index.js +1 -1
  180. package/src/components/page-templates/index.js +1 -1
  181. package/src/components/sidebar-edit-mode/page-panels/page-content.js +7 -5
  182. package/src/components/sidebar-navigation-screen/index.js +1 -1
  183. package/src/components/sidebar-navigation-screen/style.scss +19 -1
  184. package/src/components/sidebar-navigation-screen-global-styles/index.js +56 -39
  185. package/src/components/sidebar-navigation-screen-main/index.js +44 -40
  186. package/src/components/sidebar-navigation-screen-main/template-part-hint.js +36 -0
  187. package/src/components/sidebar-navigation-screen-navigation-menu/edit-button.js +8 -11
  188. package/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +10 -6
  189. package/src/components/sidebar-navigation-screen-page/status-label.js +2 -36
  190. package/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js +3 -3
  191. package/src/components/sidebar-navigation-screen-patterns/index.js +79 -75
  192. package/src/components/sidebar-navigation-screen-patterns/style.scss +23 -1
  193. package/src/components/sidebar-navigation-screen-patterns/use-my-patterns.js +7 -6
  194. package/src/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +31 -9
  195. package/src/components/site-hub/index.js +2 -2
  196. package/src/components/template-actions/index.js +40 -9
  197. package/src/components/template-actions/rename-menu-item.js +8 -6
  198. package/src/components/welcome-guide/page.js +2 -2
  199. package/src/components/welcome-guide/template.js +2 -2
  200. package/src/hooks/commands/use-edit-mode-commands.js +0 -1
  201. package/src/hooks/push-changes-to-global-styles/index.js +8 -1
  202. package/src/store/private-actions.js +5 -1
  203. package/src/style.scss +10 -12
  204. package/src/utils/use-activate-theme.js +1 -1
  205. package/build/components/page-content-focus-manager/constants.js +0 -9
  206. package/build/components/page-content-focus-manager/constants.js.map +0 -1
  207. package/build-module/components/page-content-focus-manager/constants.js +0 -2
  208. package/build-module/components/page-content-focus-manager/constants.js.map +0 -1
  209. package/src/components/page-content-focus-manager/constants.js +0 -5
@@ -1,51 +1,87 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
-
4
+ import { useState, useDeferredValue, useId } from '@wordpress/element';
5
5
  import {
6
6
  SearchControl,
7
- __experimentalHeading as Heading,
8
- __experimentalText as Text,
9
7
  __experimentalVStack as VStack,
10
8
  Flex,
11
9
  FlexBlock,
10
+ __experimentalToggleGroupControl as ToggleGroupControl,
11
+ __experimentalToggleGroupControlOption as ToggleGroupControlOption,
12
+ __experimentalHeading as Heading,
13
+ __experimentalText as Text,
12
14
  } from '@wordpress/components';
13
15
  import { __, isRTL } from '@wordpress/i18n';
14
- import { symbol, chevronLeft, chevronRight } from '@wordpress/icons';
16
+ import { chevronLeft, chevronRight } from '@wordpress/icons';
15
17
  import { privateApis as routerPrivateApis } from '@wordpress/router';
16
- import { useViewportMatch } from '@wordpress/compose';
18
+ import { useViewportMatch, useAsyncList } from '@wordpress/compose';
17
19
 
18
20
  /**
19
21
  * Internal dependencies
20
22
  */
23
+ import PatternsHeader from './header';
21
24
  import Grid from './grid';
22
25
  import NoPatterns from './no-patterns';
23
26
  import usePatterns from './use-patterns';
24
27
  import SidebarButton from '../sidebar-button';
25
28
  import useDebouncedInput from '../../utils/use-debounced-input';
26
29
  import { unlock } from '../../lock-unlock';
30
+ import { SYNC_TYPES, USER_PATTERN_CATEGORY } from './utils';
27
31
 
28
32
  const { useLocation, useHistory } = unlock( routerPrivateApis );
29
33
 
34
+ const SYNC_FILTERS = {
35
+ all: __( 'All' ),
36
+ [ SYNC_TYPES.full ]: __( 'Synced' ),
37
+ [ SYNC_TYPES.unsynced ]: __( 'Standard' ),
38
+ };
39
+
40
+ const SYNC_DESCRIPTIONS = {
41
+ all: '',
42
+ [ SYNC_TYPES.full ]: __(
43
+ 'Patterns that are kept in sync across the site.'
44
+ ),
45
+ [ SYNC_TYPES.unsynced ]: __(
46
+ 'Patterns that can be changed freely without affecting the site.'
47
+ ),
48
+ };
49
+
30
50
  export default function PatternsList( { categoryId, type } ) {
31
51
  const location = useLocation();
32
52
  const history = useHistory();
33
53
  const isMobileViewport = useViewportMatch( 'medium', '<' );
34
54
  const [ filterValue, setFilterValue, delayedFilterValue ] =
35
55
  useDebouncedInput( '' );
56
+ const deferredFilterValue = useDeferredValue( delayedFilterValue );
36
57
 
37
- const [ patterns, isResolving ] = usePatterns(
38
- type,
39
- categoryId,
40
- delayedFilterValue
41
- );
58
+ const [ syncFilter, setSyncFilter ] = useState( 'all' );
59
+ const deferredSyncedFilter = useDeferredValue( syncFilter );
60
+ const { patterns, isResolving } = usePatterns( type, categoryId, {
61
+ search: deferredFilterValue,
62
+ syncStatus:
63
+ deferredSyncedFilter === 'all' ? undefined : deferredSyncedFilter,
64
+ } );
42
65
 
43
- const { syncedPatterns, unsyncedPatterns } = patterns;
44
- const hasPatterns = !! syncedPatterns.length || !! unsyncedPatterns.length;
66
+ const id = useId();
67
+ const titleId = `${ id }-title`;
68
+ const descriptionId = `${ id }-description`;
69
+
70
+ const hasPatterns = patterns.length;
71
+ const title = SYNC_FILTERS[ syncFilter ];
72
+ const description = SYNC_DESCRIPTIONS[ syncFilter ];
73
+ const shownPatterns = useAsyncList( patterns );
45
74
 
46
75
  return (
47
76
  <VStack spacing={ 6 }>
48
- <Flex>
77
+ <PatternsHeader
78
+ categoryId={ categoryId }
79
+ type={ type }
80
+ titleId={ titleId }
81
+ descriptionId={ descriptionId }
82
+ />
83
+
84
+ <Flex alignment="stretch" wrap>
49
85
  { isMobileViewport && (
50
86
  <SidebarButton
51
87
  icon={ isRTL() ? chevronRight : chevronLeft }
@@ -61,7 +97,7 @@ export default function PatternsList( { categoryId, type } ) {
61
97
  } }
62
98
  />
63
99
  ) }
64
- <FlexBlock>
100
+ <FlexBlock className="edit-site-patterns__search-block">
65
101
  <SearchControl
66
102
  className="edit-site-patterns__search"
67
103
  onChange={ ( value ) => setFilterValue( value ) }
@@ -71,42 +107,48 @@ export default function PatternsList( { categoryId, type } ) {
71
107
  __nextHasNoMarginBottom
72
108
  />
73
109
  </FlexBlock>
110
+ { categoryId === USER_PATTERN_CATEGORY && (
111
+ <ToggleGroupControl
112
+ className="edit-site-patterns__sync-status-filter"
113
+ hideLabelFromVision
114
+ label={ __( 'Filter by sync status' ) }
115
+ value={ syncFilter }
116
+ isBlock
117
+ onChange={ ( value ) => setSyncFilter( value ) }
118
+ __nextHasNoMarginBottom
119
+ >
120
+ { Object.entries( SYNC_FILTERS ).map(
121
+ ( [ key, label ] ) => (
122
+ <ToggleGroupControlOption
123
+ className="edit-site-patterns__sync-status-filter-option"
124
+ key={ key }
125
+ value={ key }
126
+ label={ label }
127
+ />
128
+ )
129
+ ) }
130
+ </ToggleGroupControl>
131
+ ) }
74
132
  </Flex>
75
- { isResolving && __( 'Loading' ) }
76
- { ! isResolving && !! syncedPatterns.length && (
77
- <>
78
- <VStack className="edit-site-patterns__section-header">
79
- <Heading level={ 4 }>{ __( 'Synced' ) }</Heading>
80
- <Text variant="muted" as="p">
81
- { __(
82
- 'Patterns that are kept in sync across your site'
83
- ) }
133
+ { syncFilter !== 'all' && (
134
+ <VStack className="edit-site-patterns__section-header">
135
+ <Heading as="h3" level={ 4 } id={ titleId }>
136
+ { title }
137
+ </Heading>
138
+ { description ? (
139
+ <Text variant="muted" as="p" id={ descriptionId }>
140
+ { description }
84
141
  </Text>
85
- </VStack>
86
- <Grid
87
- icon={ symbol }
88
- categoryId={ categoryId }
89
- label={ __( 'Synced patterns' ) }
90
- items={ syncedPatterns }
91
- />
92
- </>
142
+ ) : null }
143
+ </VStack>
93
144
  ) }
94
- { ! isResolving && !! unsyncedPatterns.length && (
95
- <>
96
- <VStack className="edit-site-patterns__section-header">
97
- <Heading level={ 4 }>{ __( 'Standard' ) }</Heading>
98
- <Text variant="muted" as="p">
99
- { __(
100
- 'Patterns that can be changed freely without affecting your site'
101
- ) }
102
- </Text>
103
- </VStack>
104
- <Grid
105
- categoryId={ categoryId }
106
- label={ __( 'Standard patterns' ) }
107
- items={ unsyncedPatterns }
108
- />
109
- </>
145
+ { hasPatterns && (
146
+ <Grid
147
+ categoryId={ categoryId }
148
+ items={ shownPatterns }
149
+ aria-labelledby={ titleId }
150
+ aria-describedby={ descriptionId }
151
+ />
110
152
  ) }
111
153
  { ! isResolving && ! hasPatterns && <NoPatterns /> }
112
154
  </VStack>
@@ -0,0 +1,115 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ Button,
6
+ MenuItem,
7
+ Modal,
8
+ TextControl,
9
+ __experimentalHStack as HStack,
10
+ __experimentalVStack as VStack,
11
+ } from '@wordpress/components';
12
+ import { store as coreStore } from '@wordpress/core-data';
13
+ import { useDispatch } from '@wordpress/data';
14
+ import { useState } from '@wordpress/element';
15
+ import { __ } from '@wordpress/i18n';
16
+ import { store as noticesStore } from '@wordpress/notices';
17
+
18
+ /**
19
+ * Internal dependencies
20
+ */
21
+ import { TEMPLATE_PARTS } from './utils';
22
+
23
+ export default function RenameMenuItem( { item, onClose } ) {
24
+ const [ title, setTitle ] = useState( () => item.title );
25
+ const [ isModalOpen, setIsModalOpen ] = useState( false );
26
+
27
+ const { editEntityRecord, saveEditedEntityRecord } =
28
+ useDispatch( coreStore );
29
+ const { createSuccessNotice, createErrorNotice } =
30
+ useDispatch( noticesStore );
31
+
32
+ if ( item.type === TEMPLATE_PARTS && ! item.isCustom ) {
33
+ return null;
34
+ }
35
+
36
+ async function onRename( event ) {
37
+ event.preventDefault();
38
+
39
+ try {
40
+ await editEntityRecord( 'postType', item.type, item.id, { title } );
41
+
42
+ // Update state before saving rerenders the list.
43
+ setTitle( '' );
44
+ setIsModalOpen( false );
45
+ onClose();
46
+
47
+ // Persist edited entity.
48
+ await saveEditedEntityRecord( 'postType', item.type, item.id, {
49
+ throwOnError: true,
50
+ } );
51
+
52
+ createSuccessNotice( __( 'Entity renamed.' ), {
53
+ type: 'snackbar',
54
+ } );
55
+ } catch ( error ) {
56
+ const errorMessage =
57
+ error.message && error.code !== 'unknown_error'
58
+ ? error.message
59
+ : __( 'An error occurred while renaming the entity.' );
60
+
61
+ createErrorNotice( errorMessage, { type: 'snackbar' } );
62
+ }
63
+ }
64
+
65
+ return (
66
+ <>
67
+ <MenuItem
68
+ onClick={ () => {
69
+ setIsModalOpen( true );
70
+ setTitle( item.title );
71
+ } }
72
+ >
73
+ { __( 'Rename' ) }
74
+ </MenuItem>
75
+ { isModalOpen && (
76
+ <Modal
77
+ title={ __( 'Rename' ) }
78
+ onRequestClose={ () => {
79
+ setIsModalOpen( false );
80
+ onClose();
81
+ } }
82
+ overlayClassName="edit-site-list__rename_modal"
83
+ >
84
+ <form onSubmit={ onRename }>
85
+ <VStack spacing="5">
86
+ <TextControl
87
+ __nextHasNoMarginBottom
88
+ label={ __( 'Name' ) }
89
+ value={ title }
90
+ onChange={ setTitle }
91
+ required
92
+ />
93
+
94
+ <HStack justify="right">
95
+ <Button
96
+ variant="tertiary"
97
+ onClick={ () => {
98
+ setIsModalOpen( false );
99
+ onClose();
100
+ } }
101
+ >
102
+ { __( 'Cancel' ) }
103
+ </Button>
104
+
105
+ <Button variant="primary" type="submit">
106
+ { __( 'Save' ) }
107
+ </Button>
108
+ </HStack>
109
+ </VStack>
110
+ </form>
111
+ </Modal>
112
+ ) }
113
+ </>
114
+ );
115
+ }
@@ -1,6 +1,13 @@
1
1
  .edit-site-patterns {
2
- background: rgba(0, 0, 0, 0.05);
2
+ background: rgba(0, 0, 0, 0.15);
3
3
  margin: $header-height 0 0;
4
+ .components-base-control {
5
+ width: 100%;
6
+ @include break-medium {
7
+ width: auto;
8
+ }
9
+ }
10
+
4
11
  .components-text {
5
12
  color: $gray-600;
6
13
  }
@@ -12,33 +19,81 @@
12
19
  @include break-medium {
13
20
  margin: 0;
14
21
  }
22
+
23
+ .edit-site-patterns__search-block {
24
+ min-width: fit-content;
25
+ flex-grow: 1;
26
+ }
27
+
28
+ // The increased specificity here is to overcome component styles
29
+ // without relying on internal component class names.
30
+ .edit-site-patterns__search {
31
+ input[type="search"] {
32
+ height: $button-size-next-default-40px;
33
+ background: $gray-800;
34
+ color: $gray-200;
35
+
36
+ &:focus {
37
+ background: $gray-800;
38
+ }
39
+ }
40
+
41
+ svg {
42
+ fill: $gray-600;
43
+ }
44
+ }
45
+
46
+ .edit-site-patterns__sync-status-filter {
47
+ background: $gray-800;
48
+ border: none;
49
+ height: $button-size-next-default-40px;
50
+ min-width: max-content;
51
+ width: 100%;
52
+ max-width: 100%;
53
+
54
+ @include break-medium {
55
+ width: 300px;
56
+ }
57
+ }
58
+ .edit-site-patterns__sync-status-filter-option:active {
59
+ background: $gray-700;
60
+ color: $gray-100;
61
+ }
15
62
  }
16
63
 
17
- .edit-site-patterns__grid {
18
- column-gap: $grid-unit-30;
19
- @include break-large() {
20
- column-count: 2;
64
+ .edit-site-patterns__section-header {
65
+ .screen-reader-shortcut:focus {
66
+ top: 0;
21
67
  }
68
+ }
22
69
 
70
+ .edit-site-patterns__grid {
71
+ display: grid;
72
+ grid-template-columns: 1fr;
73
+ gap: $grid-unit-40;
23
74
  // Small top padding required to avoid cutting off the visible outline
24
75
  // when hovering items.
25
76
  padding-top: $border-width-focus-fallback;
26
77
  margin-bottom: $grid-unit-40;
27
-
78
+ @include break-large {
79
+ grid-template-columns: 1fr 1fr;
80
+ }
28
81
  .edit-site-patterns__pattern {
29
82
  break-inside: avoid-column;
30
83
  display: flex;
31
84
  flex-direction: column;
32
- margin-bottom: $grid-unit-60;
33
-
34
85
  .edit-site-patterns__preview {
35
- border-radius: $radius-block-ui;
86
+ box-shadow: none;
87
+ border: none;
88
+ padding: 0;
89
+ background-color: unset;
90
+ box-sizing: border-box;
91
+ border-radius: 4px;
36
92
  cursor: pointer;
37
93
  overflow: hidden;
38
94
 
39
95
  &:focus {
40
- box-shadow: inset 0 0 0 2px $white, 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
41
-
96
+ box-shadow: inset 0 0 0 0 $white, 0 0 0 2px var(--wp-admin-theme-color);
42
97
  // Windows High Contrast mode will show this outline, but not the box-shadow.
43
98
  outline: 2px solid transparent;
44
99
  }
@@ -46,6 +101,10 @@
46
101
  &.is-inactive {
47
102
  cursor: default;
48
103
  }
104
+ &.is-inactive:focus {
105
+ box-shadow: 0 0 0 var(--wp-admin-border-width-focus) $gray-800;
106
+ opacity: 0.8;
107
+ }
49
108
  }
50
109
 
51
110
  .edit-site-patterns__footer,
@@ -68,31 +127,28 @@
68
127
  }
69
128
 
70
129
  .edit-site-patterns__preview {
71
- flex: 1;
130
+ flex: 0 1 auto;
72
131
  margin-bottom: $grid-unit-20;
73
132
  }
74
133
  }
75
134
 
76
- // The increased specificity here is to overcome component styles
77
- // without relying on internal component class names.
78
- .edit-site-patterns__search {
79
- &#{&} input[type="search"] {
80
- background: $gray-800;
135
+ .edit-site-patterns__load-more {
136
+ align-self: center;
137
+ }
138
+
139
+ .edit-site-patterns__pattern-title {
140
+ color: $gray-200;
141
+
142
+ .is-link {
143
+ text-decoration: none;
81
144
  color: $gray-200;
82
145
 
146
+ &:hover,
83
147
  &:focus {
84
- background: $gray-800;
148
+ color: $white;
85
149
  }
86
150
  }
87
151
 
88
- svg {
89
- fill: $gray-600;
90
- }
91
- }
92
-
93
- .edit-site-patterns__pattern-title {
94
- color: $gray-600;
95
-
96
152
  .edit-site-patterns__pattern-icon {
97
153
  border-radius: $grid-unit-05;
98
154
  background: var(--wp-block-synced-color);
@@ -101,6 +157,10 @@
101
157
 
102
158
  .edit-site-patterns__pattern-lock-icon {
103
159
  display: inline-flex;
160
+
161
+ svg {
162
+ fill: currentcolor;
163
+ }
104
164
  }
105
165
  }
106
166