Commit f5f73e4 1 parent 257a2e8 commit f5f73e4 Copy full SHA for f5f73e4
File tree 11 files changed +73
-59
lines changed
11 files changed +73
-59
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,9 @@ function DropdownMenu( dropdownMenuProps ) {
91
91
onToggle ( ) ;
92
92
}
93
93
} ;
94
+ const { as : Toggle = Button , ...restToggleProps } =
95
+ toggleProps ?? { } ;
96
+
94
97
const mergedToggleProps = mergeProps (
95
98
{
96
99
className : classnames (
@@ -100,11 +103,11 @@ function DropdownMenu( dropdownMenuProps ) {
100
103
}
101
104
) ,
102
105
} ,
103
- toggleProps
106
+ restToggleProps
104
107
) ;
105
108
106
109
return (
107
- < Button
110
+ < Toggle
108
111
{ ...mergedToggleProps }
109
112
icon = { icon }
110
113
onClick = { ( event ) => {
@@ -126,7 +129,7 @@ function DropdownMenu( dropdownMenuProps ) {
126
129
showTooltip = { toggleProps ?. showTooltip ?? true }
127
130
>
128
131
{ mergedToggleProps . children }
129
- </ Button >
132
+ </ Toggle >
130
133
) ;
131
134
} }
132
135
renderContent = { ( props ) => {
Original file line number Diff line number Diff line change @@ -86,19 +86,20 @@ export default function NewTemplatePart( {
86
86
setIsModalOpen ( false ) ;
87
87
}
88
88
}
89
+ const { as : Toggle = Button , ...restToggleProps } = toggleProps ?? { } ;
89
90
90
91
return (
91
92
< >
92
- < Button
93
- { ...toggleProps }
93
+ < Toggle
94
+ { ...restToggleProps }
94
95
onClick = { ( ) => {
95
96
setIsModalOpen ( true ) ;
96
97
} }
97
98
icon = { showIcon ? plus : null }
98
99
label = { postType . labels . add_new }
99
100
>
100
101
{ showIcon ? null : postType . labels . add_new }
101
- </ Button >
102
+ </ Toggle >
102
103
{ isModalOpen && (
103
104
< CreateTemplatePartModal
104
105
closeModal = { ( ) => setIsModalOpen ( false ) }
Original file line number Diff line number Diff line change
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import classnames from 'classnames' ;
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { Button } from '@wordpress/components' ;
10
+
11
+ export default function SidebarButton ( props ) {
12
+ return (
13
+ < Button
14
+ { ...props }
15
+ className = { classnames (
16
+ 'edit-site-sidebar-button' ,
17
+ props . className
18
+ ) }
19
+ />
20
+ ) ;
21
+ }
Original file line number Diff line number Diff line change
1
+ .edit-site-sidebar-button {
2
+ color : $gray-200 ;
3
+ flex-shrink : 0 ;
4
+
5
+ // Focus (resets default button focus and use focus-visible).
6
+ & :focus:not (:disabled ) {
7
+ box-shadow : none ;
8
+ outline : none ;
9
+ }
10
+ & :focus-visible:not (:disabled ) {
11
+ box-shadow :
12
+ 0 0 0 var (--wp-admin-border-width-focus )
13
+ var (--wp-components-color-accent , var (--wp-admin-theme-color , #007cba ));
14
+ outline : 3px solid transparent ;
15
+ }
16
+
17
+ & :hover ,
18
+ & :focus-visible ,
19
+ & :focus ,
20
+ & :not ([aria-disabled = " true" ]):active {
21
+ color : $white ;
22
+ }
23
+ }
Original file line number Diff line number Diff line change 3
3
*/
4
4
import { __ } from '@wordpress/i18n' ;
5
5
import { useDispatch , useSelect } from '@wordpress/data' ;
6
- import {
7
- Button ,
8
- __experimentalUseNavigator as useNavigator ,
9
- } from '@wordpress/components' ;
6
+ import { __experimentalUseNavigator as useNavigator } from '@wordpress/components' ;
10
7
import { store as coreStore } from '@wordpress/core-data' ;
11
8
import { decodeEntities } from '@wordpress/html-entities' ;
9
+ import { pencil } from '@wordpress/icons' ;
12
10
13
11
/**
14
12
* Internal dependencies
15
13
*/
16
14
import SidebarNavigationScreen from '../sidebar-navigation-screen' ;
17
15
import { unlock } from '../../private-apis' ;
18
16
import { store as editSiteStore } from '../../store' ;
17
+ import SidebarButton from '../sidebar-button' ;
19
18
20
19
export default function SidebarNavigationScreenNavigationItem ( ) {
21
20
const { setCanvasMode } = unlock ( useDispatch ( editSiteStore ) ) ;
@@ -43,13 +42,11 @@ export default function SidebarNavigationScreenNavigationItem() {
43
42
< SidebarNavigationScreen
44
43
title = { post ? decodeEntities ( post ?. title ?. rendered ) : null }
45
44
actions = {
46
- < Button
47
- variant = "primary"
48
- className = "edit-site-sidebar-navigation-screen__edit"
45
+ < SidebarButton
49
46
onClick = { ( ) => setCanvasMode ( 'edit' ) }
50
- >
51
- { __ ( 'Edit' ) }
52
- </ Button >
47
+ label = { __ ( 'Edit' ) }
48
+ icon = { pencil }
49
+ / >
53
50
}
54
51
content = {
55
52
post ? decodeEntities ( post ?. description ?. rendered ) : null
Original file line number Diff line number Diff line change 3
3
*/
4
4
import { __ } from '@wordpress/i18n' ;
5
5
import { useDispatch } from '@wordpress/data' ;
6
- import { Button } from '@wordpress/components ' ;
6
+ import { pencil } from '@wordpress/icons ' ;
7
7
8
8
/**
9
9
* Internal dependencies
@@ -12,6 +12,7 @@ import SidebarNavigationScreen from '../sidebar-navigation-screen';
12
12
import useEditedEntityRecord from '../use-edited-entity-record' ;
13
13
import { unlock } from '../../private-apis' ;
14
14
import { store as editSiteStore } from '../../store' ;
15
+ import SidebarButton from '../sidebar-button' ;
15
16
16
17
export default function SidebarNavigationScreenTemplate ( ) {
17
18
const { setCanvasMode } = unlock ( useDispatch ( editSiteStore ) ) ;
@@ -27,13 +28,11 @@ export default function SidebarNavigationScreenTemplate() {
27
28
< SidebarNavigationScreen
28
29
title = { getTitle ( ) }
29
30
actions = {
30
- < Button
31
- variant = "primary"
32
- className = "edit-site-sidebar-navigation-screen__edit"
31
+ < SidebarButton
33
32
onClick = { ( ) => setCanvasMode ( 'edit' ) }
34
- >
35
- { __ ( 'Edit' ) }
36
- </ Button >
33
+ label = { __ ( 'Edit' ) }
34
+ icon = { pencil }
35
+ / >
37
36
}
38
37
content = { description ? < p > { description } </ p > : undefined }
39
38
/>
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import { useLink } from '../routes/link';
20
20
import SidebarNavigationItem from '../sidebar-navigation-item' ;
21
21
import AddNewTemplate from '../add-new-template' ;
22
22
import { store as editSiteStore } from '../../store' ;
23
+ import SidebarButton from '../sidebar-button' ;
23
24
24
25
const config = {
25
26
wp_template : {
@@ -84,8 +85,7 @@ export default function SidebarNavigationScreenTemplates() {
84
85
< AddNewTemplate
85
86
templateType = { postType }
86
87
toggleProps = { {
87
- className :
88
- 'edit-site-sidebar-navigation-screen-templates__add-button' ,
88
+ as : SidebarButton ,
89
89
} }
90
90
/>
91
91
)
Original file line number Diff line number Diff line change 2
2
/* Overrides the margin that comes from the Item component */
3
3
margin-top : $grid-unit-20 !important ;
4
4
}
5
-
6
- .edit-site-sidebar-navigation-screen-templates__add-button {
7
- /* Overrides the color for all states of the button */
8
- color : inherit !important ;
9
- }
Original file line number Diff line number Diff line change 5
5
__experimentalHStack as HStack ,
6
6
__experimentalVStack as VStack ,
7
7
__experimentalNavigatorToParentButton as NavigatorToParentButton ,
8
- Button ,
9
8
} from '@wordpress/components' ;
10
9
import { isRTL , __ } from '@wordpress/i18n' ;
11
10
import { chevronRight , chevronLeft } from '@wordpress/icons' ;
@@ -16,6 +15,7 @@ import { useSelect } from '@wordpress/data';
16
15
*/
17
16
import { store as editSiteStore } from '../../store' ;
18
17
import { unlock } from '../../private-apis' ;
18
+ import SidebarButton from '../sidebar-button' ;
19
19
20
20
export default function SidebarNavigationScreen ( {
21
21
isRoot,
@@ -39,13 +39,12 @@ export default function SidebarNavigationScreen( {
39
39
>
40
40
{ ! isRoot ? (
41
41
< NavigatorToParentButton
42
- className = "edit-site-sidebar-navigation-screen__back"
42
+ as = { SidebarButton }
43
43
icon = { isRTL ( ) ? chevronRight : chevronLeft }
44
44
aria-label = { __ ( 'Back' ) }
45
45
/>
46
46
) : (
47
- < Button
48
- className = "edit-site-sidebar-navigation-screen__back"
47
+ < SidebarButton
49
48
icon = { isRTL ( ) ? chevronRight : chevronLeft }
50
49
aria-label = { __ ( 'Navigate to the Dashboard' ) }
51
50
href = { dashboardLink || 'index.php' }
Original file line number Diff line number Diff line change 29
29
color : $white ;
30
30
margin : 0 ;
31
31
}
32
-
33
- .edit-site-sidebar-navigation-screen__edit {
34
- flex-shrink : 0 ;
35
- }
36
-
37
- .edit-site-sidebar-navigation-screen__back {
38
- color : $gray-200 ;
39
-
40
- // Focus (resets default button focus and use focus-visible).
41
- & :focus:not (:disabled ) {
42
- box-shadow : none ;
43
- outline : none ;
44
- }
45
- & :focus-visible:not (:disabled ) {
46
- box-shadow : 0 0 0 var (--wp-admin-border-width-focus ) var (--wp-components-color-accent , var (--wp-admin-theme-color , #007cba ));
47
- outline : 3px solid transparent ;
48
- }
49
-
50
- & :hover ,
51
- & :focus-visible ,
52
- & :focus ,
53
- & :not ([aria-disabled = " true" ]):active {
54
- color : $white ;
55
- }
56
- }
Original file line number Diff line number Diff line change 22
22
@import " ./components/layout/style.scss" ;
23
23
@import " ./components/save-panel/style.scss" ;
24
24
@import " ./components/sidebar/style.scss" ;
25
+ @import " ./components/sidebar-button/style.scss" ;
25
26
@import " ./components/sidebar-navigation-item/style.scss" ;
26
27
@import " ./components/sidebar-navigation-screen/style.scss" ;
27
28
@import " ./components/sidebar-navigation-screen-templates/style.scss" ;
You can’t perform that action at this time.
0 commit comments