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

168 lines
4.8 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';
2023-08-09 00:53:06 +00:00
import type { PropsType } from './StoriesTab';
import { StoriesTab } from './StoriesTab';
2022-03-04 21:14:52 +00:00
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 {
2023-08-09 00:53:06 +00:00
title: 'Components/StoriesTab',
component: StoriesTab,
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,
},
maxAttachmentSizeInKb: {
defaultValue: 100 * 1024,
},
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 },
retryMessageSend: { action: true },
2022-07-01 00:52:03 +00:00
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-11-18 00:45:19 +00:00
// eslint-disable-next-line react/function-component-definition
2023-08-09 00:53:06 +00:00
const Template: Story<PropsType> = args => <StoriesTab {...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,
}),
],
};