2020-10-30 20:34:04 +00:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-08-26 18:10:02 +00:00
|
|
|
import * as React from 'react';
|
|
|
|
import { action } from '@storybook/addon-actions';
|
|
|
|
|
2021-09-18 00:30:08 +00:00
|
|
|
import { setupI18n } from '../../util/setupI18n';
|
2020-08-26 18:10:02 +00:00
|
|
|
import enMessages from '../../../_locales/en/messages.json';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { Props } from './StickerManager';
|
|
|
|
import { StickerManager } from './StickerManager';
|
2020-08-26 18:10:02 +00:00
|
|
|
import { createPack, sticker1, sticker2 } from './StickerPicker.stories';
|
|
|
|
|
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export default {
|
|
|
|
title: 'Components/Stickers/StickerManager',
|
|
|
|
};
|
2020-08-26 18:10:02 +00:00
|
|
|
|
|
|
|
const receivedPacks = [
|
|
|
|
createPack({ id: 'received-pack-1', status: 'downloaded' }, sticker1),
|
|
|
|
createPack({ id: 'received-pack-2', status: 'downloaded' }, sticker2),
|
|
|
|
];
|
|
|
|
|
|
|
|
const installedPacks = [
|
|
|
|
createPack({ id: 'installed-pack-1', status: 'installed' }, sticker1),
|
|
|
|
createPack({ id: 'installed-pack-2', status: 'installed' }, sticker2),
|
|
|
|
];
|
|
|
|
|
|
|
|
const blessedPacks = [
|
|
|
|
createPack(
|
|
|
|
{ id: 'blessed-pack-1', status: 'downloaded', isBlessed: true },
|
|
|
|
sticker1
|
|
|
|
),
|
|
|
|
createPack(
|
|
|
|
{ id: 'blessed-pack-2', status: 'downloaded', isBlessed: true },
|
|
|
|
sticker2
|
|
|
|
),
|
|
|
|
];
|
|
|
|
|
|
|
|
const knownPacks = [
|
|
|
|
createPack({ id: 'known-pack-1', status: 'known' }, sticker1),
|
|
|
|
createPack({ id: 'known-pack-2', status: 'known' }, sticker2),
|
|
|
|
];
|
|
|
|
|
|
|
|
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
|
|
|
|
blessedPacks: overrideProps.blessedPacks || [],
|
2022-12-14 00:06:15 +00:00
|
|
|
closeStickerPackPreview: action('closeStickerPackPreview'),
|
2020-08-26 18:10:02 +00:00
|
|
|
downloadStickerPack: action('downloadStickerPack'),
|
|
|
|
i18n,
|
|
|
|
installStickerPack: action('installStickerPack'),
|
|
|
|
installedPacks: overrideProps.installedPacks || [],
|
|
|
|
knownPacks: overrideProps.knownPacks || [],
|
|
|
|
receivedPacks: overrideProps.receivedPacks || [],
|
|
|
|
uninstallStickerPack: action('uninstallStickerPack'),
|
|
|
|
});
|
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function Full(): JSX.Element {
|
2020-08-26 18:10:02 +00:00
|
|
|
const props = createProps({ installedPacks, receivedPacks, blessedPacks });
|
|
|
|
|
|
|
|
return <StickerManager {...props} />;
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2020-08-26 18:10:02 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function InstalledPacks(): JSX.Element {
|
2020-08-26 18:10:02 +00:00
|
|
|
const props = createProps({ installedPacks });
|
|
|
|
|
|
|
|
return <StickerManager {...props} />;
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2020-08-26 18:10:02 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function ReceivedPacks(): JSX.Element {
|
2020-08-26 18:10:02 +00:00
|
|
|
const props = createProps({ receivedPacks });
|
|
|
|
|
|
|
|
return <StickerManager {...props} />;
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2020-08-26 18:10:02 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function InstalledKnownPacks(): JSX.Element {
|
2020-08-26 18:10:02 +00:00
|
|
|
const props = createProps({ installedPacks, knownPacks });
|
|
|
|
|
|
|
|
return <StickerManager {...props} />;
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
|
|
|
InstalledKnownPacks.story = {
|
|
|
|
name: 'Installed + Known Packs',
|
|
|
|
};
|
2020-08-26 18:10:02 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function Empty(): JSX.Element {
|
2020-08-26 18:10:02 +00:00
|
|
|
const props = createProps();
|
|
|
|
|
|
|
|
return <StickerManager {...props} />;
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|