Skip to content

Commit

Permalink
Use query instead of path
Browse files Browse the repository at this point in the history
  • Loading branch information
tellthemachines committed Dec 16, 2024
1 parent 7e9bbce commit b7dff57
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const GlobalStylesPageActions = ( {
setIsStyleBookOpened,
path,
} ) => {
const stylebookPath = 'styles-stylebook';
const stylebookPath = addQueryArgs( path, { preview: 'stylebook' } );
const history = useHistory();
return (
<Button
Expand All @@ -33,8 +33,8 @@ const GlobalStylesPageActions = ( {
onClick={ () => {
setIsStyleBookOpened( ! isStyleBookOpened );
const updatedPath = ! isStyleBookOpened
? path.replace( 'styles', stylebookPath )
: path.replace( stylebookPath, 'styles' );
? path.replace( '/styles', stylebookPath )
: path.replace( stylebookPath, '/styles' );
// Navigate to the updated path.
history.navigate( updatedPath );
} }
Expand Down Expand Up @@ -69,7 +69,7 @@ export default function GlobalStylesUIWrapper() {
const { path } = useLocation();

const [ isStyleBookOpened, setIsStyleBookOpened ] = useState(
path.includes( 'styles-stylebook' )
path.includes( 'preview=stylebook' )
);
const isMobileViewport = useViewportMatch( 'medium', '<' );
const [ section, onChangeSection ] = useSection();
Expand Down
2 changes: 0 additions & 2 deletions packages/edit-site/src/components/site-editor-routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { templateItemRoute } from './template-item';
import { pagesRoute } from './pages';
import { pageItemRoute } from './page-item';
import { stylebookRoute } from './stylebook';
import { stylesStylebookRoute } from './styles-stylebook';

const routes = [
pageItemRoute,
Expand All @@ -36,7 +35,6 @@ const routes = [
stylesRoute,
homeRoute,
stylebookRoute,
stylesStylebookRoute,
];

export function useRegisterSiteEditorRoutes() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Editor from '../editor';
import { unlock } from '../../lock-unlock';
import SidebarNavigationScreenGlobalStyles from '../sidebar-navigation-screen-global-styles';
import GlobalStylesUIWrapper from '../sidebar-global-styles-wrapper';
import { StyleBookPreview } from '../style-book';

const { useLocation } = unlock( routerPrivateApis );

Expand All @@ -30,7 +31,10 @@ export const stylesRoute = {
areas: {
content: <GlobalStylesUIWrapper />,
sidebar: <SidebarNavigationScreenGlobalStyles backPath="/" />,
preview: <Editor />,
preview( { query } ) {
const isStylebook = query.preview === 'stylebook';
return isStylebook ? <StyleBookPreview /> : <Editor />;
},
mobile: <MobileGlobalStylesUI />,
},
widths: {
Expand Down

0 comments on commit b7dff57

Please sign in to comment.