From d305e72b5a9faa806dc9dc7be8eb257274811c54 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Mon, 24 Mar 2025 12:24:49 -0600 Subject: [PATCH] Update scroll area --- .../ui/layouts/AppLayout.stories.tsx | 20 +---- .../ui/layouts/AppPageLayout.stories.tsx | 2 +- .../ui/layouts/AppPageLayoutContent.tsx | 16 ++-- .../ui/scroll-area/ScrollArea.stories.tsx | 87 +++++++------------ .../components/ui/scroll-area/ScrollArea.tsx | 4 +- .../DashboardViewDashboardController.tsx | 5 +- web/src/styles/buster.scss | 3 +- 7 files changed, 49 insertions(+), 88 deletions(-) diff --git a/web/src/components/ui/layouts/AppLayout.stories.tsx b/web/src/components/ui/layouts/AppLayout.stories.tsx index 1edf7bd76..dd926d0f2 100644 --- a/web/src/components/ui/layouts/AppLayout.stories.tsx +++ b/web/src/components/ui/layouts/AppLayout.stories.tsx @@ -40,20 +40,6 @@ export const Default: Story = { } }; -export const WithSidebar: Story = { - args: { - children: , - sidebar:
Sidebar Content
- }, - decorators: [ - (Story) => ( -
- -
- ) - ] -}; - export const NonFloating: Story = { args: { children: , @@ -66,14 +52,14 @@ export const WithAppPageLayout: Story = { sidebar:
Sidebar Content
, children: ( - -
+ + <> {Array.from({ length: 30 }, (_, i) => (
List Item {i + 1} - Lorem ipsum dolor sit amet, consectetur adipiscing elit.
))} -
+
), diff --git a/web/src/components/ui/layouts/AppPageLayout.stories.tsx b/web/src/components/ui/layouts/AppPageLayout.stories.tsx index 15cf35672..3fb756206 100644 --- a/web/src/components/ui/layouts/AppPageLayout.stories.tsx +++ b/web/src/components/ui/layouts/AppPageLayout.stories.tsx @@ -38,7 +38,7 @@ export const NonScrollable: Story = { args: { scrollable: false, header:
Header Content
, - children:
Fixed Content
+ children:
Fixed Content
} }; diff --git a/web/src/components/ui/layouts/AppPageLayoutContent.tsx b/web/src/components/ui/layouts/AppPageLayoutContent.tsx index c071768f6..f2eb2a73f 100644 --- a/web/src/components/ui/layouts/AppPageLayoutContent.tsx +++ b/web/src/components/ui/layouts/AppPageLayoutContent.tsx @@ -1,5 +1,6 @@ import React, { PropsWithChildren } from 'react'; import { cn } from '@/lib/utils'; +import { ScrollArea } from '../scroll-area/ScrollArea'; export const AppPageLayoutContent: React.FC< PropsWithChildren<{ @@ -7,15 +8,12 @@ export const AppPageLayoutContent: React.FC< scrollable?: boolean; }> > = ({ className = '', children, scrollable = true }) => { + const Selector = scrollable ? ScrollArea : 'main'; + const ChildSelector = scrollable ? 'main' : React.Fragment; + return ( -
- {children} -
+ + {children} + ); }; diff --git a/web/src/components/ui/scroll-area/ScrollArea.stories.tsx b/web/src/components/ui/scroll-area/ScrollArea.stories.tsx index f91a7fa28..3747f36dd 100644 --- a/web/src/components/ui/scroll-area/ScrollArea.stories.tsx +++ b/web/src/components/ui/scroll-area/ScrollArea.stories.tsx @@ -1,5 +1,7 @@ import type { Meta, StoryObj } from '@storybook/react'; -import { ScrollArea } from './ScrollArea'; +import { ScrollArea, ScrollBar } from './ScrollArea'; +import { faker } from '@faker-js/faker'; +import Image from 'next/image'; const meta = { title: 'UI/ScrollArea/ScrollArea', @@ -59,61 +61,34 @@ export const TallContent: Story = { }; export const WideContent: Story = { - render: () => ( - -
-

- This content is intentionally wider than the container to demonstrate horizontal - scrolling. The ScrollArea component will automatically add scrollbars as needed. -

-
- {Array.from({ length: 10 }).map((_, i) => ( -
- {i + 1} -
+ render: () => { + const works = Array.from({ length: 50 }, (_, i) => ({ + artist: `Artist ${i + 1}`, + art: faker.image.urlLoremFlickr({ category: 'food', width: 300, height: 400 }) + })); + + return ( + +
+ {works.map((artwork) => ( +
+
+ {`Photo +
+
+ Photo by {artwork.artist} +
+
))}
-
- - ) -}; - -export const CustomHeight: Story = { - render: () => ( - -
-

Taller Scroll Area

- {Array.from({ length: 20 }).map((_, i) => ( -

- Paragraph {i + 1}: Lorem ipsum dolor sit amet, consectetur adipiscing elit. -

- ))} -
-
- ) -}; - -export const NestedContent: Story = { - render: () => ( - -
-

Nested Content Example

-
-

Main content area with some text.

-
-

Nested Section

-

This is nested content inside the scroll area.

-
-
- {Array.from({ length: 10 }).map((_, i) => ( -
-

Section {i + 1}

-

Additional content for demonstrating scrolling behavior.

-
- ))} -
-
- ) + + + ); + } }; diff --git a/web/src/components/ui/scroll-area/ScrollArea.tsx b/web/src/components/ui/scroll-area/ScrollArea.tsx index 9f93d7127..9ca3cee8c 100644 --- a/web/src/components/ui/scroll-area/ScrollArea.tsx +++ b/web/src/components/ui/scroll-area/ScrollArea.tsx @@ -13,7 +13,9 @@ const ScrollArea = React.forwardRef< ref={ref} className={cn('relative overflow-hidden', className)} {...props}> - + {children} diff --git a/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardViewDashboardController.tsx b/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardViewDashboardController.tsx index deda80bb6..17fb897f0 100644 --- a/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardViewDashboardController.tsx +++ b/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardViewDashboardController.tsx @@ -10,6 +10,7 @@ import { useUpdateDashboardConfig } from '@/api/buster_rest/dashboards'; import { useDashboardContentStore } from '@/context/Dashboards'; +import { ScrollArea } from '@/components/ui/scroll-area'; export const DashboardViewDashboardController: React.FC = ({ dashboardId, @@ -24,7 +25,7 @@ export const DashboardViewDashboardController: React.FC = ({ const dashboard = dashboardResponse?.dashboard; return ( -
+ = ({ onOpenAddContentModal={onOpenAddContentModal} readOnly={readOnly} /> -
+ ); }; diff --git a/web/src/styles/buster.scss b/web/src/styles/buster.scss index 5f71a4aad..5673bfca5 100644 --- a/web/src/styles/buster.scss +++ b/web/src/styles/buster.scss @@ -6,8 +6,7 @@ } } -.scroll-shadow-container { - @apply relative overflow-y-auto; +#scroll-area-viewport { scroll-timeline-name: --scrollShadowContainer; .scroll-header {