import { Tab, TabPanel, TabPanels, Tabs, Tooltip } from '@chakra-ui/react'; import _ from 'lodash'; import React, { ReactElement } from 'react'; import { useHotkeys } from 'react-hotkeys-hook'; import { RootState } from 'app/store'; import { useAppDispatch, useAppSelector } from 'app/storeHooks'; import NodesWIP from 'common/components/WorkInProgress/NodesWIP'; import { PostProcessingWIP } from 'common/components/WorkInProgress/PostProcessingWIP'; import ImageToImageIcon from 'common/icons/ImageToImageIcon'; import NodesIcon from 'common/icons/NodesIcon'; import PostprocessingIcon from 'common/icons/PostprocessingIcon'; import TextToImageIcon from 'common/icons/TextToImageIcon'; import { setActiveTab, setIsLightBoxOpen, } from 'features/options/store/optionsSlice'; import ImageToImageWorkarea from './ImageToImage'; import TextToImageWorkarea from './TextToImage'; import Lightbox from 'features/lightbox/components/Lightbox'; import UnifiedCanvasWorkarea from './UnifiedCanvas/UnifiedCanvasWorkarea'; import UnifiedCanvasIcon from 'common/icons/UnifiedCanvasIcon'; import TrainingWIP from 'common/components/WorkInProgress/Training'; import TrainingIcon from 'common/icons/TrainingIcon'; import { InvokeTabName } from 'features/tabs/tabMap'; export interface InvokeTabInfo { title: ReactElement; workarea: ReactElement; tooltip: string; } export const tabDict: Record = { txt2img: { title: , workarea: , tooltip: 'Text To Image', }, img2img: { title: , workarea: , tooltip: 'Image To Image', }, unifiedCanvas: { title: , workarea: , tooltip: 'Unified Canvas', }, nodes: { title: , workarea: , tooltip: 'Nodes', }, postprocess: { title: , workarea: , tooltip: 'Post Processing', }, training: { title: , workarea: , tooltip: 'Training', }, }; export default function InvokeTabs() { const activeTab = useAppSelector( (state: RootState) => state.options.activeTab ); const isLightBoxOpen = useAppSelector( (state: RootState) => state.options.isLightBoxOpen ); const dispatch = useAppDispatch(); useHotkeys('1', () => { dispatch(setActiveTab(0)); }); useHotkeys('2', () => { dispatch(setActiveTab(1)); }); useHotkeys('3', () => { dispatch(setActiveTab(2)); }); useHotkeys('4', () => { dispatch(setActiveTab(3)); }); useHotkeys('5', () => { dispatch(setActiveTab(4)); }); useHotkeys('6', () => { dispatch(setActiveTab(5)); }); // Lightbox Hotkey useHotkeys( 'z', () => { dispatch(setIsLightBoxOpen(!isLightBoxOpen)); }, [isLightBoxOpen] ); const renderTabs = () => { const tabsToRender: ReactElement[] = []; Object.keys(tabDict).forEach((key) => { tabsToRender.push( {tabDict[key as keyof typeof tabDict].title} ); }); return tabsToRender; }; const renderTabPanels = () => { const tabPanelsToRender: ReactElement[] = []; Object.keys(tabDict).forEach((key) => { tabPanelsToRender.push( {tabDict[key as keyof typeof tabDict].workarea} ); }); return tabPanelsToRender; }; return ( { dispatch(setActiveTab(index)); }} >
{renderTabs()}
{isLightBoxOpen ? : renderTabPanels()}
); }