Created
January 28, 2024 20:02
-
-
Save ChrisCrossCrash/c8e214374ee9273b5ef465ab49c9cbeb to your computer and use it in GitHub Desktop.
A three-panel layout that only displays two panels at once.
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
import React from 'react' | |
type TriPanelShiftLayoutProps = { | |
panelStart: React.ReactNode | |
panelCenter: React.ReactNode | |
panelEnd: React.ReactNode | |
isShifted?: boolean | |
className?: string | |
style?: React.CSSProperties | |
} | |
/** A three-panel layout that only displays two panels at once. */ | |
function TriPanelShiftLayout(props: TriPanelShiftLayoutProps) { | |
return ( | |
<div | |
style={{ maxWidth: '100vw', overflowX: 'hidden', ...props.style }} | |
className={props.className ?? ''} | |
> | |
<div | |
style={{ | |
display: 'grid', | |
gridTemplateColumns: 'repeat(3, 50vw)', | |
height: '100vh', | |
width: '150%', | |
transition: 'transform 1s cubic-bezier(0.215, 0.61, 0.355, 1)', | |
transform: props.isShifted ? 'translateX(-50vw)' : 'none', | |
}} | |
> | |
<div>{props.panelStart}</div> | |
<div>{props.panelCenter}</div> | |
<div>{props.panelEnd}</div> | |
</div> | |
</div> | |
) | |
} | |
export default TriPanelShiftLayout |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment