-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25787 from storybookjs/charles-fix-mobile-addon-p…
…anel UI: Improve how the addon panel work on mobile
- Loading branch information
Showing
6 changed files
with
46 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 5 additions & 43 deletions
48
code/ui/manager/src/components/mobile/navigation/MobileAddonsDrawer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<MobileAddonsDrawerProps> = ({ children }) => { | ||
const { isMobilePanelOpen } = useLayout(); | ||
const containerRef = useRef(null); | ||
|
||
return ( | ||
<Transition | ||
nodeRef={containerRef} | ||
in={isMobilePanelOpen} | ||
timeout={TRANSITION_DURATION} | ||
mountOnEnter | ||
unmountOnExit | ||
> | ||
{(state) => ( | ||
<Container ref={containerRef} state={state}> | ||
{children} | ||
</Container> | ||
)} | ||
</Transition> | ||
); | ||
return <Container>{children}</Container>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters