-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
index.js
114 lines (109 loc) · 2.88 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/**
* WordPress dependencies
*/
import { __experimentalItemGroup as ItemGroup } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { layout, symbol, navigation, styles, page } from '@wordpress/icons';
import { useDispatch, useSelect } from '@wordpress/data';
import { useEffect } from '@wordpress/element';
import { store as coreStore } from '@wordpress/core-data';
/**
* Internal dependencies
*/
import SidebarNavigationScreen from '../sidebar-navigation-screen';
import SidebarNavigationItem from '../sidebar-navigation-item';
import { SidebarNavigationItemGlobalStyles } from '../sidebar-navigation-screen-global-styles';
import { unlock } from '../../lock-unlock';
import { store as editSiteStore } from '../../store';
export function MainSidebarNavigationContent( { isBlockBasedTheme = true } ) {
return (
<ItemGroup>
{ isBlockBasedTheme && (
<>
<SidebarNavigationItem
uid="navigation-navigation-item"
to="/navigation"
withChevron
icon={ navigation }
>
{ __( 'Navigation' ) }
</SidebarNavigationItem>
<SidebarNavigationItemGlobalStyles
to="/styles"
uid="global-styles-navigation-item"
icon={ styles }
>
{ __( 'Styles' ) }
</SidebarNavigationItemGlobalStyles>
<SidebarNavigationItem
uid="page-navigation-item"
to="/page"
withChevron
icon={ page }
>
{ __( 'Pages' ) }
</SidebarNavigationItem>
<SidebarNavigationItem
uid="template-navigation-item"
to="/template"
withChevron
icon={ layout }
>
{ __( 'Templates' ) }
</SidebarNavigationItem>
</>
) }
{ ! isBlockBasedTheme && (
<SidebarNavigationItem
uid="stylebook-navigation-item"
to="/stylebook"
withChevron
icon={ styles }
>
{ __( 'Styles' ) }
</SidebarNavigationItem>
) }
<SidebarNavigationItem
uid="patterns-navigation-item"
to="/pattern"
withChevron
icon={ symbol }
>
{ __( 'Patterns' ) }
</SidebarNavigationItem>
</ItemGroup>
);
}
export default function SidebarNavigationScreenMain() {
const isBlockBasedTheme = useSelect(
( select ) => select( coreStore ).getCurrentTheme()?.is_block_theme,
[]
);
const { setEditorCanvasContainerView } = unlock(
useDispatch( editSiteStore )
);
// Clear the editor canvas container view when accessing the main navigation screen.
useEffect( () => {
setEditorCanvasContainerView( undefined );
}, [ setEditorCanvasContainerView ] );
return (
<SidebarNavigationScreen
isRoot
title={ __( 'Design' ) }
description={
isBlockBasedTheme
? __(
'Customize the appearance of your website using the block editor.'
)
: __(
'Explore block styles and patterns to refine your site'
)
}
content={
<MainSidebarNavigationContent
isBlockBasedTheme={ isBlockBasedTheme }
/>
}
/>
);
}