Skip to content

Commit 71f9ac9

Browse files
psychedelicioushipsterusername
authored andcommitted
feat(ui): scollable areas support x-axis scrolling
Closes #5490
1 parent 8bbdfc4 commit 71f9ac9

File tree

4 files changed

+35
-10
lines changed

4 files changed

+35
-10
lines changed

invokeai/frontend/web/src/common/components/OverlayScrollbars/ScrollableContent.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,35 @@
11
import type { ChakraProps } from '@invoke-ai/ui';
22
import { Box, Flex } from '@invoke-ai/ui';
3-
import { overlayScrollbarsParams } from 'common/components/OverlayScrollbars/constants';
3+
import { getOverlayScrollbarsParams } from 'common/components/OverlayScrollbars/constants';
44
import { OverlayScrollbarsComponent } from 'overlayscrollbars-react';
55
import type { CSSProperties, PropsWithChildren } from 'react';
6-
import { memo } from 'react';
6+
import { memo, useMemo } from 'react';
77

88
type Props = PropsWithChildren & {
99
maxHeight?: ChakraProps['maxHeight'];
10+
overflowX?: 'hidden' | 'scroll';
11+
overflowY?: 'hidden' | 'scroll';
1012
};
1113

1214
const styles: CSSProperties = { height: '100%', width: '100%' };
1315

14-
const ScrollableContent = ({ children, maxHeight }: Props) => {
16+
const ScrollableContent = ({
17+
children,
18+
maxHeight,
19+
overflowX = 'hidden',
20+
overflowY = 'scroll',
21+
}: Props) => {
22+
const overlayscrollbarsOptions = useMemo(
23+
() => getOverlayScrollbarsParams(overflowX, overflowY).options,
24+
[overflowX, overflowY]
25+
);
1526
return (
1627
<Flex w="full" h="full" maxHeight={maxHeight} position="relative">
1728
<Box position="absolute" top={0} left={0} right={0} bottom={0}>
1829
<OverlayScrollbarsComponent
1930
defer
2031
style={styles}
21-
options={overlayScrollbarsParams.options}
32+
options={overlayscrollbarsOptions}
2233
>
2334
{children}
2435
</OverlayScrollbarsComponent>

invokeai/frontend/web/src/common/components/OverlayScrollbars/constants.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { cloneDeep, merge } from 'lodash-es';
12
import { ClickScrollPlugin, OverlayScrollbars } from 'overlayscrollbars';
23
import type { UseOverlayScrollbarsParams } from 'overlayscrollbars-react';
34

@@ -16,3 +17,12 @@ export const overlayScrollbarsParams: UseOverlayScrollbarsParams = {
1617
overflow: { x: 'hidden' },
1718
},
1819
};
20+
21+
export const getOverlayScrollbarsParams = (
22+
overflowX: 'hidden' | 'scroll' = 'hidden',
23+
overflowY: 'hidden' | 'scroll' = 'scroll'
24+
) => {
25+
const params = cloneDeep(overlayScrollbarsParams);
26+
merge(params, { options: { overflow: { y: overflowY, x: overflowX } } });
27+
return params;
28+
};

invokeai/frontend/web/src/features/gallery/components/ImageMetadataViewer/DataViewer.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { Box, Flex, IconButton, Tooltip } from '@invoke-ai/ui';
2-
import { overlayScrollbarsParams } from 'common/components/OverlayScrollbars/constants';
2+
import {
3+
getOverlayScrollbarsParams,
4+
} from 'common/components/OverlayScrollbars/constants';
35
import { isString } from 'lodash-es';
46
import { OverlayScrollbarsComponent } from 'overlayscrollbars-react';
57
import type { CSSProperties } from 'react';
@@ -15,6 +17,11 @@ type Props = {
1517
withCopy?: boolean;
1618
};
1719

20+
const overlayscrollbarsOptions = getOverlayScrollbarsParams(
21+
'scroll',
22+
'scroll'
23+
).options;
24+
1825
const DataViewer = (props: Props) => {
1926
const { label, data, fileName, withDownload = true, withCopy = true } = props;
2027
const dataString = useMemo(
@@ -60,7 +67,7 @@ const DataViewer = (props: Props) => {
6067
<OverlayScrollbarsComponent
6168
defer
6269
style={overlayScrollbarsStyles}
63-
options={overlayScrollbarsParams.options}
70+
options={overlayscrollbarsOptions}
6471
>
6572
<pre>{dataString}</pre>
6673
</OverlayScrollbarsComponent>

invokeai/frontend/web/src/features/queue/components/QueueList/QueueItemDetail.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
Spinner,
77
Text,
88
} from '@invoke-ai/ui';
9-
import ScrollableContent from 'common/components/OverlayScrollbars/ScrollableContent';
109
import DataViewer from 'features/gallery/components/ImageMetadataViewer/DataViewer';
1110
import { useCancelBatch } from 'features/queue/hooks/useCancelBatch';
1211
import { useCancelQueueItem } from 'features/queue/hooks/useCancelQueueItem';
@@ -127,9 +126,7 @@ const QueueItemComponent = ({ queueItemDTO }: Props) => {
127126
justifyContent="center"
128127
>
129128
{queueItem ? (
130-
<ScrollableContent>
131-
<DataViewer label="Queue Item" data={queueItem} />
132-
</ScrollableContent>
129+
<DataViewer label="Queue Item" data={queueItem} />
133130
) : (
134131
<Spinner opacity={0.5} />
135132
)}

0 commit comments

Comments
 (0)