signal-desktop/ts/components/stickers/StickerPreviewModal.stories.tsx

135 lines
3.3 KiB
TypeScript
Raw Normal View History

2020-10-30 20:34:04 +00:00
// Copyright 2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2020-04-06 16:48:58 +00:00
import * as React from 'react';
2020-09-14 22:14:03 +00:00
import { action } from '@storybook/addon-actions';
import type { Meta } from '@storybook/react';
import type { Props } from './StickerPreviewModal';
2020-04-06 16:48:58 +00:00
import { StickerPreviewModal } from './StickerPreviewModal';
2021-09-18 00:30:08 +00:00
import { setupI18n } from '../../util/setupI18n';
2020-04-06 16:48:58 +00:00
import enMessages from '../../../_locales/en/messages.json';
import {
landscapeGreenUrl,
portraitTealUrl,
squareStickerUrl,
} from '../../storybook/Fixtures';
const i18n = setupI18n('en', enMessages);
2022-06-07 00:48:02 +00:00
export default {
title: 'Components/Stickers/StickerPreviewModal',
argTypes: {},
args: {},
} satisfies Meta<Props>;
const abeSticker = {
id: -1,
emoji: '🎩',
url: squareStickerUrl,
packId: 'abe',
};
const wideSticker = {
id: -2,
emoji: '🤯',
url: landscapeGreenUrl,
packId: 'wide',
};
const tallSticker = {
id: -3,
emoji: '🔥',
url: portraitTealUrl,
packId: 'tall',
};
2022-11-18 00:45:19 +00:00
export function Full(): JSX.Element {
const title = 'Foo';
const author = 'Foo McBarrington';
2020-04-06 16:48:58 +00:00
const pack = {
id: 'foo',
key: 'foo',
lastUsed: Date.now(),
cover: abeSticker,
title,
isBlessed: true,
author,
2020-09-14 22:14:03 +00:00
status: 'downloaded' as const,
2020-04-06 16:48:58 +00:00
stickerCount: 101,
stickers: [
wideSticker,
tallSticker,
...Array(101)
.fill(0)
.map((_n, id) => ({ ...abeSticker, id })),
],
};
return (
<StickerPreviewModal
closeStickerPackPreview={action('closeStickerPackPreview')}
2022-12-14 00:06:15 +00:00
onClose={action('onClose')}
2020-04-06 16:48:58 +00:00
installStickerPack={action('installStickerPack')}
uninstallStickerPack={action('uninstallStickerPack')}
downloadStickerPack={action('downloadStickerPack')}
i18n={i18n}
pack={pack}
/>
);
2022-11-18 00:45:19 +00:00
}
2022-11-18 00:45:19 +00:00
export function JustFourStickers(): JSX.Element {
const title = 'Foo';
const author = 'Foo McBarrington';
const pack = {
id: 'foo',
key: 'foo',
lastUsed: Date.now(),
cover: abeSticker,
title,
isBlessed: true,
author,
status: 'downloaded' as const,
stickerCount: 101,
stickers: [abeSticker, abeSticker, abeSticker, abeSticker],
};
return (
<StickerPreviewModal
closeStickerPackPreview={action('closeStickerPackPreview')}
installStickerPack={action('installStickerPack')}
uninstallStickerPack={action('uninstallStickerPack')}
downloadStickerPack={action('downloadStickerPack')}
i18n={i18n}
pack={pack}
/>
);
2022-11-18 00:45:19 +00:00
}
2022-11-18 00:45:19 +00:00
export function InitialDownload(): JSX.Element {
return (
<StickerPreviewModal
closeStickerPackPreview={action('closeStickerPackPreview')}
installStickerPack={action('installStickerPack')}
uninstallStickerPack={action('uninstallStickerPack')}
downloadStickerPack={action('downloadStickerPack')}
i18n={i18n}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
pack={{} as any}
/>
);
2022-11-18 00:45:19 +00:00
}
2022-11-18 00:45:19 +00:00
export function PackDeleted(): JSX.Element {
return (
<StickerPreviewModal
closeStickerPackPreview={action('closeStickerPackPreview')}
installStickerPack={action('installStickerPack')}
uninstallStickerPack={action('uninstallStickerPack')}
downloadStickerPack={action('downloadStickerPack')}
i18n={i18n}
pack={undefined}
/>
);
2022-11-18 00:45:19 +00:00
}