feat: Introduce Mantine's ScrollArea

This commit is contained in:
blessedcoolant 2023-06-13 01:31:15 +12:00 committed by psychedelicious
parent d282810e53
commit 33912382e3
8 changed files with 59 additions and 47 deletions

View File

@ -0,0 +1,12 @@
import { ScrollArea, ScrollAreaProps } from '@mantine/core';
type IAIScrollArea = ScrollAreaProps;
export default function IAIScrollArea(props: IAIScrollArea) {
const { offsetScrollbars = true, ...rest } = props;
return (
<ScrollArea offsetScrollbars={offsetScrollbars} {...rest}>
{props.children}
</ScrollArea>
);
}

View File

@ -9,15 +9,15 @@ import {
Tooltip, Tooltip,
} from '@chakra-ui/react'; } from '@chakra-ui/react';
import { useAppDispatch } from 'app/store/storeHooks'; import { useAppDispatch } from 'app/store/storeHooks';
import IAIScrollArea from 'common/components/IAIScrollArea';
import { useRecallParameters } from 'features/parameters/hooks/useRecallParameters';
import { setShouldShowImageDetails } from 'features/ui/store/uiSlice'; import { setShouldShowImageDetails } from 'features/ui/store/uiSlice';
import { memo } from 'react'; import { memo } from 'react';
import { useHotkeys } from 'react-hotkeys-hook'; import { useHotkeys } from 'react-hotkeys-hook';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { FaCopy } from 'react-icons/fa'; import { FaCopy } from 'react-icons/fa';
import { IoArrowUndoCircleOutline } from 'react-icons/io5'; import { IoArrowUndoCircleOutline } from 'react-icons/io5';
import { OverlayScrollbarsComponent } from 'overlayscrollbars-react';
import { ImageDTO } from 'services/api'; import { ImageDTO } from 'services/api';
import { useRecallParameters } from 'features/parameters/hooks/useRecallParameters';
type MetadataItemProps = { type MetadataItemProps = {
isLink?: boolean; isLink?: boolean;
@ -317,19 +317,19 @@ const ImageMetadataViewer = memo(({ image }: ImageMetadataViewerProps) => {
</Tooltip> </Tooltip>
<Text fontWeight="semibold">Metadata JSON:</Text> <Text fontWeight="semibold">Metadata JSON:</Text>
</Flex> </Flex>
<OverlayScrollbarsComponent defer> <IAIScrollArea>
<Box <Box
sx={{ sx={{
padding: 4, padding: 4,
borderRadius: 'base', borderRadius: 'base',
bg: 'whiteAlpha.500', bg: 'whiteAlpha.500',
_dark: { bg: 'blackAlpha.500' }, _dark: { bg: 'blackAlpha.500' },
w: 'max-content', w: 'full',
}} }}
> >
<pre>{metadataJSON}</pre> <pre>{metadataJSON}</pre>
</Box> </Box>
</OverlayScrollbarsComponent> </IAIScrollArea>
</Flex> </Flex>
</Flex> </Flex>
); );

View File

@ -1,5 +1,4 @@
import { import {
Box,
Menu, Menu,
MenuButton, MenuButton,
MenuItemOption, MenuItemOption,
@ -13,7 +12,6 @@ import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import IAIButton from 'common/components/IAIButton'; import IAIButton from 'common/components/IAIButton';
import { setSchedulers } from 'features/ui/store/uiSlice'; import { setSchedulers } from 'features/ui/store/uiSlice';
import { isArray } from 'lodash-es'; import { isArray } from 'lodash-es';
import { OverlayScrollbarsComponent } from 'overlayscrollbars-react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
export default function SettingsSchedulers() { export default function SettingsSchedulers() {

View File

@ -1,21 +1,21 @@
import { Flex } from '@chakra-ui/react';
import { createSelector } from '@reduxjs/toolkit'; import { createSelector } from '@reduxjs/toolkit';
import { lightboxSelector } from 'features/lightbox/store/lightboxSelectors';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { memo, useMemo } from 'react'; import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions';
import { Box, Flex } from '@chakra-ui/react'; import IAIScrollArea from 'common/components/IAIScrollArea';
import { lightboxSelector } from 'features/lightbox/store/lightboxSelectors';
import InvokeAILogoComponent from 'features/system/components/InvokeAILogoComponent'; import InvokeAILogoComponent from 'features/system/components/InvokeAILogoComponent';
import OverlayScrollable from './common/OverlayScrollable';
import { PARAMETERS_PANEL_WIDTH } from 'theme/util/constants';
import { import {
activeTabNameSelector, activeTabNameSelector,
uiSelector, uiSelector,
} from 'features/ui/store/uiSelectors'; } from 'features/ui/store/uiSelectors';
import { setShouldShowParametersPanel } from 'features/ui/store/uiSlice'; import { setShouldShowParametersPanel } from 'features/ui/store/uiSlice';
import ResizableDrawer from './common/ResizableDrawer/ResizableDrawer'; import { memo, useMemo } from 'react';
import { PARAMETERS_PANEL_WIDTH } from 'theme/util/constants';
import PinParametersPanelButton from './PinParametersPanelButton'; import PinParametersPanelButton from './PinParametersPanelButton';
import TextToImageTabParameters from './tabs/TextToImage/TextToImageTabParameters'; import ResizableDrawer from './common/ResizableDrawer/ResizableDrawer';
import ImageToImageTabParameters from './tabs/ImageToImage/ImageToImageTabParameters'; import ImageToImageTabParameters from './tabs/ImageToImage/ImageToImageTabParameters';
import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions'; import TextToImageTabParameters from './tabs/TextToImage/TextToImageTabParameters';
import UnifiedCanvasParameters from './tabs/UnifiedCanvas/UnifiedCanvasParameters'; import UnifiedCanvasParameters from './tabs/UnifiedCanvas/UnifiedCanvasParameters';
const selector = createSelector( const selector = createSelector(
@ -82,9 +82,9 @@ const ParametersDrawer = () => {
<InvokeAILogoComponent /> <InvokeAILogoComponent />
<PinParametersPanelButton /> <PinParametersPanelButton />
</Flex> </Flex>
<OverlayScrollable> <IAIScrollArea>
<Flex sx={{ flexDir: 'column', gap: 2 }}>{drawerContent}</Flex> <Flex sx={{ flexDir: 'column', gap: 2 }}>{drawerContent}</Flex>
</OverlayScrollable> </IAIScrollArea>
</Flex> </Flex>
</ResizableDrawer> </ResizableDrawer>
); );

View File

@ -1,11 +1,11 @@
import { Box, Flex } from '@chakra-ui/react'; import { Box, Flex } from '@chakra-ui/react';
import { createSelector } from '@reduxjs/toolkit';
import { useAppSelector } from 'app/store/storeHooks';
import IAIScrollArea from 'common/components/IAIScrollArea';
import { PropsWithChildren, memo } from 'react'; import { PropsWithChildren, memo } from 'react';
import { PARAMETERS_PANEL_WIDTH } from 'theme/util/constants'; import { PARAMETERS_PANEL_WIDTH } from 'theme/util/constants';
import OverlayScrollable from './common/OverlayScrollable';
import PinParametersPanelButton from './PinParametersPanelButton';
import { createSelector } from '@reduxjs/toolkit';
import { uiSelector } from '../store/uiSelectors'; import { uiSelector } from '../store/uiSelectors';
import { useAppSelector } from 'app/store/storeHooks'; import PinParametersPanelButton from './PinParametersPanelButton';
const selector = createSelector(uiSelector, (ui) => { const selector = createSelector(uiSelector, (ui) => {
const { shouldPinParametersPanel, shouldShowParametersPanel } = ui; const { shouldPinParametersPanel, shouldShowParametersPanel } = ui;
@ -35,21 +35,20 @@ const ParametersPinnedWrapper = (props: ParametersPinnedWrapperProps) => {
flexShrink: 0, flexShrink: 0,
}} }}
> >
<OverlayScrollable>
<Flex <Flex
sx={{ sx={{
gap: 2,
flexDirection: 'column',
h: 'full', h: 'full',
w: 'full', w: 'full',
position: 'absolute', position: 'absolute',
}} }}
> >
{props.children} <IAIScrollArea>
<Flex sx={{ flexDirection: 'column', gap: 2 }}>{props.children}</Flex>
</IAIScrollArea>
</Flex> </Flex>
</OverlayScrollable>
<PinParametersPanelButton <PinParametersPanelButton
sx={{ position: 'absolute', top: 0, insetInlineEnd: 0 }} sx={{ position: 'absolute', top: 0, insetInlineEnd: 2 }}
/> />
</Box> </Box>
); );

View File

@ -1,14 +1,17 @@
import { Box, Flex } from '@chakra-ui/react'; import { Box, Flex } from '@chakra-ui/react';
import { memo, useCallback, useRef } from 'react';
import { Panel, PanelGroup } from 'react-resizable-panels';
import { useAppDispatch } from 'app/store/storeHooks'; import { useAppDispatch } from 'app/store/storeHooks';
import { requestCanvasRescale } from 'features/canvas/store/thunks/requestCanvasScale'; import { requestCanvasRescale } from 'features/canvas/store/thunks/requestCanvasScale';
import ResizeHandle from '../ResizeHandle';
import ImageToImageTabParameters from './ImageToImageTabParameters';
import TextToImageTabMain from '../TextToImage/TextToImageTabMain';
import { ImperativePanelGroupHandle } from 'react-resizable-panels';
import ParametersPinnedWrapper from '../../ParametersPinnedWrapper';
import InitialImageDisplay from 'features/parameters/components/Parameters/ImageToImage/InitialImageDisplay'; import InitialImageDisplay from 'features/parameters/components/Parameters/ImageToImage/InitialImageDisplay';
import { memo, useCallback, useRef } from 'react';
import {
ImperativePanelGroupHandle,
Panel,
PanelGroup,
} from 'react-resizable-panels';
import ParametersPinnedWrapper from '../../ParametersPinnedWrapper';
import ResizeHandle from '../ResizeHandle';
import TextToImageTabMain from '../TextToImage/TextToImageTabMain';
import ImageToImageTabParameters from './ImageToImageTabParameters';
const ImageToImageTab = () => { const ImageToImageTab = () => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
@ -23,7 +26,7 @@ const ImageToImageTab = () => {
}, []); }, []);
return ( return (
<Flex sx={{ gap: 4, w: 'full', h: 'full' }}> <Flex sx={{ gap: 2, w: 'full', h: 'full' }}>
<ParametersPinnedWrapper> <ParametersPinnedWrapper>
<ImageToImageTabParameters /> <ImageToImageTabParameters />
</ParametersPinnedWrapper> </ParametersPinnedWrapper>

View File

@ -1,12 +1,12 @@
import { Flex } from '@chakra-ui/react'; import { Flex } from '@chakra-ui/react';
import { memo } from 'react'; import { memo } from 'react';
import ParametersPinnedWrapper from '../../ParametersPinnedWrapper';
import TextToImageTabMain from './TextToImageTabMain'; import TextToImageTabMain from './TextToImageTabMain';
import TextToImageTabParameters from './TextToImageTabParameters'; import TextToImageTabParameters from './TextToImageTabParameters';
import ParametersPinnedWrapper from '../../ParametersPinnedWrapper';
const TextToImageTab = () => { const TextToImageTab = () => {
return ( return (
<Flex sx={{ gap: 4, w: 'full', h: 'full' }}> <Flex sx={{ gap: 2, w: 'full', h: 'full' }}>
<ParametersPinnedWrapper> <ParametersPinnedWrapper>
<TextToImageTabParameters /> <TextToImageTabParameters />
</ParametersPinnedWrapper> </ParametersPinnedWrapper>

View File

@ -1,12 +1,12 @@
import { Flex } from '@chakra-ui/react'; import { Flex } from '@chakra-ui/react';
import { memo } from 'react'; import { memo } from 'react';
import ParametersPinnedWrapper from '../../ParametersPinnedWrapper';
import UnifiedCanvasContent from './UnifiedCanvasContent'; import UnifiedCanvasContent from './UnifiedCanvasContent';
import UnifiedCanvasParameters from './UnifiedCanvasParameters'; import UnifiedCanvasParameters from './UnifiedCanvasParameters';
import ParametersPinnedWrapper from '../../ParametersPinnedWrapper';
const UnifiedCanvasTab = () => { const UnifiedCanvasTab = () => {
return ( return (
<Flex sx={{ gap: 4, w: 'full', h: 'full' }}> <Flex sx={{ gap: 2, w: 'full', h: 'full' }}>
<ParametersPinnedWrapper> <ParametersPinnedWrapper>
<UnifiedCanvasParameters /> <UnifiedCanvasParameters />
</ParametersPinnedWrapper> </ParametersPinnedWrapper>