-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: the visible height of the table container
- Loading branch information
1 parent
3d0661b
commit 0d48466
Showing
4 changed files
with
40 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useEffect, useRef, useState } from 'react'; | ||
|
||
function useCustomSimpleBar() { | ||
const [scrollBarMaxHeight, setScrollBarMaxHeight] = useState(0); | ||
const scrollBarContainer = useRef<HTMLDivElement | null>(null); | ||
|
||
useEffect(() => { | ||
function handleResize() { | ||
if (!scrollBarContainer?.current) return; | ||
|
||
setScrollBarMaxHeight(scrollBarContainer.current.offsetHeight); | ||
} | ||
|
||
handleResize(); | ||
|
||
window.addEventListener('resize', handleResize); | ||
|
||
return () => { | ||
window.removeEventListener('resize', handleResize); | ||
}; | ||
}, []); | ||
|
||
return { scrollBarMaxHeight, scrollBarContainer }; | ||
} | ||
|
||
export { useCustomSimpleBar }; |
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,11 +1,16 @@ | ||
import 'simplebar-react/dist/simplebar.min.css'; | ||
import { useCustomSimpleBar } from './hook'; | ||
import * as S from './styles'; | ||
import { CustomSimpleBarProps } from './types'; | ||
|
||
export function CustomSimpleBar({ children }: CustomSimpleBarProps) { | ||
const { scrollBarContainer, scrollBarMaxHeight } = useCustomSimpleBar(); | ||
|
||
return ( | ||
<S.Container> | ||
<S.Wrapper>{children}</S.Wrapper> | ||
<S.Container ref={scrollBarContainer}> | ||
<S.Wrapper style={{ maxHeight: scrollBarMaxHeight }}> | ||
{children} | ||
</S.Wrapper> | ||
</S.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
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