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

281 lines
8.5 KiB
TypeScript
Raw Normal View History

// Copyright 2020-2021 Signal Messenger, LLC
2020-10-30 15:34:04 -05:00
// SPDX-License-Identifier: AGPL-3.0-only
2020-05-27 17:37:06 -04:00
import * as React from 'react';
import { storiesOf } from '@storybook/react';
import { number as numberKnob, text } from '@storybook/addon-knobs';
import { action } from '@storybook/addon-actions';
2020-05-27 17:37:06 -04:00
2020-09-14 12:51:27 -07:00
import { ConversationHero } from './ConversationHero';
2020-05-27 17:37:06 -04:00
import { setup as setupI18n } from '../../../js/modules/i18n';
import enMessages from '../../../_locales/en/messages.json';
const i18n = setupI18n('en', enMessages);
2021-01-25 20:01:19 -05:00
const getAbout = () => text('about', '👍 Free to chat');
2020-07-23 18:35:32 -07:00
const getTitle = () => text('name', 'Cayce Bollard');
2020-05-27 17:37:06 -04:00
const getName = () => text('name', 'Cayce Bollard');
2020-07-23 18:35:32 -07:00
const getProfileName = () => text('profileName', 'Cayce Bollard (profile)');
2020-05-27 17:37:06 -04:00
const getAvatarPath = () =>
text('avatarPath', '/fixtures/kitten-4-112-112.jpg');
const getPhoneNumber = () => text('phoneNumber', '+1 (646) 327-2700');
const updateSharedGroups = action('updateSharedGroups');
2020-05-27 17:37:06 -04:00
storiesOf('Components/Conversation/ConversationHero', module)
.add('Direct (Three Other Groups)', () => {
return (
<div style={{ width: '480px' }}>
<ConversationHero
2021-01-25 20:01:19 -05:00
about={getAbout()}
acceptedMessageRequest
2020-05-27 17:37:06 -04:00
i18n={i18n}
2021-05-07 17:21:10 -05:00
isMe={false}
2020-07-23 18:35:32 -07:00
title={getTitle()}
2020-05-27 17:37:06 -04:00
avatarPath={getAvatarPath()}
name={getName()}
profileName={getProfileName()}
phoneNumber={getPhoneNumber()}
conversationType="direct"
updateSharedGroups={updateSharedGroups}
2020-08-04 18:13:19 -07:00
sharedGroupNames={['NYC Rock Climbers', 'Dinner Party', 'Friends 🌿']}
unblurAvatar={action('unblurAvatar')}
2020-05-27 17:37:06 -04:00
/>
</div>
);
})
.add('Direct (Two Other Groups)', () => {
return (
<div style={{ width: '480px' }}>
<ConversationHero
2021-01-25 20:01:19 -05:00
about={getAbout()}
acceptedMessageRequest
2020-05-27 17:37:06 -04:00
i18n={i18n}
2021-05-07 17:21:10 -05:00
isMe={false}
2020-07-23 18:35:32 -07:00
title={getTitle()}
2020-05-27 17:37:06 -04:00
avatarPath={getAvatarPath()}
name={getName()}
profileName={getProfileName()}
phoneNumber={getPhoneNumber()}
conversationType="direct"
updateSharedGroups={updateSharedGroups}
2020-08-04 18:13:19 -07:00
sharedGroupNames={['NYC Rock Climbers', 'Dinner Party']}
unblurAvatar={action('unblurAvatar')}
2020-05-27 17:37:06 -04:00
/>
</div>
);
})
.add('Direct (One Other Group)', () => {
return (
<div style={{ width: '480px' }}>
<ConversationHero
2021-01-25 20:01:19 -05:00
about={getAbout()}
acceptedMessageRequest
2020-05-27 17:37:06 -04:00
i18n={i18n}
2021-05-07 17:21:10 -05:00
isMe={false}
2020-07-23 18:35:32 -07:00
title={getTitle()}
2020-05-27 17:37:06 -04:00
avatarPath={getAvatarPath()}
name={getName()}
profileName={getProfileName()}
phoneNumber={getPhoneNumber()}
conversationType="direct"
updateSharedGroups={updateSharedGroups}
2020-08-04 18:13:19 -07:00
sharedGroupNames={['NYC Rock Climbers']}
unblurAvatar={action('unblurAvatar')}
2020-05-27 17:37:06 -04:00
/>
</div>
);
})
2020-07-23 18:35:32 -07:00
.add('Direct (No Groups, Name)', () => {
2020-05-27 17:37:06 -04:00
return (
<div style={{ width: '480px' }}>
<ConversationHero
2021-01-25 20:01:19 -05:00
about={getAbout()}
acceptedMessageRequest
2020-05-27 17:37:06 -04:00
i18n={i18n}
2021-05-07 17:21:10 -05:00
isMe={false}
2020-07-23 18:35:32 -07:00
title={getTitle()}
2020-05-27 17:37:06 -04:00
avatarPath={getAvatarPath()}
name={getName()}
2020-07-23 18:35:32 -07:00
profileName={text('profileName', '')}
phoneNumber={getPhoneNumber()}
conversationType="direct"
updateSharedGroups={updateSharedGroups}
2020-08-04 18:13:19 -07:00
sharedGroupNames={[]}
unblurAvatar={action('unblurAvatar')}
2020-07-23 18:35:32 -07:00
/>
</div>
);
})
.add('Direct (No Groups, Just Profile)', () => {
return (
<div style={{ width: '480px' }}>
<ConversationHero
2021-01-25 20:01:19 -05:00
about={getAbout()}
acceptedMessageRequest
2020-07-23 18:35:32 -07:00
i18n={i18n}
2021-05-07 17:21:10 -05:00
isMe={false}
2020-07-23 18:35:32 -07:00
title={text('title', 'Cayce Bollard (profile)')}
avatarPath={getAvatarPath()}
name={text('name', '')}
2020-05-27 17:37:06 -04:00
profileName={getProfileName()}
phoneNumber={getPhoneNumber()}
conversationType="direct"
updateSharedGroups={updateSharedGroups}
2020-08-04 18:13:19 -07:00
sharedGroupNames={[]}
unblurAvatar={action('unblurAvatar')}
2020-05-27 17:37:06 -04:00
/>
</div>
);
})
2020-07-23 18:35:32 -07:00
.add('Direct (No Groups, Just Phone Number)', () => {
return (
<div style={{ width: '480px' }}>
<ConversationHero
2021-01-25 20:01:19 -05:00
about={getAbout()}
acceptedMessageRequest
2020-07-23 18:35:32 -07:00
i18n={i18n}
2021-05-07 17:21:10 -05:00
isMe={false}
2020-07-23 18:35:32 -07:00
title={text('title', '+1 (646) 327-2700')}
avatarPath={getAvatarPath()}
name={text('name', '')}
profileName={text('profileName', '')}
phoneNumber={getPhoneNumber()}
conversationType="direct"
updateSharedGroups={updateSharedGroups}
2020-08-04 18:13:19 -07:00
sharedGroupNames={[]}
unblurAvatar={action('unblurAvatar')}
2020-07-23 18:35:32 -07:00
/>
</div>
);
})
.add('Direct (No Groups, No Data)', () => {
return (
<div style={{ width: '480px' }}>
<ConversationHero
i18n={i18n}
2021-05-07 17:21:10 -05:00
isMe={false}
2020-07-23 18:35:32 -07:00
title={text('title', 'Unknown contact')}
acceptedMessageRequest
avatarPath={getAvatarPath()}
name={text('name', '')}
profileName={text('profileName', '')}
phoneNumber={text('phoneNumber', '')}
conversationType="direct"
sharedGroupNames={[]}
unblurAvatar={action('unblurAvatar')}
updateSharedGroups={updateSharedGroups}
/>
</div>
);
})
.add('Direct (No Groups, No Data, Not Accepted)', () => {
return (
<div style={{ width: '480px' }}>
<ConversationHero
i18n={i18n}
2021-05-07 17:21:10 -05:00
isMe={false}
title={text('title', 'Unknown contact')}
acceptedMessageRequest={false}
2020-07-23 18:35:32 -07:00
avatarPath={getAvatarPath()}
name={text('name', '')}
profileName={text('profileName', '')}
phoneNumber={text('phoneNumber', '')}
conversationType="direct"
2020-08-04 18:13:19 -07:00
sharedGroupNames={[]}
unblurAvatar={action('unblurAvatar')}
updateSharedGroups={updateSharedGroups}
2020-07-23 18:35:32 -07:00
/>
</div>
);
})
2020-05-27 17:37:06 -04:00
.add('Group (many members)', () => {
return (
<div style={{ width: '480px' }}>
<ConversationHero
acceptedMessageRequest
2020-05-27 17:37:06 -04:00
i18n={i18n}
2021-05-07 17:21:10 -05:00
isMe={false}
2020-07-23 18:35:32 -07:00
title={text('title', 'NYC Rock Climbers')}
2020-05-27 17:37:06 -04:00
name={text('groupName', 'NYC Rock Climbers')}
conversationType="group"
membersCount={numberKnob('membersCount', 22)}
2021-05-07 17:21:10 -05:00
sharedGroupNames={[]}
unblurAvatar={action('unblurAvatar')}
updateSharedGroups={updateSharedGroups}
2020-05-27 17:37:06 -04:00
/>
</div>
);
})
.add('Group (one member)', () => {
return (
<div style={{ width: '480px' }}>
<ConversationHero
acceptedMessageRequest
2020-05-27 17:37:06 -04:00
i18n={i18n}
2021-05-07 17:21:10 -05:00
isMe={false}
2020-07-23 18:35:32 -07:00
title={text('title', 'NYC Rock Climbers')}
2020-05-27 17:37:06 -04:00
name={text('groupName', 'NYC Rock Climbers')}
conversationType="group"
membersCount={1}
2021-05-07 17:21:10 -05:00
sharedGroupNames={[]}
unblurAvatar={action('unblurAvatar')}
updateSharedGroups={updateSharedGroups}
2020-05-27 17:37:06 -04:00
/>
</div>
);
})
.add('Group (zero members)', () => {
return (
<div style={{ width: '480px' }}>
<ConversationHero
acceptedMessageRequest
2020-05-27 17:37:06 -04:00
i18n={i18n}
2021-05-07 17:21:10 -05:00
isMe={false}
2020-07-23 18:35:32 -07:00
title={text('title', 'NYC Rock Climbers')}
2020-05-27 17:37:06 -04:00
name={text('groupName', 'NYC Rock Climbers')}
2020-07-23 18:35:32 -07:00
conversationType="group"
membersCount={0}
2021-05-07 17:21:10 -05:00
sharedGroupNames={[]}
unblurAvatar={action('unblurAvatar')}
updateSharedGroups={updateSharedGroups}
2020-07-23 18:35:32 -07:00
/>
</div>
);
})
.add('Group (No name)', () => {
return (
<div style={{ width: '480px' }}>
<ConversationHero
acceptedMessageRequest
2020-07-23 18:35:32 -07:00
i18n={i18n}
2021-05-07 17:21:10 -05:00
isMe={false}
2020-07-23 18:35:32 -07:00
title={text('title', 'Unknown group')}
name={text('groupName', '')}
2020-05-27 17:37:06 -04:00
conversationType="group"
membersCount={0}
2021-05-07 17:21:10 -05:00
sharedGroupNames={[]}
unblurAvatar={action('unblurAvatar')}
updateSharedGroups={updateSharedGroups}
2020-05-27 17:37:06 -04:00
/>
</div>
);
})
.add('Note to Self', () => {
return (
<div style={{ width: '480px' }}>
<ConversationHero
2021-05-07 17:21:10 -05:00
acceptedMessageRequest
2020-05-27 17:37:06 -04:00
i18n={i18n}
2020-09-14 12:51:27 -07:00
isMe
2020-07-23 18:35:32 -07:00
title={getTitle()}
2020-05-27 17:37:06 -04:00
conversationType="direct"
phoneNumber={getPhoneNumber()}
2021-05-07 17:21:10 -05:00
sharedGroupNames={[]}
unblurAvatar={action('unblurAvatar')}
updateSharedGroups={updateSharedGroups}
2020-05-27 17:37:06 -04:00
/>
</div>
);
});