2021-04-30 22:58:57 +00:00
// Copyright 2020-2021 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
2020-05-27 21:37:06 +00:00
import * as React from 'react' ;
import { storiesOf } from '@storybook/react' ;
import { number as numberKnob , text } from '@storybook/addon-knobs' ;
2021-04-30 19:40:25 +00:00
import { action } from '@storybook/addon-actions' ;
2020-05-27 21:37:06 +00:00
2020-09-14 19:51:27 +00:00
import { ConversationHero } from './ConversationHero' ;
2021-09-18 00:30:08 +00:00
import { setupI18n } from '../../util/setupI18n' ;
2020-05-27 21:37:06 +00:00
import enMessages from '../../../_locales/en/messages.json' ;
2021-11-02 23:01:13 +00:00
import { StorybookThemeContext } from '../../../.storybook/StorybookThemeContext' ;
2020-05-27 21:37:06 +00:00
const i18n = setupI18n ( 'en' , enMessages ) ;
2021-01-26 01:01:19 +00:00
const getAbout = ( ) = > text ( 'about' , '👍 Free to chat' ) ;
2020-07-24 01:35:32 +00:00
const getTitle = ( ) = > text ( 'name' , 'Cayce Bollard' ) ;
2020-05-27 21:37:06 +00:00
const getName = ( ) = > text ( 'name' , 'Cayce Bollard' ) ;
2020-07-24 01:35:32 +00:00
const getProfileName = ( ) = > text ( 'profileName' , 'Cayce Bollard (profile)' ) ;
2020-05-27 21:37:06 +00:00
const getAvatarPath = ( ) = >
text ( 'avatarPath' , '/fixtures/kitten-4-112-112.jpg' ) ;
const getPhoneNumber = ( ) = > text ( 'phoneNumber' , '+1 (646) 327-2700' ) ;
2021-04-30 22:58:57 +00:00
const updateSharedGroups = action ( 'updateSharedGroups' ) ;
2021-11-02 23:01:13 +00:00
const Wrapper = (
props : Omit < React.ComponentProps < typeof ConversationHero > , 'theme' >
) = > {
const theme = React . useContext ( StorybookThemeContext ) ;
return < ConversationHero { ...props } theme = { theme } / > ;
} ;
2020-05-27 21:37:06 +00:00
storiesOf ( 'Components/Conversation/ConversationHero' , module )
2021-09-17 20:57:54 +00:00
. add ( 'Direct (Five Other Groups)' , ( ) = > {
return (
< div style = { { width : '480px' } } >
2021-11-02 23:01:13 +00:00
< Wrapper
2021-09-17 20:57:54 +00:00
about = { getAbout ( ) }
acceptedMessageRequest
2021-12-01 17:24:00 +00:00
badge = { undefined }
2021-09-17 20:57:54 +00:00
i18n = { i18n }
isMe = { false }
title = { getTitle ( ) }
avatarPath = { getAvatarPath ( ) }
name = { getName ( ) }
profileName = { getProfileName ( ) }
phoneNumber = { getPhoneNumber ( ) }
conversationType = "direct"
updateSharedGroups = { updateSharedGroups }
sharedGroupNames = { [
'NYC Rock Climbers' ,
'Dinner Party' ,
'Friends 🌿' ,
'Fourth' ,
'Fifth' ,
] }
unblurAvatar = { action ( 'unblurAvatar' ) }
onHeightChange = { action ( 'onHeightChange' ) }
/ >
< / div >
) ;
} )
. add ( 'Direct (Four Other Groups)' , ( ) = > {
return (
< div style = { { width : '480px' } } >
2021-11-02 23:01:13 +00:00
< Wrapper
2021-09-17 20:57:54 +00:00
about = { getAbout ( ) }
acceptedMessageRequest
2021-12-01 17:24:00 +00:00
badge = { undefined }
2021-09-17 20:57:54 +00:00
i18n = { i18n }
isMe = { false }
title = { getTitle ( ) }
avatarPath = { getAvatarPath ( ) }
name = { getName ( ) }
profileName = { getProfileName ( ) }
phoneNumber = { getPhoneNumber ( ) }
conversationType = "direct"
updateSharedGroups = { updateSharedGroups }
sharedGroupNames = { [
'NYC Rock Climbers' ,
'Dinner Party' ,
'Friends 🌿' ,
'Fourth' ,
] }
unblurAvatar = { action ( 'unblurAvatar' ) }
onHeightChange = { action ( 'onHeightChange' ) }
/ >
< / div >
) ;
} )
2020-05-27 21:37:06 +00:00
. add ( 'Direct (Three Other Groups)' , ( ) = > {
return (
< div style = { { width : '480px' } } >
2021-11-02 23:01:13 +00:00
< Wrapper
2021-01-26 01:01:19 +00:00
about = { getAbout ( ) }
2021-04-30 22:58:57 +00:00
acceptedMessageRequest
2021-12-01 17:24:00 +00:00
badge = { undefined }
2020-05-27 21:37:06 +00:00
i18n = { i18n }
2021-05-07 22:21:10 +00:00
isMe = { false }
2020-07-24 01:35:32 +00:00
title = { getTitle ( ) }
2020-05-27 21:37:06 +00:00
avatarPath = { getAvatarPath ( ) }
name = { getName ( ) }
profileName = { getProfileName ( ) }
phoneNumber = { getPhoneNumber ( ) }
conversationType = "direct"
2021-04-30 22:58:57 +00:00
updateSharedGroups = { updateSharedGroups }
2020-08-05 01:13:19 +00:00
sharedGroupNames = { [ 'NYC Rock Climbers' , 'Dinner Party' , 'Friends 🌿' ] }
2021-04-30 19:40:25 +00:00
unblurAvatar = { action ( 'unblurAvatar' ) }
2021-09-16 21:44:00 +00:00
onHeightChange = { action ( 'onHeightChange' ) }
2020-05-27 21:37:06 +00:00
/ >
< / div >
) ;
} )
. add ( 'Direct (Two Other Groups)' , ( ) = > {
return (
< div style = { { width : '480px' } } >
2021-11-02 23:01:13 +00:00
< Wrapper
2021-01-26 01:01:19 +00:00
about = { getAbout ( ) }
2021-04-30 22:58:57 +00:00
acceptedMessageRequest
2021-12-01 17:24:00 +00:00
badge = { undefined }
2020-05-27 21:37:06 +00:00
i18n = { i18n }
2021-05-07 22:21:10 +00:00
isMe = { false }
2020-07-24 01:35:32 +00:00
title = { getTitle ( ) }
2020-05-27 21:37:06 +00:00
avatarPath = { getAvatarPath ( ) }
name = { getName ( ) }
profileName = { getProfileName ( ) }
phoneNumber = { getPhoneNumber ( ) }
conversationType = "direct"
2021-04-30 22:58:57 +00:00
updateSharedGroups = { updateSharedGroups }
2020-08-05 01:13:19 +00:00
sharedGroupNames = { [ 'NYC Rock Climbers' , 'Dinner Party' ] }
2021-04-30 19:40:25 +00:00
unblurAvatar = { action ( 'unblurAvatar' ) }
2021-09-16 21:44:00 +00:00
onHeightChange = { action ( 'onHeightChange' ) }
2020-05-27 21:37:06 +00:00
/ >
< / div >
) ;
} )
. add ( 'Direct (One Other Group)' , ( ) = > {
return (
< div style = { { width : '480px' } } >
2021-11-02 23:01:13 +00:00
< Wrapper
2021-01-26 01:01:19 +00:00
about = { getAbout ( ) }
2021-04-30 22:58:57 +00:00
acceptedMessageRequest
2021-12-01 17:24:00 +00:00
badge = { undefined }
2020-05-27 21:37:06 +00:00
i18n = { i18n }
2021-05-07 22:21:10 +00:00
isMe = { false }
2020-07-24 01:35:32 +00:00
title = { getTitle ( ) }
2020-05-27 21:37:06 +00:00
avatarPath = { getAvatarPath ( ) }
name = { getName ( ) }
profileName = { getProfileName ( ) }
phoneNumber = { getPhoneNumber ( ) }
conversationType = "direct"
2021-04-30 22:58:57 +00:00
updateSharedGroups = { updateSharedGroups }
2020-08-05 01:13:19 +00:00
sharedGroupNames = { [ 'NYC Rock Climbers' ] }
2021-04-30 19:40:25 +00:00
unblurAvatar = { action ( 'unblurAvatar' ) }
2021-09-16 21:44:00 +00:00
onHeightChange = { action ( 'onHeightChange' ) }
2020-05-27 21:37:06 +00:00
/ >
< / div >
) ;
} )
2020-07-24 01:35:32 +00:00
. add ( 'Direct (No Groups, Name)' , ( ) = > {
2020-05-27 21:37:06 +00:00
return (
< div style = { { width : '480px' } } >
2021-11-02 23:01:13 +00:00
< Wrapper
2021-01-26 01:01:19 +00:00
about = { getAbout ( ) }
2021-04-30 22:58:57 +00:00
acceptedMessageRequest
2021-12-01 17:24:00 +00:00
badge = { undefined }
2020-05-27 21:37:06 +00:00
i18n = { i18n }
2021-05-07 22:21:10 +00:00
isMe = { false }
2020-07-24 01:35:32 +00:00
title = { getTitle ( ) }
2020-05-27 21:37:06 +00:00
avatarPath = { getAvatarPath ( ) }
name = { getName ( ) }
2020-07-24 01:35:32 +00:00
profileName = { text ( 'profileName' , '' ) }
phoneNumber = { getPhoneNumber ( ) }
conversationType = "direct"
2021-04-30 22:58:57 +00:00
updateSharedGroups = { updateSharedGroups }
2020-08-05 01:13:19 +00:00
sharedGroupNames = { [ ] }
2021-04-30 19:40:25 +00:00
unblurAvatar = { action ( 'unblurAvatar' ) }
2021-09-16 21:44:00 +00:00
onHeightChange = { action ( 'onHeightChange' ) }
2020-07-24 01:35:32 +00:00
/ >
< / div >
) ;
} )
. add ( 'Direct (No Groups, Just Profile)' , ( ) = > {
return (
< div style = { { width : '480px' } } >
2021-11-02 23:01:13 +00:00
< Wrapper
2021-01-26 01:01:19 +00:00
about = { getAbout ( ) }
2021-04-30 22:58:57 +00:00
acceptedMessageRequest
2021-12-01 17:24:00 +00:00
badge = { undefined }
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 = { text ( 'title' , 'Cayce Bollard (profile)' ) }
avatarPath = { getAvatarPath ( ) }
name = { text ( 'name' , '' ) }
2020-05-27 21:37:06 +00:00
profileName = { getProfileName ( ) }
phoneNumber = { getPhoneNumber ( ) }
conversationType = "direct"
2021-04-30 22:58:57 +00:00
updateSharedGroups = { updateSharedGroups }
2020-08-05 01:13:19 +00:00
sharedGroupNames = { [ ] }
2021-04-30 19:40:25 +00:00
unblurAvatar = { action ( 'unblurAvatar' ) }
2021-09-16 21:44:00 +00:00
onHeightChange = { action ( 'onHeightChange' ) }
2020-05-27 21:37:06 +00:00
/ >
< / div >
) ;
} )
2020-07-24 01:35:32 +00:00
. add ( 'Direct (No Groups, Just Phone Number)' , ( ) = > {
return (
< div style = { { width : '480px' } } >
2021-11-02 23:01:13 +00:00
< Wrapper
2021-01-26 01:01:19 +00:00
about = { getAbout ( ) }
2021-04-30 22:58:57 +00:00
acceptedMessageRequest
2021-12-01 17:24:00 +00:00
badge = { undefined }
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 = { text ( 'title' , '+1 (646) 327-2700' ) }
avatarPath = { getAvatarPath ( ) }
name = { text ( 'name' , '' ) }
profileName = { text ( 'profileName' , '' ) }
phoneNumber = { getPhoneNumber ( ) }
conversationType = "direct"
2021-04-30 22:58:57 +00:00
updateSharedGroups = { updateSharedGroups }
2020-08-05 01:13:19 +00:00
sharedGroupNames = { [ ] }
2021-04-30 19:40:25 +00:00
unblurAvatar = { action ( 'unblurAvatar' ) }
2021-09-16 21:44:00 +00:00
onHeightChange = { action ( 'onHeightChange' ) }
2020-07-24 01:35:32 +00:00
/ >
< / div >
) ;
} )
. add ( 'Direct (No Groups, No Data)' , ( ) = > {
return (
< div style = { { width : '480px' } } >
2021-11-02 23:01:13 +00:00
< Wrapper
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 = { text ( 'title' , 'Unknown contact' ) }
2021-04-30 22:58:57 +00:00
acceptedMessageRequest
2021-12-01 17:24:00 +00:00
badge = { undefined }
2021-04-30 22:58:57 +00:00
avatarPath = { getAvatarPath ( ) }
name = { text ( 'name' , '' ) }
profileName = { text ( 'profileName' , '' ) }
phoneNumber = { text ( 'phoneNumber' , '' ) }
conversationType = "direct"
sharedGroupNames = { [ ] }
unblurAvatar = { action ( 'unblurAvatar' ) }
updateSharedGroups = { updateSharedGroups }
2021-09-16 21:44:00 +00:00
onHeightChange = { action ( 'onHeightChange' ) }
2021-04-30 22:58:57 +00:00
/ >
< / div >
) ;
} )
. add ( 'Direct (No Groups, No Data, Not Accepted)' , ( ) = > {
return (
< div style = { { width : '480px' } } >
2021-11-02 23:01:13 +00:00
< Wrapper
2021-04-30 22:58:57 +00:00
i18n = { i18n }
2021-05-07 22:21:10 +00:00
isMe = { false }
2021-04-30 22:58:57 +00:00
title = { text ( 'title' , 'Unknown contact' ) }
acceptedMessageRequest = { false }
2021-12-01 17:24:00 +00:00
badge = { undefined }
2020-07-24 01:35:32 +00:00
avatarPath = { getAvatarPath ( ) }
name = { text ( 'name' , '' ) }
profileName = { text ( 'profileName' , '' ) }
phoneNumber = { text ( 'phoneNumber' , '' ) }
conversationType = "direct"
2020-08-05 01:13:19 +00:00
sharedGroupNames = { [ ] }
2021-04-30 19:40:25 +00:00
unblurAvatar = { action ( 'unblurAvatar' ) }
2021-04-30 22:58:57 +00:00
updateSharedGroups = { updateSharedGroups }
2021-09-16 21:44:00 +00:00
onHeightChange = { action ( 'onHeightChange' ) }
2020-07-24 01:35:32 +00:00
/ >
< / div >
) ;
} )
2020-05-27 21:37:06 +00:00
. add ( 'Group (many members)' , ( ) = > {
return (
< div style = { { width : '480px' } } >
2021-11-02 23:01:13 +00:00
< Wrapper
2021-04-30 22:58:57 +00:00
acceptedMessageRequest
2021-12-01 17:24:00 +00:00
badge = { undefined }
2020-05-27 21:37:06 +00:00
i18n = { i18n }
2021-05-07 22:21:10 +00:00
isMe = { false }
2020-07-24 01:35:32 +00:00
title = { text ( 'title' , 'NYC Rock Climbers' ) }
2020-05-27 21:37:06 +00:00
name = { text ( 'groupName' , 'NYC Rock Climbers' ) }
conversationType = "group"
membersCount = { numberKnob ( 'membersCount' , 22 ) }
2021-05-07 22:21:10 +00:00
sharedGroupNames = { [ ] }
2021-04-30 19:40:25 +00:00
unblurAvatar = { action ( 'unblurAvatar' ) }
2021-04-30 22:58:57 +00:00
updateSharedGroups = { updateSharedGroups }
2021-09-16 21:44:00 +00:00
onHeightChange = { action ( 'onHeightChange' ) }
2020-05-27 21:37:06 +00:00
/ >
< / div >
) ;
} )
. add ( 'Group (one member)' , ( ) = > {
return (
< div style = { { width : '480px' } } >
2021-11-02 23:01:13 +00:00
< Wrapper
2021-04-30 22:58:57 +00:00
acceptedMessageRequest
2021-12-01 17:24:00 +00:00
badge = { undefined }
2020-05-27 21:37:06 +00:00
i18n = { i18n }
2021-05-07 22:21:10 +00:00
isMe = { false }
2020-07-24 01:35:32 +00:00
title = { text ( 'title' , 'NYC Rock Climbers' ) }
2020-05-27 21:37:06 +00:00
name = { text ( 'groupName' , 'NYC Rock Climbers' ) }
conversationType = "group"
membersCount = { 1 }
2021-05-07 22:21:10 +00:00
sharedGroupNames = { [ ] }
2021-04-30 19:40:25 +00:00
unblurAvatar = { action ( 'unblurAvatar' ) }
2021-04-30 22:58:57 +00:00
updateSharedGroups = { updateSharedGroups }
2021-09-16 21:44:00 +00:00
onHeightChange = { action ( 'onHeightChange' ) }
2020-05-27 21:37:06 +00:00
/ >
< / div >
) ;
} )
. add ( 'Group (zero members)' , ( ) = > {
return (
< div style = { { width : '480px' } } >
2021-11-02 23:01:13 +00:00
< Wrapper
2021-04-30 22:58:57 +00:00
acceptedMessageRequest
2021-12-01 17:24:00 +00:00
badge = { undefined }
2020-05-27 21:37:06 +00:00
i18n = { i18n }
2021-05-07 22:21:10 +00:00
isMe = { false }
2020-07-24 01:35:32 +00:00
title = { text ( 'title' , 'NYC Rock Climbers' ) }
2020-05-27 21:37:06 +00:00
name = { text ( 'groupName' , 'NYC Rock Climbers' ) }
2020-07-24 01:35:32 +00:00
conversationType = "group"
2021-06-02 00:24:28 +00:00
groupDescription = "This is a group for all the rock climbers of NYC"
membersCount = { 0 }
sharedGroupNames = { [ ] }
unblurAvatar = { action ( 'unblurAvatar' ) }
updateSharedGroups = { updateSharedGroups }
2021-09-16 21:44:00 +00:00
onHeightChange = { action ( 'onHeightChange' ) }
2021-06-02 00:24:28 +00:00
/ >
< / div >
) ;
} )
. add ( 'Group (long group description)' , ( ) = > {
return (
< div style = { { width : '480px' } } >
2021-11-02 23:01:13 +00:00
< Wrapper
2021-06-02 00:24:28 +00:00
acceptedMessageRequest
2021-12-01 17:24:00 +00:00
badge = { undefined }
2021-06-02 00:24:28 +00:00
i18n = { i18n }
isMe = { false }
title = { text ( 'title' , 'NYC Rock Climbers' ) }
name = { text ( 'groupName' , 'NYC Rock Climbers' ) }
conversationType = "group"
groupDescription = "This is a group for all the rock climbers of NYC. We really like to climb rocks and these NYC people climb any rock. No rock is too small or too big to be climbed. We will ascend upon all rocks, and not just in NYC, in the whole world. We are just getting started, NYC is just the beginning, watch out rocks in the galaxy. Kuiper belt I'm looking at you. We will put on a space suit and climb all your rocks. No rock is near nor far for the rock climbers of NYC."
2020-07-24 01:35:32 +00:00
membersCount = { 0 }
2021-05-07 22:21:10 +00:00
sharedGroupNames = { [ ] }
2021-04-30 19:40:25 +00:00
unblurAvatar = { action ( 'unblurAvatar' ) }
2021-04-30 22:58:57 +00:00
updateSharedGroups = { updateSharedGroups }
2021-09-16 21:44:00 +00:00
onHeightChange = { action ( 'onHeightChange' ) }
2020-07-24 01:35:32 +00:00
/ >
< / div >
) ;
} )
. add ( 'Group (No name)' , ( ) = > {
return (
< div style = { { width : '480px' } } >
2021-11-02 23:01:13 +00:00
< Wrapper
2021-04-30 22:58:57 +00:00
acceptedMessageRequest
2021-12-01 17:24:00 +00:00
badge = { undefined }
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 = { text ( 'title' , 'Unknown group' ) }
name = { text ( 'groupName' , '' ) }
2020-05-27 21:37:06 +00:00
conversationType = "group"
membersCount = { 0 }
2021-05-07 22:21:10 +00:00
sharedGroupNames = { [ ] }
2021-04-30 19:40:25 +00:00
unblurAvatar = { action ( 'unblurAvatar' ) }
2021-04-30 22:58:57 +00:00
updateSharedGroups = { updateSharedGroups }
2021-09-16 21:44:00 +00:00
onHeightChange = { action ( 'onHeightChange' ) }
2020-05-27 21:37:06 +00:00
/ >
< / div >
) ;
} )
. add ( 'Note to Self' , ( ) = > {
return (
< div style = { { width : '480px' } } >
2021-11-02 23:01:13 +00:00
< Wrapper
2021-05-07 22:21:10 +00:00
acceptedMessageRequest
2021-12-01 17:24:00 +00:00
badge = { undefined }
2020-05-27 21:37:06 +00:00
i18n = { i18n }
2020-09-14 19:51:27 +00:00
isMe
2020-07-24 01:35:32 +00:00
title = { getTitle ( ) }
2020-05-27 21:37:06 +00:00
conversationType = "direct"
phoneNumber = { getPhoneNumber ( ) }
2021-05-07 22:21:10 +00:00
sharedGroupNames = { [ ] }
2021-04-30 19:40:25 +00:00
unblurAvatar = { action ( 'unblurAvatar' ) }
2021-04-30 22:58:57 +00:00
updateSharedGroups = { updateSharedGroups }
2021-09-16 21:44:00 +00:00
onHeightChange = { action ( 'onHeightChange' ) }
2020-05-27 21:37:06 +00:00
/ >
< / div >
) ;
} ) ;