Files
explore/ui/shared/ContainerWithScrollY.tsx
tom goriunovandGitHub f0e713b877 Add support for customizing the UI color theme (#2923)
* UI customizations: new features

Fixes #2905

* colors for graphs

* introduce env variable

* colors for topbar, stats, selected state and tabs

* fix build

* fix validator

* refactor link.primary.hover color token

* refactor selected colors

* update styles for switch and fix some color tokens

* change color for selectable controls

* icon color tokens refactoring

* UI customizations: new features

Fixes #2905

* test for common components

* tweaks

* migrate from color-mode-hex cookie to color-theme cookie

* clean up

* update screenshots

* more screenshot updates

* update default color of chart line

* update envs for mega eth
2025-08-19 11:58:05 +02:00

49 lines
1.4 KiB
TypeScript

import type { FlexProps } from '@chakra-ui/react';
import { Flex, useToken } from '@chakra-ui/react';
import React from 'react';
export interface Props extends FlexProps {
gradientHeight: number;
onScrollVisibilityChange?: (isVisible: boolean) => void;
};
const ContainerWithScrollY = ({ gradientHeight, children, onScrollVisibilityChange, ...rest }: Props) => {
const ref = React.useRef<HTMLDivElement>(null);
const [ hasScroll, setHasScroll ] = React.useState(false);
const gradientStopColor = useToken('colors', 'bg.primary');
React.useEffect(() => {
if (!ref.current) {
return;
}
const hasScroll = ref.current.scrollHeight >= ref.current.clientHeight + gradientHeight / 2;
setHasScroll(hasScroll);
onScrollVisibilityChange?.(hasScroll);
}, [ gradientHeight, onScrollVisibilityChange ]);
return (
<Flex
flexDirection="column"
overflowY={ hasScroll ? 'scroll' : 'auto' }
ref={ ref }
_after={ hasScroll ? {
position: 'absolute',
content: '""',
bottom: 0,
left: 0,
right: '20px',
height: `${ gradientHeight }px`,
bg: `linear-gradient(to bottom, transparent, ${ gradientStopColor })`,
} : undefined }
pr={ hasScroll ? 5 : 0 }
pb={ hasScroll ? `${ gradientHeight }px` : 0 }
{ ...rest }
>
{ children }
</Flex>
);
};
export default ContainerWithScrollY;