Scroll behavior part 2 (#1304)

* Fix layout issues introduced by scroll behavior

* Complete scrollbar work
This commit is contained in:
Charles Bochet
2023-08-25 12:38:45 +02:00
committed by GitHub
parent 0d210244db
commit de569f4c06
11 changed files with 162 additions and 92 deletions

View File

@ -0,0 +1,35 @@
import { useRef } from 'react';
import styled from '@emotion/styled';
import { useListenScroll } from '../hooks/useListenScroll';
const StyledScrollWrapper = styled.div`
display: flex;
height: 100%;
overflow: scroll;
scrollbar-gutter: stable;
width: 100%;
&.scrolling::-webkit-scrollbar-thumb {
background-color: ${({ theme }) => theme.border.color.medium};
}
`;
export type ScrollWrapperProps = {
children: React.ReactNode;
className?: string;
};
export function ScrollWrapper({ children, className }: ScrollWrapperProps) {
const scrollableRef = useRef<HTMLDivElement>(null);
useListenScroll({
scrollableRef,
});
return (
<StyledScrollWrapper ref={scrollableRef} className={className}>
{children}
</StyledScrollWrapper>
);
}

View File

@ -1,12 +0,0 @@
import styled from '@emotion/styled';
export const StyledScrollWrapper = styled.div`
display: flex;
height: 100%;
overflow: auto;
width: 100%;
&.scrolling::-webkit-scrollbar-thumb {
background-color: ${({ theme }) => theme.border.color.medium};
}
`;