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

67 lines
1.7 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
import * as React from 'react';
import { action } from '@storybook/addon-actions';
import { boolean, text } from '@storybook/addon-knobs';
2021-09-18 00:30:08 +00:00
import { setupI18n } from '../../util/setupI18n';
import enMessages from '../../../_locales/en/messages.json';
import type { ContactType, Props } from './SafetyNumberNotification';
import { SafetyNumberNotification } from './SafetyNumberNotification';
const i18n = setupI18n('en', enMessages);
const createContact = (props: Partial<ContactType>): ContactType => ({
id: '',
title: text('contact title', props.title || ''),
});
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
i18n,
contact: overrideProps.contact || ({} as ContactType),
isGroup: boolean('isGroup', overrideProps.isGroup || false),
toggleSafetyNumberModal: action('toggleSafetyNumberModal'),
});
2022-06-07 00:48:02 +00:00
export default {
title: 'Components/Conversation/SafetyNumberNotification',
};
2022-11-18 00:45:19 +00:00
export function GroupConversation(): JSX.Element {
const props = createProps({
isGroup: true,
contact: createContact({
title: 'Mr. Fire',
}),
});
return <SafetyNumberNotification {...props} />;
2022-11-18 00:45:19 +00:00
}
2022-11-18 00:45:19 +00:00
export function DirectConversation(): JSX.Element {
const props = createProps({
isGroup: false,
contact: createContact({
title: 'Mr. Fire',
}),
});
return <SafetyNumberNotification {...props} />;
2022-11-18 00:45:19 +00:00
}
2022-11-18 00:45:19 +00:00
export function LongNameInGroup(): JSX.Element {
const props = createProps({
isGroup: true,
contact: createContact({
title: '🐈‍⬛🍕🎂'.repeat(50),
}),
});
return <SafetyNumberNotification {...props} />;
2022-11-18 00:45:19 +00:00
}
2022-06-07 00:48:02 +00:00
LongNameInGroup.story = {
name: 'Long name in group',
};