mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Rough draft of this. Not happy with the styling but it's clearer than having them look just like buttons.
57 lines
1.7 KiB
TypeScript
57 lines
1.7 KiB
TypeScript
import { createSelector } from '@reduxjs/toolkit';
|
|
import { IoMdOptions } from 'react-icons/io';
|
|
import { RootState, useAppDispatch, useAppSelector } from '../../app/store';
|
|
import IAIIconButton from '../../common/components/IAIIconButton';
|
|
import {
|
|
OptionsState,
|
|
setShouldShowOptionsPanel,
|
|
} from '../options/optionsSlice';
|
|
import CancelButton from '../options/ProcessButtons/CancelButton';
|
|
import InvokeButton from '../options/ProcessButtons/InvokeButton';
|
|
import _ from 'lodash';
|
|
import LoopbackButton from '../options/ProcessButtons/Loopback';
|
|
|
|
const canInvokeSelector = createSelector(
|
|
(state: RootState) => state.options,
|
|
|
|
(options: OptionsState) => {
|
|
const { shouldPinOptionsPanel, shouldShowOptionsPanel } = options;
|
|
return {
|
|
shouldShowProcessButtons:
|
|
!shouldPinOptionsPanel || !shouldShowOptionsPanel,
|
|
};
|
|
},
|
|
{ memoizeOptions: { resultEqualityCheck: _.isEqual } }
|
|
);
|
|
|
|
const FloatingOptionsPanelButtons = () => {
|
|
const dispatch = useAppDispatch();
|
|
const { shouldShowProcessButtons } = useAppSelector(canInvokeSelector);
|
|
|
|
const handleShowOptionsPanel = () => {
|
|
dispatch(setShouldShowOptionsPanel(true));
|
|
};
|
|
|
|
return (
|
|
<div className="show-hide-button-options">
|
|
<IAIIconButton
|
|
tooltip="Show Options Panel (O)"
|
|
tooltipProps={{ placement: 'top' }}
|
|
aria-label="Show Options Panel"
|
|
onClick={handleShowOptionsPanel}
|
|
>
|
|
<IoMdOptions />
|
|
</IAIIconButton>
|
|
{shouldShowProcessButtons && (
|
|
<>
|
|
<InvokeButton iconButton />
|
|
<LoopbackButton />
|
|
<CancelButton />
|
|
</>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default FloatingOptionsPanelButtons;
|