signal-desktop/ts/components/conversation/ReactionViewer.stories.tsx

222 lines
5.2 KiB
TypeScript
Raw Normal View History

2021-05-07 22:21:10 +00:00
// Copyright 2020-2021 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
2020-08-26 14:28:50 +00:00
import * as React from 'react';
import { action } from '@storybook/addon-actions';
import { storiesOf } from '@storybook/react';
import { Props, ReactionViewer } from './ReactionViewer';
2021-09-18 00:30:08 +00:00
import { setupI18n } from '../../util/setupI18n';
2020-08-26 14:28:50 +00:00
import enMessages from '../../../_locales/en/messages.json';
2021-05-07 22:21:10 +00:00
import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation';
2020-09-14 19:51:27 +00:00
2020-08-26 14:28:50 +00:00
const i18n = setupI18n('en', enMessages);
const story = storiesOf('Components/Conversation/ReactionViewer', module);
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
i18n,
onClose: action('onClose'),
pickedReaction: overrideProps.pickedReaction,
reactions: overrideProps.reactions || [],
style: overrideProps.style,
});
story.add('All Reactions', () => {
const props = createProps({
reactions: [
{
emoji: '❤️',
timestamp: 1,
2021-05-07 22:21:10 +00:00
from: getDefaultConversation({
2020-08-26 14:28:50 +00:00
id: '+14155552671',
phoneNumber: '+14155552671',
profileName: 'Ameila Briggs',
title: 'Amelia',
2021-05-07 22:21:10 +00:00
}),
2020-08-26 14:28:50 +00:00
},
{
emoji: '❤️',
timestamp: 2,
2021-05-07 22:21:10 +00:00
from: getDefaultConversation({
2020-08-26 14:28:50 +00:00
id: '+14155552672',
name: 'Adam Burrel',
title: 'Adam',
2021-05-07 22:21:10 +00:00
}),
2020-08-26 14:28:50 +00:00
},
{
emoji: '❤️',
timestamp: 3,
2021-05-07 22:21:10 +00:00
from: getDefaultConversation({
2020-08-26 14:28:50 +00:00
id: '+14155552673',
name: 'Rick Owens',
title: 'Rick',
2021-05-07 22:21:10 +00:00
}),
2020-08-26 14:28:50 +00:00
},
{
emoji: '❤️',
timestamp: 4,
2021-05-07 22:21:10 +00:00
from: getDefaultConversation({
2020-08-26 14:28:50 +00:00
id: '+14155552674',
name: 'Bojack Horseman',
title: 'Bojack',
2021-05-07 22:21:10 +00:00
}),
2020-08-26 14:28:50 +00:00
},
{
emoji: '👍',
timestamp: 9,
2021-05-07 22:21:10 +00:00
from: getDefaultConversation({
2020-08-26 14:28:50 +00:00
id: '+14155552678',
phoneNumber: '+14155552678',
profileName: 'Adam Burrel',
title: 'Adam',
2021-05-07 22:21:10 +00:00
}),
2020-08-26 14:28:50 +00:00
},
{
emoji: '👎',
timestamp: 10,
2021-05-07 22:21:10 +00:00
from: getDefaultConversation({
2020-08-26 14:28:50 +00:00
id: '+14155552673',
name: 'Rick Owens',
title: 'Rick',
2021-05-07 22:21:10 +00:00
}),
2020-08-26 14:28:50 +00:00
},
{
emoji: '😂',
timestamp: 11,
2021-05-07 22:21:10 +00:00
from: getDefaultConversation({
2020-08-26 14:28:50 +00:00
id: '+14155552674',
name: 'Bojack Horseman',
title: 'Bojack',
2021-05-07 22:21:10 +00:00
}),
2020-08-26 14:28:50 +00:00
},
{
emoji: '😮',
timestamp: 12,
2021-05-07 22:21:10 +00:00
from: getDefaultConversation({
2020-08-26 14:28:50 +00:00
id: '+14155552675',
name: 'Cayce Pollard',
title: 'Cayce',
2021-05-07 22:21:10 +00:00
}),
2020-08-26 14:28:50 +00:00
},
{
emoji: '😢',
timestamp: 13,
2021-05-07 22:21:10 +00:00
from: getDefaultConversation({
2020-08-26 14:28:50 +00:00
id: '+14155552676',
name: 'Foo McBarrington',
title: 'Foo',
2021-05-07 22:21:10 +00:00
}),
2020-08-26 14:28:50 +00:00
},
{
emoji: '😡',
timestamp: 14,
2021-05-07 22:21:10 +00:00
from: getDefaultConversation({
2020-08-26 14:28:50 +00:00
id: '+14155552676',
name: 'Foo McBarrington',
title: 'Foo',
2021-05-07 22:21:10 +00:00
}),
2020-08-26 14:28:50 +00:00
},
],
});
return <ReactionViewer {...props} />;
});
story.add('Picked Reaction', () => {
const props = createProps({
pickedReaction: '❤️',
reactions: [
{
emoji: '❤️',
2021-05-07 22:21:10 +00:00
from: getDefaultConversation({
2020-08-26 14:28:50 +00:00
id: '+14155552671',
name: 'Amelia Briggs',
isMe: true,
title: 'Amelia',
2021-05-07 22:21:10 +00:00
}),
2020-08-26 14:28:50 +00:00
timestamp: Date.now(),
},
{
emoji: '👍',
2021-05-07 22:21:10 +00:00
from: getDefaultConversation({
2020-08-26 14:28:50 +00:00
id: '+14155552671',
phoneNumber: '+14155552671',
profileName: 'Joel Ferrari',
title: 'Joel',
2021-05-07 22:21:10 +00:00
}),
2020-08-26 14:28:50 +00:00
timestamp: Date.now(),
},
],
});
return <ReactionViewer {...props} />;
});
story.add('Picked Missing Reaction', () => {
const props = createProps({
pickedReaction: '😡',
reactions: [
{
emoji: '❤️',
2021-05-07 22:21:10 +00:00
from: getDefaultConversation({
2020-08-26 14:28:50 +00:00
id: '+14155552671',
name: 'Amelia Briggs',
isMe: true,
title: 'Amelia',
2021-05-07 22:21:10 +00:00
}),
2020-08-26 14:28:50 +00:00
timestamp: Date.now(),
},
{
emoji: '👍',
2021-05-07 22:21:10 +00:00
from: getDefaultConversation({
2020-08-26 14:28:50 +00:00
id: '+14155552671',
phoneNumber: '+14155552671',
profileName: 'Joel Ferrari',
title: 'Joel',
2021-05-07 22:21:10 +00:00
}),
2020-08-26 14:28:50 +00:00
timestamp: Date.now(),
},
],
});
return <ReactionViewer {...props} />;
});
2020-10-02 20:05:09 +00:00
const skinTones = [
'\u{1F3FB}',
'\u{1F3FC}',
'\u{1F3FD}',
'\u{1F3FE}',
'\u{1F3FF}',
];
const thumbsUpHands = skinTones.map(skinTone => `👍${skinTone}`);
const okHands = skinTones.map(skinTone => `👌${skinTone}`).reverse();
const createReaction = (
emoji: string,
name: string,
timestamp = Date.now()
) => ({
emoji,
2021-05-07 22:21:10 +00:00
from: getDefaultConversation({
2020-10-02 20:05:09 +00:00
id: '+14155552671',
name,
title: name,
2021-05-07 22:21:10 +00:00
}),
2020-10-02 20:05:09 +00:00
timestamp,
});
story.add('Reaction Skin Tones', () => {
const props = createProps({
pickedReaction: '😡',
reactions: [
...thumbsUpHands.map((emoji, n) =>
createReaction(emoji, `Thumbs Up ${n + 1}`, Date.now() + n * 1000)
),
...okHands.map((emoji, n) =>
createReaction(emoji, `Ok Hand ${n + 1}`, Date.now() + n * 1000)
),
],
});
return <ReactionViewer {...props} />;
});