// // Copyright 2026 DXOS.org // import React, { PropsWithChildren, useMemo } from 'react'; import { random } from '@dxos/random'; import { mx } from '@dxos/ui-theme'; import { ThemedClassName } from '@dxos/ui-types'; import { withLayout, withTheme } from '../../testing'; import { Column } from '../Column'; import { Input } from '../Input'; import { ScrollArea } from './ScrollArea'; random.seed(123); export default { title: 'ui/react-ui-core/components/ScrollArea', component: ScrollArea, decorators: [withTheme()], parameters: { layout: 'centered', }, }; const List = ({ items = 50 }: { items?: number }) => (
{Array.from({ length: items }).map((_, index) => (
Item {index + 1}
))}
); const Row = ({ items = 50 }: { items?: number }) => (
{Array.from({ length: items }).map((_, index) => (
{index + 1}
))}
); const Container = ({ classNames, children }: ThemedClassName) => { return
{children}
; }; export const Vertical = { render: () => ( ), }; export const VerticalThin = { render: () => ( ), }; export const VerticalPadded = { render: () => ( ), }; export const VerticalColumn = { render: () => ( ), }; export const Horizontal = { render: () => ( ), }; export const HorizontalThin = { render: () => ( ), }; export const Both = { render: () => (
{Array.from({ length: 50 }).map((_, rowIndex) => (
{Array.from({ length: 50 }).map((_, colIndex) => (
[{colIndex}:{rowIndex}]
))}
))}
), }; export const Fullscreen = { decorators: [withTheme(), withLayout({ layout: 'fullscreen' })], render: () => (
{Array.from({ length: 50 }).map((_, rowIndex) => (
{Array.from({ length: 50 }).map((_, colIndex) => (
[{colIndex}:{rowIndex}]
))}
))}
), }; export const NestedScrollAreas = { decorators: [withTheme(), withLayout({ layout: 'fullscreen' })], render: () => { const columns = useMemo( () => Array.from({ length: 8 }).map((_, index) => ({ id: String(index), count: random.number.int({ min: 5, max: 20 }), })), [], ); return ( {columns.map((column) => (
Column {column.id}
{Array.from({ length: column.count }, (_, i) => (
Item {i + 1}
))}
{column.count}
))}
); }, }; export const NativeScroll = { render: () => (
), };