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

198 lines
5 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-07-24 01:35:32 +00:00
import * as React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { gifUrl } from '../storybook/Fixtures';
import { setup as setupI18n } from '../../js/modules/i18n';
2020-09-12 00:46:52 +00:00
import enMessages from '../../_locales/en/messages.json';
2020-07-24 01:35:32 +00:00
import { ContactListItem } from './ContactListItem';
2021-08-06 00:17:05 +00:00
import { getRandomColor } from '../test-both/helpers/getRandomColor';
2020-07-24 01:35:32 +00:00
const i18n = setupI18n('en', enMessages);
const onClick = action('onClick');
storiesOf('Components/ContactListItem', module)
.add("It's me!", () => {
return (
<ContactListItem
type="direct"
acceptedMessageRequest
2020-07-24 01:35:32 +00:00
i18n={i18n}
isMe
title="Someone 🔥 Somewhere"
name="Someone 🔥 Somewhere"
phoneNumber="(202) 555-0011"
profileName="🔥Flames🔥"
2021-05-07 22:21:10 +00:00
sharedGroupNames={[]}
2020-07-24 01:35:32 +00:00
avatarPath={gifUrl}
onClick={onClick}
/>
);
})
.add('With name and profile (note vertical spacing)', () => {
return (
<div>
<ContactListItem
type="direct"
acceptedMessageRequest
2020-07-24 01:35:32 +00:00
i18n={i18n}
2021-05-07 22:21:10 +00:00
isMe={false}
2020-07-24 01:35:32 +00:00
title="Someone 🔥 Somewhere"
name="Someone 🔥 Somewhere"
phoneNumber="(202) 555-0011"
profileName="🔥Flames🔥"
2021-05-07 22:21:10 +00:00
sharedGroupNames={[]}
2021-01-26 01:01:19 +00:00
about="👍 Free to chat"
2020-07-24 01:35:32 +00:00
avatarPath={gifUrl}
onClick={onClick}
/>
<ContactListItem
type="direct"
acceptedMessageRequest
2020-07-24 01:35:32 +00:00
i18n={i18n}
2021-05-07 22:21:10 +00:00
isMe={false}
2020-07-24 01:35:32 +00:00
title="Another ❄️ Yes"
name="Another ❄️ Yes"
phoneNumber="(202) 555-0011"
profileName="❄Ice❄"
2021-05-07 22:21:10 +00:00
sharedGroupNames={[]}
2021-01-26 01:01:19 +00:00
about="🙏 Be kind"
2020-07-24 01:35:32 +00:00
avatarPath={gifUrl}
onClick={onClick}
/>
</div>
);
})
2020-09-09 02:25:05 +00:00
.add('With name and profile, admin', () => {
return (
<ContactListItem
type="direct"
acceptedMessageRequest
2020-09-09 02:25:05 +00:00
i18n={i18n}
2021-05-07 22:21:10 +00:00
isMe={false}
2020-09-09 02:25:05 +00:00
isAdmin
title="Someone 🔥 Somewhere"
name="Someone 🔥 Somewhere"
phoneNumber="(202) 555-0011"
profileName="🔥Flames🔥"
2021-05-07 22:21:10 +00:00
sharedGroupNames={[]}
2021-01-28 00:18:50 +00:00
about="👍 This is my really long status message that I have in order to test line breaking"
2020-09-09 02:25:05 +00:00
avatarPath={gifUrl}
onClick={onClick}
/>
);
})
.add('With a group with no avatarPath', () => {
return (
<ContactListItem
type="group"
i18n={i18n}
2021-05-07 22:21:10 +00:00
isMe={false}
isAdmin
title="Group!"
2021-05-07 22:21:10 +00:00
sharedGroupNames={[]}
acceptedMessageRequest
about="👍 Free to chat"
onClick={onClick}
/>
);
})
2020-09-09 02:25:05 +00:00
.add('With just number, admin', () => {
return (
<ContactListItem
type="direct"
acceptedMessageRequest
2020-09-09 02:25:05 +00:00
i18n={i18n}
2021-05-07 22:21:10 +00:00
isMe={false}
2020-09-09 02:25:05 +00:00
isAdmin
title="(202) 555-0011"
phoneNumber="(202) 555-0011"
2021-05-07 22:21:10 +00:00
sharedGroupNames={[]}
2021-01-26 01:01:19 +00:00
about="👍 Free to chat"
2020-09-09 02:25:05 +00:00
avatarPath={gifUrl}
onClick={onClick}
/>
);
})
2020-07-24 01:35:32 +00:00
.add('With name and profile, no avatar', () => {
return (
<ContactListItem
type="direct"
acceptedMessageRequest
2020-07-24 01:35:32 +00:00
i18n={i18n}
2021-05-07 22:21:10 +00:00
isMe={false}
2020-07-24 01:35:32 +00:00
title="Someone 🔥 Somewhere"
name="Someone 🔥 Somewhere"
2021-08-06 00:17:05 +00:00
color={getRandomColor()}
2020-07-24 01:35:32 +00:00
phoneNumber="(202) 555-0011"
profileName="🔥Flames🔥"
2021-05-07 22:21:10 +00:00
sharedGroupNames={[]}
2021-01-26 01:01:19 +00:00
about="👍 Free to chat"
2020-07-24 01:35:32 +00:00
onClick={onClick}
/>
);
})
.add('Profile, no name, no avatar', () => {
return (
<ContactListItem
type="direct"
acceptedMessageRequest
2021-08-06 00:17:05 +00:00
color={getRandomColor()}
2020-07-24 01:35:32 +00:00
i18n={i18n}
2021-05-07 22:21:10 +00:00
isMe={false}
2020-07-24 01:35:32 +00:00
phoneNumber="(202) 555-0011"
title="🔥Flames🔥"
profileName="🔥Flames🔥"
2021-05-07 22:21:10 +00:00
sharedGroupNames={[]}
2021-01-26 01:01:19 +00:00
about="👍 Free to chat"
2020-07-24 01:35:32 +00:00
onClick={onClick}
/>
);
})
2021-01-26 01:01:19 +00:00
.add('No name, no profile, no avatar, no about', () => {
2020-07-24 01:35:32 +00:00
return (
<ContactListItem
type="direct"
acceptedMessageRequest
2020-07-24 01:35:32 +00:00
i18n={i18n}
2021-05-07 22:21:10 +00:00
isMe={false}
2020-07-24 01:35:32 +00:00
phoneNumber="(202) 555-0011"
2021-05-07 22:21:10 +00:00
sharedGroupNames={[]}
2020-07-24 01:35:32 +00:00
title="(202) 555-0011"
onClick={onClick}
/>
);
})
2021-01-26 01:01:19 +00:00
.add('No name, no profile, no avatar', () => {
2020-07-24 01:35:32 +00:00
return (
<ContactListItem
type="direct"
acceptedMessageRequest
2020-07-24 01:35:32 +00:00
i18n={i18n}
2021-05-07 22:21:10 +00:00
isMe={false}
2020-07-24 01:35:32 +00:00
title="(202) 555-0011"
2021-01-26 01:01:19 +00:00
about="👍 Free to chat"
2021-05-07 22:21:10 +00:00
sharedGroupNames={[]}
2020-07-24 01:35:32 +00:00
phoneNumber="(202) 555-0011"
onClick={onClick}
/>
);
})
.add('No name, no profile, no number', () => {
return (
<ContactListItem
type="direct"
acceptedMessageRequest
i18n={i18n}
2021-05-07 22:21:10 +00:00
isMe={false}
title="Unknown contact"
2021-05-07 22:21:10 +00:00
sharedGroupNames={[]}
onClick={onClick}
/>
2020-07-24 01:35:32 +00:00
);
});