diff --git a/code/lib/router/src/router.tsx b/code/lib/router/src/router.tsx index 118077b9c007..f2e44437b001 100644 --- a/code/lib/router/src/router.tsx +++ b/code/lib/router/src/router.tsx @@ -3,7 +3,6 @@ import React, { useCallback } from 'react'; import type { ReactNode, ReactElement, ComponentProps } from 'react'; import * as R from 'react-router-dom'; -import { ToggleVisibility } from './visibility'; import { queryFromString, parsePath, getMatch } from './utils'; import type { LinkProps, NavigateOptions, RenderData } from './types'; @@ -31,13 +30,11 @@ interface MatchPropsDefault { interface RoutePropsStartsWith { path: string; startsWith?: boolean; - hideOnly?: boolean; children: ReactNode; } interface RoutePropsDefault { path: RegExp; startsWith?: false; - hideOnly?: boolean; children: ReactNode; } @@ -128,23 +125,14 @@ Match.displayName = 'QueryMatch'; function Route(props: RoutePropsDefault): ReactElement; function Route(props: RoutePropsStartsWith): ReactElement; function Route(input: RoutePropsDefault | RoutePropsStartsWith) { - const { children, hideOnly, ...rest } = input; + const { children, ...rest } = input; if (rest.startsWith === undefined) { rest.startsWith = false; } const matchProps = rest as Omit, 'children'>; - return ( - - {({ match }) => { - if (hideOnly) { - return ; - } - return match ? children : null; - }} - - ); + return {({ match }) => (match ? children : null)}; } Route.displayName = 'Route'; diff --git a/code/ui/manager/src/App.tsx b/code/ui/manager/src/App.tsx index 394016ff5708..74e68183ee62 100644 --- a/code/ui/manager/src/App.tsx +++ b/code/ui/manager/src/App.tsx @@ -1,8 +1,5 @@ import type { ComponentProps } from 'react'; import React from 'react'; - -import { Route } from '@storybook/router'; - import { Global, createGlobal } from '@storybook/theming'; import type { Addon_PageType } from '@storybook/types'; import Sidebar from './container/Sidebar'; @@ -27,11 +24,7 @@ export const App = ({ managerLayoutState, setManagerLayoutState, pages }: Props) - - - } + slotMain={} slotSidebar={ setMobileAboutOpen((state) => !state)} />} slotPanel={} slotPages={pages.map(({ id, render: Content }) => ( diff --git a/code/ui/manager/src/components/layout/Layout.stories.tsx b/code/ui/manager/src/components/layout/Layout.stories.tsx index aea6f4a1a5f2..6fa6541b88df 100644 --- a/code/ui/manager/src/components/layout/Layout.stories.tsx +++ b/code/ui/manager/src/components/layout/Layout.stories.tsx @@ -7,6 +7,7 @@ import type { Meta, StoryObj } from '@storybook/react'; import { fn } from '@storybook/test'; import { Layout } from './Layout'; import { LayoutProvider } from './LayoutProvider'; +import { LocationProvider } from '@storybook/router'; import MobileNavigationStoriesMeta from '../mobile/navigation/MobileNavigation.stories'; const PlaceholderBlock = styled.div({ @@ -67,7 +68,11 @@ const meta = { }, decorators: [ MobileNavigationStoriesMeta.decorators[0] as any, - (storyFn) => {storyFn()}, + (storyFn) => ( + + {storyFn()} + + ), ], render: (args) => { const [managerLayoutState, setManagerLayoutState] = useState(args.managerLayoutState); diff --git a/code/ui/manager/src/components/layout/Layout.tsx b/code/ui/manager/src/components/layout/Layout.tsx index 726b535e7f37..1c3494f76a20 100644 --- a/code/ui/manager/src/components/layout/Layout.tsx +++ b/code/ui/manager/src/components/layout/Layout.tsx @@ -6,6 +6,7 @@ import { MobileNavigation } from '../mobile/navigation/MobileNavigation'; import { MEDIA_DESKTOP_BREAKPOINT } from '../../constants'; import { useLayout } from './LayoutProvider'; import { Notifications } from '../../container/Notifications'; +import { Match } from '@storybook/router'; interface InternalLayoutState { isDragging: boolean; @@ -145,7 +146,9 @@ export const Layout = ({ managerLayoutState, setManagerLayoutState, ...slots }: > {showPages && {slots.slotPages}} - {slots.slotMain} + + {({ match }) => {slots.slotMain}} + {isDesktop && ( <> @@ -210,11 +213,12 @@ const SidebarContainer = styled.div(({ theme }) => ({ borderRight: `1px solid ${theme.color.border}`, })); -const ContentContainer = styled.div(({ theme }) => ({ +const ContentContainer = styled.div<{ shown: boolean }>(({ theme, shown }) => ({ flex: 1, position: 'relative', backgroundColor: theme.background.content, - display: 'grid', // This is needed to make the content container fill the available space + display: shown ? 'grid' : 'none', // This is needed to make the content container fill the available space + overflow: 'auto', [MEDIA_DESKTOP_BREAKPOINT]: { flex: 'auto', diff --git a/code/ui/manager/src/components/mobile/navigation/MobileAddonsDrawer.tsx b/code/ui/manager/src/components/mobile/navigation/MobileAddonsDrawer.tsx index b05dff4c3d25..7c0027d610bc 100644 --- a/code/ui/manager/src/components/mobile/navigation/MobileAddonsDrawer.tsx +++ b/code/ui/manager/src/components/mobile/navigation/MobileAddonsDrawer.tsx @@ -1,59 +1,21 @@ import type { FC, ReactNode } from 'react'; -import React, { useRef } from 'react'; +import React from 'react'; import { styled } from '@storybook/theming'; -import { Transition } from 'react-transition-group'; -import type { TransitionStatus } from 'react-transition-group/Transition'; -import { useLayout } from '../../layout/LayoutProvider'; interface MobileAddonsDrawerProps { children: ReactNode; } -const TRANSITION_DURATION = 200; - -const Container = styled.div<{ state: TransitionStatus }>(({ theme, state }) => ({ - position: 'fixed', +const Container = styled.div(({ theme }) => ({ + position: 'relative', boxSizing: 'border-box', width: '100%', background: theme.background.content, - height: '50%', - bottom: 0, - left: 0, + height: '42vh', zIndex: 11, - transition: `all ${TRANSITION_DURATION}ms ease-in-out`, overflow: 'hidden', - borderTop: `1px solid ${theme.appBorderColor}`, - transform: `${(() => { - switch (state) { - case 'entering': - case 'entered': - return 'translateY(0)'; - case 'exiting': - case 'exited': - return 'translateY(100%)'; - default: - return 'translateY(0)'; - } - })()}`, })); export const MobileAddonsDrawer: FC = ({ children }) => { - const { isMobilePanelOpen } = useLayout(); - const containerRef = useRef(null); - - return ( - - {(state) => ( - - {children} - - )} - - ); + return {children}; }; diff --git a/code/ui/manager/src/components/mobile/navigation/MobileNavigation.tsx b/code/ui/manager/src/components/mobile/navigation/MobileNavigation.tsx index 7174b8bd6a2e..47b7587019f8 100644 --- a/code/ui/manager/src/components/mobile/navigation/MobileNavigation.tsx +++ b/code/ui/manager/src/components/mobile/navigation/MobileNavigation.tsx @@ -35,40 +35,50 @@ const useFullStoryName = () => { }; export const MobileNavigation: FC = ({ menu, panel, showPanel }) => { - const { isMobileMenuOpen, setMobileMenuOpen, setMobilePanelOpen } = useLayout(); + const { isMobileMenuOpen, isMobilePanelOpen, setMobileMenuOpen, setMobilePanelOpen } = + useLayout(); const fullStoryName = useFullStoryName(); return ( {menu} - {panel} - - {showPanel && ( - setMobilePanelOpen(true)} title="Open addon panel"> - - + {isMobilePanelOpen ? ( + {panel} + ) : ( + )} ); }; const Container = styled.div(({ theme }) => ({ - display: 'flex', - alignItems: 'center', - justifyContent: 'space-between', bottom: 0, left: 0, width: '100%', - height: 40, zIndex: 10, background: theme.barBg, - padding: '0 6px', borderTop: `1px solid ${theme.appBorderColor}`, })); +const Nav = styled.div({ + display: 'flex', + alignItems: 'center', + justifyContent: 'space-between', + width: '100%', + height: 40, + padding: '0 6px', +}); + const Button = styled.button(({ theme }) => ({ all: 'unset', display: 'flex', diff --git a/docs/snippets/vue/button-story-auto-docs.ts-4-9.mdx b/docs/snippets/vue/button-story-auto-docs.ts-4-9.mdx index 3c03a16deab1..75f31fd78fa1 100644 --- a/docs/snippets/vue/button-story-auto-docs.ts-4-9.mdx +++ b/docs/snippets/vue/button-story-auto-docs.ts-4-9.mdx @@ -1,7 +1,6 @@ ```ts // Button.stories.ts -// Replace vue3 with vue if you are using Storybook for Vue 2 import type { Meta, StoryObj } from '@storybook/vue3'; import Button from './Button.vue'; diff --git a/docs/snippets/vue/csf-3-example-starter.ts-4-9.mdx b/docs/snippets/vue/csf-3-example-starter.ts-4-9.mdx index 3d6b26d14379..f33bfd299044 100644 --- a/docs/snippets/vue/csf-3-example-starter.ts-4-9.mdx +++ b/docs/snippets/vue/csf-3-example-starter.ts-4-9.mdx @@ -1,7 +1,6 @@ ```ts // CSF 3 -// Replace vue3 with vue if you are using Storybook for Vue 2 import type { Meta, StoryObj } from '@storybook/vue3'; import Button from './Button.vue'; diff --git a/docs/snippets/vue/csf-3-example-starter.ts.mdx b/docs/snippets/vue/csf-3-example-starter.ts.mdx index 2dc150b1d738..e13b2470da4e 100644 --- a/docs/snippets/vue/csf-3-example-starter.ts.mdx +++ b/docs/snippets/vue/csf-3-example-starter.ts.mdx @@ -1,7 +1,6 @@ ```ts // CSF 3 -// Replace vue3 with vue if you are using Storybook for Vue 2 import type { Meta, StoryObj } from '@storybook/vue3'; import Button from './Button.vue';