signal-desktop/ts/components/Stories.stories.tsx

164 lines
4.7 KiB
TypeScript
Raw Normal View History

2022-03-04 21:14:52 +00:00
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2022-06-17 00:48:57 +00:00
import type { Meta, Story } from '@storybook/react';
2022-03-04 21:14:52 +00:00
import React from 'react';
import type { PropsType } from './Stories';
import { Stories } from './Stories';
import enMessages from '../../_locales/en/messages.json';
import { setupI18n } from '../util/setupI18n';
import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation';
import {
2022-07-01 00:52:03 +00:00
getFakeMyStory,
getFakeStory,
} from '../test-both/helpers/getFakeStory';
2022-03-04 21:14:52 +00:00
import * as durations from '../util/durations';
const i18n = setupI18n('en', enMessages);
2022-06-07 00:48:02 +00:00
export default {
title: 'Components/Stories',
2022-06-17 00:48:57 +00:00
component: Stories,
2022-07-01 00:52:03 +00:00
argTypes: {
deleteStoryForEveryone: { action: true },
getPreferredBadge: { action: true },
2022-07-01 00:52:03 +00:00
hiddenStories: {
defaultValue: [],
},
i18n: {
defaultValue: i18n,
},
2022-07-06 19:06:20 +00:00
me: {
defaultValue: getDefaultConversation(),
},
2022-07-01 00:52:03 +00:00
myStories: {
defaultValue: [],
},
onForwardStory: { action: true },
onSaveStory: { action: true },
ourConversationId: {
defaultValue: getDefaultConversation().id,
},
preferredWidthFromStorage: {
defaultValue: 380,
},
queueStoryDownload: { action: true },
renderStoryCreator: { action: true },
renderStoryViewer: { action: true },
showConversation: { action: true },
showStoriesSettings: { action: true },
showToast: { action: true },
2022-07-01 00:52:03 +00:00
stories: {
defaultValue: [],
},
toggleHideStories: { action: true },
toggleStoriesView: { action: true },
2022-07-06 19:06:20 +00:00
viewUserStories: { action: true },
viewStory: { action: true },
2022-07-01 00:52:03 +00:00
},
2022-06-17 00:48:57 +00:00
} as Meta;
2022-03-04 21:14:52 +00:00
2022-07-01 00:52:03 +00:00
const Template: Story<PropsType> = args => <Stories {...args} />;
2022-03-04 21:14:52 +00:00
2022-07-01 00:52:03 +00:00
export const Blank = Template.bind({});
Blank.args = {};
2022-03-29 01:10:08 +00:00
2022-07-01 00:52:03 +00:00
export const Many = Template.bind({});
Many.args = {
2022-03-04 21:14:52 +00:00
stories: [
2022-07-01 00:52:03 +00:00
getFakeStory({
attachmentUrl: '/fixtures/tina-rolf-269345-unsplash.jpg',
2022-03-04 21:14:52 +00:00
timestamp: Date.now() - 2 * durations.MINUTE,
}),
2022-07-01 00:52:03 +00:00
getFakeStory({
attachmentUrl: '/fixtures/koushik-chowdavarapu-105425-unsplash.jpg',
2022-03-04 21:14:52 +00:00
timestamp: Date.now() - 5 * durations.MINUTE,
}),
2022-07-01 00:52:03 +00:00
getFakeStory({
attachmentUrl: '/fixtures/nathan-anderson-316188-unsplash.jpg',
2022-04-15 00:08:46 +00:00
group: getDefaultConversation({ title: 'BBQ in the park' }),
2022-03-04 21:14:52 +00:00
timestamp: Date.now() - 65 * durations.MINUTE,
}),
2022-07-01 00:52:03 +00:00
getFakeStory({
attachmentUrl: '/fixtures/snow.jpg',
2022-03-04 21:14:52 +00:00
timestamp: Date.now() - 92 * durations.MINUTE,
}),
2022-07-01 00:52:03 +00:00
getFakeStory({
attachmentUrl: '/fixtures/kitten-1-64-64.jpg',
2022-03-04 21:14:52 +00:00
timestamp: Date.now() - 164 * durations.MINUTE,
}),
2022-07-01 00:52:03 +00:00
getFakeStory({
attachmentUrl: '/fixtures/kitten-2-64-64.jpg',
2022-04-15 00:08:46 +00:00
group: getDefaultConversation({ title: 'Breaking Signal for Science' }),
2022-03-04 21:14:52 +00:00
timestamp: Date.now() - 380 * durations.MINUTE,
}),
2022-07-01 00:52:03 +00:00
getFakeStory({
attachmentUrl: '/fixtures/kitten-3-64-64.jpg',
2022-03-04 21:14:52 +00:00
timestamp: Date.now() - 421 * durations.MINUTE,
}),
],
2022-07-01 00:52:03 +00:00
};
2022-06-17 00:48:57 +00:00
2022-07-01 00:52:03 +00:00
export const HiddenStories = Template.bind({});
HiddenStories.args = {
hiddenStories: [
getFakeStory({
attachmentUrl: '/fixtures/kitten-1-64-64.jpg',
timestamp: Date.now() - 164 * durations.MINUTE,
}),
getFakeStory({
attachmentUrl: '/fixtures/kitten-2-64-64.jpg',
group: getDefaultConversation({ title: 'Breaking Signal for Science' }),
timestamp: Date.now() - 380 * durations.MINUTE,
}),
getFakeStory({
attachmentUrl: '/fixtures/kitten-3-64-64.jpg',
timestamp: Date.now() - 421 * durations.MINUTE,
}),
],
stories: [
getFakeStory({
attachmentUrl: '/fixtures/tina-rolf-269345-unsplash.jpg',
timestamp: Date.now() - 2 * durations.MINUTE,
}),
getFakeStory({
attachmentUrl: '/fixtures/snow.jpg',
timestamp: Date.now() - 92 * durations.MINUTE,
}),
],
2022-06-17 00:48:57 +00:00
};
2022-07-01 00:52:03 +00:00
export const MyStories = Template.bind({});
MyStories.args = {
myStories: [
getFakeMyStory(undefined, 'BFF'),
getFakeMyStory(undefined, 'The Fun Group'),
],
hiddenStories: [
getFakeStory({
attachmentUrl: '/fixtures/kitten-1-64-64.jpg',
timestamp: Date.now() - 164 * durations.MINUTE,
}),
getFakeStory({
attachmentUrl: '/fixtures/kitten-2-64-64.jpg',
group: getDefaultConversation({ title: 'Breaking Signal for Science' }),
timestamp: Date.now() - 380 * durations.MINUTE,
}),
getFakeStory({
attachmentUrl: '/fixtures/kitten-3-64-64.jpg',
timestamp: Date.now() - 421 * durations.MINUTE,
}),
],
stories: [
getFakeStory({
attachmentUrl: '/fixtures/tina-rolf-269345-unsplash.jpg',
timestamp: Date.now() - 2 * durations.MINUTE,
}),
getFakeStory({
attachmentUrl: '/fixtures/snow.jpg',
timestamp: Date.now() - 92 * durations.MINUTE,
}),
],
};