Skip to content

Commit

Permalink
Navigator: use stable export instead of experimental export
Browse files Browse the repository at this point in the history
  • Loading branch information
ciampo committed Sep 30, 2024
1 parent b7bf133 commit dfbc26b
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import {
__experimentalSpacer as Spacer,
__experimentalHeading as Heading,
__experimentalView as View,
__experimentalNavigatorProvider as NavigatorProvider,
__experimentalNavigatorScreen as NavigatorScreen,
__experimentalNavigatorButton as NavigatorButton,
__experimentalNavigatorBackButton as NavigatorBackButton,
Navigator,
FlexBlock,
} from '@wordpress/components';
import { Icon, chevronRight, chevronLeft } from '@wordpress/icons';
Expand All @@ -24,7 +21,7 @@ function ScreenHeader( { title } ) {
<View>
<Spacer marginBottom={ 0 } paddingX={ 4 } paddingY={ 3 }>
<HStack spacing={ 2 }>
<NavigatorBackButton
<Navigator.BackButton
style={
// TODO: This style override is also used in ToolsPanelHeader.
// It should be supported out-of-the-box by Button.
Expand All @@ -46,14 +43,14 @@ function ScreenHeader( { title } ) {

export default function MobileTabNavigation( { categories, children } ) {
return (
<NavigatorProvider
<Navigator.BackButton
initialPath="/"
className="block-editor-inserter__mobile-tab-navigation"
>
<NavigatorScreen path="/">
<Navigator.Screen path="/">
<ItemGroup>
{ categories.map( ( category ) => (
<NavigatorButton
<Navigator.Button
key={ category.name }
path={ `/category/${ category.name }` }
as={ Item }
Expand All @@ -67,19 +64,19 @@ export default function MobileTabNavigation( { categories, children } ) {
}
/>
</HStack>
</NavigatorButton>
</Navigator.Button>
) ) }
</ItemGroup>
</NavigatorScreen>
</Navigator.Screen>
{ categories.map( ( category ) => (
<NavigatorScreen
<Navigator.Screen
key={ category.name }
path={ `/category/${ category.name }` }
>
<ScreenHeader title={ __( 'Back' ) } />
{ children( category ) }
</NavigatorScreen>
</Navigator.Screen>
) ) }
</NavigatorProvider>
</Navigator.BackButton>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
FlexBlock,
Flex,
Button,
__experimentalUseNavigator as useNavigator,
useNavigator,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { styles, seen, backup } from '@wordpress/icons';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { _n, sprintf, isRTL } from '@wordpress/i18n';
import {
__experimentalUseNavigator as useNavigator,
useNavigator,
__experimentalText as Text,
Button,
Flex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import {
__experimentalText as Text,
__experimentalHStack as HStack,
__experimentalVStack as VStack,
__experimentalNavigatorProvider as NavigatorProvider,
__experimentalNavigatorScreen as NavigatorScreen,
__experimentalNavigatorBackButton as NavigatorBackButton,
Navigator,
__experimentalHeading as Heading,
Notice,
SelectControl,
Expand Down Expand Up @@ -284,11 +282,11 @@ function FontCollection( { slug } ) {

{ ! isLoading && (
<>
<NavigatorProvider
<Navigator
initialPath="/"
className="font-library-modal__tabpanel-layout"
>
<NavigatorScreen path="/">
<Navigator.Screen path="/">
<HStack justify="space-between">
<VStack>
<Heading level={ 2 } size={ 13 }>
Expand Down Expand Up @@ -378,11 +376,11 @@ function FontCollection( { slug } ) {
</ul>
{ /* eslint-enable jsx-a11y/no-redundant-roles */ }
</div>
</NavigatorScreen>
</Navigator.Screen>

<NavigatorScreen path="/fontFamily">
<Navigator.Screen path="/fontFamily">
<Flex justify="flex-start">
<NavigatorBackButton
<Navigator.BackButton
icon={
isRTL() ? chevronRight : chevronLeft
}
Expand Down Expand Up @@ -463,8 +461,8 @@ function FontCollection( { slug } ) {
{ /* eslint-enable jsx-a11y/no-redundant-roles */ }
</VStack>
<Spacer margin={ 16 } />
</NavigatorScreen>
</NavigatorProvider>
</Navigator.Screen>
</Navigator>

{ selectedFont && (
<Flex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import {
__experimentalConfirmDialog as ConfirmDialog,
__experimentalHStack as HStack,
__experimentalHeading as Heading,
__experimentalNavigatorProvider as NavigatorProvider,
__experimentalNavigatorScreen as NavigatorScreen,
__experimentalNavigatorBackButton as NavigatorBackButton,
__experimentalUseNavigator as useNavigator,
Navigator,
useNavigator,
__experimentalSpacer as Spacer,
__experimentalText as Text,
__experimentalVStack as VStack,
Expand Down Expand Up @@ -235,12 +233,12 @@ function InstalledFonts() {

{ ! isResolvingLibrary && (
<>
<NavigatorProvider
<Navigator.Button
initialPath={
libraryFontSelected ? '/fontFamily' : '/'
}
>
<NavigatorScreen path="/">
<Navigator.Screen path="/">
<VStack spacing="8">
{ notice && (
<Notice
Expand Down Expand Up @@ -338,9 +336,9 @@ function InstalledFonts() {
</VStack>
) }
</VStack>
</NavigatorScreen>
</Navigator.Screen>

<NavigatorScreen path="/fontFamily">
<Navigator.Screen path="/fontFamily">
<ConfirmDeleteDialog
font={ libraryFontSelected }
isOpen={ isConfirmDeleteOpen }
Expand All @@ -353,7 +351,7 @@ function InstalledFonts() {
/>

<Flex justify="flex-start">
<NavigatorBackButton
<Navigator.BackButton
icon={
isRTL() ? chevronRight : chevronLeft
}
Expand Down Expand Up @@ -427,8 +425,8 @@ function InstalledFonts() {
</ul>
{ /* eslint-enable jsx-a11y/no-redundant-roles */ }
</VStack>
</NavigatorScreen>
</NavigatorProvider>
</Navigator.Screen>
</Navigator.Button>

<HStack
justify="flex-end"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
import { __, sprintf } from '@wordpress/i18n';
import {
__experimentalSpacer as Spacer,
__experimentalUseNavigator as useNavigator,
useNavigator,
__experimentalView as View,
__experimentalHStack as HStack,
__experimentalVStack as VStack,
Expand Down
4 changes: 2 additions & 2 deletions packages/edit-site/src/components/global-styles/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
__experimentalSpacer as Spacer,
__experimentalHeading as Heading,
__experimentalView as View,
__experimentalNavigatorBackButton as NavigatorBackButton,
Navigator,
} from '@wordpress/components';
import { isRTL, __ } from '@wordpress/i18n';
import { chevronRight, chevronLeft } from '@wordpress/icons';
Expand All @@ -18,7 +18,7 @@ function ScreenHeader( { title, description, onBack } ) {
<View>
<Spacer marginBottom={ 0 } paddingX={ 4 } paddingY={ 3 }>
<HStack spacing={ 2 }>
<NavigatorBackButton
<Navigator.BackButton
icon={ isRTL() ? chevronRight : chevronLeft }
size="small"
label={ __( 'Back' ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
* WordPress dependencies
*/
import {
__experimentalNavigatorButton as NavigatorButton,
__experimentalNavigatorBackButton as NavigatorBackButton,
Navigator,
__experimentalItem as Item,
FlexItem,
__experimentalHStack as HStack,
Expand All @@ -29,11 +28,11 @@ function GenericNavigationButton( { icon, children, ...props } ) {
}

function NavigationButtonAsItem( props ) {
return <NavigatorButton as={ GenericNavigationButton } { ...props } />;
return <Navigator.Button as={ GenericNavigationButton } { ...props } />;
}

function NavigationBackButtonAsItem( props ) {
return <NavigatorBackButton as={ GenericNavigationButton } { ...props } />;
return <Navigator.BackButton as={ GenericNavigationButton } { ...props } />;
}

export { NavigationButtonAsItem, NavigationBackButtonAsItem };
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { __, sprintf } from '@wordpress/i18n';
import {
__experimentalUseNavigator as useNavigator,
useNavigator,
__experimentalConfirmDialog as ConfirmDialog,
Spinner,
} from '@wordpress/components';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
__experimentalUnitControl as UnitControl,
__experimentalGrid as Grid,
__experimentalDropdownContentWrapper as DropdownContentWrapper,
__experimentalUseNavigator as useNavigator,
useNavigator,
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
__experimentalConfirmDialog as ConfirmDialog,
Expand Down
11 changes: 5 additions & 6 deletions packages/edit-site/src/components/global-styles/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
* WordPress dependencies
*/
import {
__experimentalNavigatorProvider as NavigatorProvider,
__experimentalNavigatorScreen as NavigatorScreen,
__experimentalUseNavigator as useNavigator,
Navigator,
useNavigator,
createSlotFill,
DropdownMenu,
MenuGroup,
Expand Down Expand Up @@ -124,7 +123,7 @@ function GlobalStylesActionMenu() {

function GlobalStylesNavigationScreen( { className, ...props } ) {
return (
<NavigatorScreen
<Navigator.Screen
className={ [
'edit-site-global-styles-sidebar__navigator-screen',
className,
Expand Down Expand Up @@ -283,7 +282,7 @@ function GlobalStylesUI() {
[]
);
return (
<NavigatorProvider
<Navigator
className="edit-site-global-styles-sidebar__navigator-provider"
initialPath="/"
>
Expand Down Expand Up @@ -385,7 +384,7 @@ function GlobalStylesUI() {
<GlobalStylesActionMenu />
<GlobalStylesBlockLink />
<GlobalStylesEditorCanvasContainerLink />
</NavigatorProvider>
</Navigator>
);
}
export { GlobalStylesMenuSlot };
Expand Down
26 changes: 10 additions & 16 deletions packages/preferences/src/components/preferences-modal-tabs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
*/
import { useViewportMatch } from '@wordpress/compose';
import {
__experimentalNavigatorProvider as NavigatorProvider,
__experimentalNavigatorScreen as NavigatorScreen,
__experimentalNavigatorButton as NavigatorButton,
__experimentalNavigatorBackButton as NavigatorBackButton,
Navigator,
__experimentalItemGroup as ItemGroup,
__experimentalItem as Item,
__experimentalHStack as HStack,
Expand Down Expand Up @@ -98,17 +95,14 @@ export default function PreferencesModalTabs( { sections } ) {
);
} else {
modalContent = (
<NavigatorProvider
initialPath="/"
className="preferences__provider"
>
<NavigatorScreen path="/">
<Navigator initialPath="/" className="preferences__provider">
<Navigator.Screen path="/">
<Card isBorderless size="small">
<CardBody>
<ItemGroup>
{ tabs.map( ( tab ) => {
return (
<NavigatorButton
<Navigator.Button
key={ tab.name }
path={ `/${ tab.name }` }
as={ Item }
Expand All @@ -130,17 +124,17 @@ export default function PreferencesModalTabs( { sections } ) {
/>
</FlexItem>
</HStack>
</NavigatorButton>
</Navigator.Button>
);
} ) }
</ItemGroup>
</CardBody>
</Card>
</NavigatorScreen>
</Navigator.Screen>
{ sections.length &&
sections.map( ( section ) => {
return (
<NavigatorScreen
<Navigator.Screen
key={ `${ section.name }-menu` }
path={ `/${ section.name }` }
>
Expand All @@ -151,7 +145,7 @@ export default function PreferencesModalTabs( { sections } ) {
size="small"
gap="6"
>
<NavigatorBackButton
<Navigator.BackButton
icon={
isRTL()
? chevronRight
Expand All @@ -165,10 +159,10 @@ export default function PreferencesModalTabs( { sections } ) {
</CardHeader>
<CardBody>{ section.content }</CardBody>
</Card>
</NavigatorScreen>
</Navigator.Screen>
);
} ) }
</NavigatorProvider>
</Navigator>
);
}

Expand Down

0 comments on commit dfbc26b

Please sign in to comment.