Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: Simplify overlayscrollbars component #22963

Merged
merged 2 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion code/ui/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
},
"devDependencies": {
"@popperjs/core": "^2.6.0",
"@types/overlayscrollbars": "^1.12.0",
"@types/react-syntax-highlighter": "11.0.5",
"@types/util-deprecate": "^1.0.0",
"css": "^3.0.0",
Expand Down
29 changes: 2 additions & 27 deletions code/ui/components/src/ScrollArea/OverlayScrollbars.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,5 @@
import type { FC } from 'react';
import React, { useRef, useEffect } from 'react';
import type { UseOverlayScrollbarsParams } from 'overlayscrollbars-react';
import { OverlayScrollbarsComponent } from 'overlayscrollbars-react';

import { useOverlayScrollbars } from 'overlayscrollbars-react';

export const OverlayScrollbarsComponent: FC<{
options: UseOverlayScrollbarsParams['options'];
className?: string;
}> = ({
options = {},

className,
children,
}) => {
const ref = useRef<HTMLDivElement>();
const [initialize] = useOverlayScrollbars({ options });

useEffect(() => {
initialize(ref.current);
}, [initialize]);

return (
<div className={className} ref={ref}>
{children}
</div>
);
};
export const OverlayScrollbars = OverlayScrollbarsComponent;

export default OverlayScrollbarsComponent;
1 change: 1 addition & 0 deletions code/ui/components/src/ScrollArea/ScrollArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Scroller: FC<ScrollAreaProps> = ({ horizontal, vertical, ...props }) => (
<Suspense fallback={<div {...props} />}>
<GlobalScrollAreaStyles />
<OverlayScrollbars
defer
options={{ scrollbars: { autoHide: 'leave', visibility: 'auto' } }}
{...props}
/>
Expand Down
8 changes: 0 additions & 8 deletions code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6248,7 +6248,6 @@ __metadata:
"@storybook/global": ^5.0.0
"@storybook/theming": 7.1.0-alpha.29
"@storybook/types": 7.1.0-alpha.29
"@types/overlayscrollbars": ^1.12.0
"@types/react-syntax-highlighter": 11.0.5
"@types/util-deprecate": ^1.0.0
css: ^3.0.0
Expand Down Expand Up @@ -8758,13 +8757,6 @@ __metadata:
languageName: node
linkType: hard

"@types/overlayscrollbars@npm:^1.12.0":
version: 1.12.1
resolution: "@types/overlayscrollbars@npm:1.12.1"
checksum: 01e5f3e96ddb349fc49c7e6d8b5b6e2c930c4e50d19d3f269df8f537d149cb054ddfe9db617fb7c071f0799163cd9e633e4d23491f070c9888bca827b0b964e7
languageName: node
linkType: hard

"@types/parse-json@npm:^4.0.0":
version: 4.0.0
resolution: "@types/parse-json@npm:4.0.0"
Expand Down