New sticker creator button

This commit is contained in:
Fedor Indutny 2023-02-27 14:34:43 -08:00 committed by GitHub
parent 85adb39d31
commit fad0529080
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 442 additions and 11 deletions

View file

@ -10,11 +10,13 @@ import { ModalHost } from './ModalHost';
import { ModalPage } from './Modal';
import type { Theme } from '../util/theme';
import { useAnimated } from '../hooks/useAnimated';
import { Spinner } from './Spinner';
export type ActionSpec = {
text: string;
action: () => unknown;
style?: 'affirmative' | 'negative';
autoClose?: boolean;
};
export type OwnProps = Readonly<{
@ -22,6 +24,7 @@ export type OwnProps = Readonly<{
dialogName: string;
cancelButtonVariant?: ButtonVariant;
cancelText?: string;
isSpinning?: boolean;
children?: React.ReactNode;
hasXButton?: boolean;
i18n: LocalizerType;
@ -65,6 +68,7 @@ export const ConfirmationDialog = React.memo(function ConfirmationDialogInner({
children,
hasXButton,
i18n,
isSpinning,
moduleClassName,
noMouseClose,
noDefaultCancelButton,
@ -99,7 +103,7 @@ export const ConfirmationDialog = React.memo(function ConfirmationDialogInner({
const footer = (
<>
{!noDefaultCancelButton ? (
{!isSpinning && !noDefaultCancelButton ? (
<Button
onClick={handleCancel}
ref={focusRef}
@ -114,14 +118,25 @@ export const ConfirmationDialog = React.memo(function ConfirmationDialogInner({
{actions.map((action, i) => (
<Button
key={action.text}
disabled={isSpinning}
onClick={() => {
action.action();
close();
if (action.autoClose !== false) {
close();
}
}}
data-action={i}
variant={getButtonVariant(action.style)}
>
{action.text}
{isSpinning ? (
<Spinner
size="22px"
svgSize="small"
direction="on-primary-button"
/>
) : (
action.text
)}
</Button>
))}
</>