Move drag container to scrollarea component

This commit is contained in:
jeffvli 2023-09-22 02:40:27 -07:00
parent 1a87adb728
commit 14f4649b93
2 changed files with 55 additions and 57 deletions

View file

@ -79,24 +79,6 @@ const TitleWrapper = styled(motion.div)`
height: 100%; height: 100%;
`; `;
const DragContainer = styled.div`
position: absolute;
top: 0;
left: 0;
z-index: -1;
width: calc(100% - 130px);
height: 65px;
-webkit-app-region: drag;
button {
-webkit-app-region: no-drag;
}
input {
-webkit-app-region: no-drag;
}
`;
const variants: Variants = { const variants: Variants = {
animate: { animate: {
opacity: 1, opacity: 1,
@ -125,40 +107,35 @@ export const PageHeader = ({
return ( return (
<> <>
{windowBarStyle === Platform.WEB && <DragContainer />} <Container
{!isHidden && ( ref={ref}
<Container $height={height}
ref={ref} $position={position}
$height={height} {...props}
$position={position} >
{...props} <Header
$isDraggable={windowBarStyle === Platform.WEB}
$isHidden={isHidden}
$padRight={padRight}
> >
<Header <AnimatePresence initial={animated ?? false}>
$isDraggable={windowBarStyle === Platform.WEB} <TitleWrapper
$isHidden={isHidden} animate="animate"
$padRight={padRight} exit="exit"
> initial="initial"
<AnimatePresence initial={animated ?? false}> variants={variants}
<TitleWrapper >
animate="animate" {children}
exit="exit" </TitleWrapper>
initial="initial" </AnimatePresence>
variants={variants} </Header>
> {backgroundColor && (
{children} <>
</TitleWrapper> <BackgroundImage $background={backgroundColor || 'var(--titlebar-bg)'} />
</AnimatePresence> <BackgroundImageOverlay theme={theme as 'light' | 'dark'} />
</Header> </>
{backgroundColor && ( )}
<> </Container>
<BackgroundImage
$background={backgroundColor || 'var(--titlebar-bg)'}
/>
<BackgroundImageOverlay theme={theme as 'light' | 'dark'} />
</>
)}
</Container>
)}
</> </>
); );
}; };

View file

@ -9,6 +9,24 @@ import { PageHeader, PageHeaderProps } from '/@/renderer/components/page-header'
import { useWindowSettings } from '/@/renderer/store/settings.store'; import { useWindowSettings } from '/@/renderer/store/settings.store';
import { Platform } from '/@/renderer/types'; import { Platform } from '/@/renderer/types';
const DragContainer = styled.div`
position: absolute;
top: 0;
left: 0;
z-index: -1;
width: calc(100% - 130px);
height: 65px;
-webkit-app-region: drag;
button {
-webkit-app-region: no-drag;
}
input {
-webkit-app-region: no-drag;
}
`;
interface ScrollAreaProps extends MantineScrollAreaProps { interface ScrollAreaProps extends MantineScrollAreaProps {
children: ReactNode; children: ReactNode;
} }
@ -128,12 +146,15 @@ export const NativeScrollArea = forwardRef(
return ( return (
<> <>
<PageHeader {windowBarStyle === Platform.WEB && <DragContainer />}
animated {shouldShowHeader && (
isHidden={!shouldShowHeader} <PageHeader
position="absolute" animated
{...pageHeaderProps} isHidden={false}
/> position="absolute"
{...pageHeaderProps}
/>
)}
<StyledNativeScrollArea <StyledNativeScrollArea
ref={mergedRef} ref={mergedRef}
$scrollBarOffset={scrollBarOffset} $scrollBarOffset={scrollBarOffset}