Skip to content

Commit

Permalink
add as prop
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitayutanov committed Jan 15, 2025
1 parent e768976 commit 8f693e0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.container {
@include lightDark(--thumb-color, #e5e5e7, rgba(255, 255, 255, 0.1));

overflow-y: auto;
overflow: auto;

/* firefox */
@-moz-document url-prefix() {
Expand All @@ -17,6 +17,10 @@
width: 16px;
}

&::-webkit-scrollbar-corner {
background-color: transparent;
}

&::-webkit-scrollbar-track,
&::-webkit-scrollbar-thumb {
background-clip: padding-box;
Expand Down
20 changes: 14 additions & 6 deletions utils/vara-ui/src/components/scroll-area/scroll-area.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import cx from 'clsx';
import { PropsWithChildren } from 'react';
import { ComponentPropsWithoutRef, ElementType, PropsWithChildren } from 'react';

import styles from './scroll-area.module.scss';

type Props = PropsWithChildren & {
className?: string;
};
type Props<T extends ElementType> = PropsWithChildren &
ComponentPropsWithoutRef<T> & {
as?: T;
className?: string;
};

function ScrollArea({ children, className }: Props) {
return <div className={cx(styles.container, className)}>{children}</div>;
function ScrollArea<T extends ElementType = 'div'>({ as, children, className, ...attrs }: Props<T>) {
const Element = as || 'div';

return (
<Element className={cx(styles.container, className)} {...attrs}>
{children}
</Element>
);
}

export { ScrollArea };
Expand Down

0 comments on commit 8f693e0

Please sign in to comment.