2022-03-04 16:14:52 -05:00
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react' ;
import { action } from '@storybook/addon-actions' ;
import type { PropsType } from './StoryViewer' ;
import { StoryViewer } from './StoryViewer' ;
import enMessages from '../../_locales/en/messages.json' ;
import { setupI18n } from '../util/setupI18n' ;
import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation' ;
import { fakeAttachment } from '../test-both/helpers/fakeAttachment' ;
const i18n = setupI18n ( 'en' , enMessages ) ;
2022-06-06 20:48:02 -04:00
export default {
title : 'Components/StoryViewer' ,
} ;
2022-03-04 16:14:52 -05:00
function getDefaultProps ( ) : PropsType {
2022-04-14 20:08:46 -04:00
const sender = getDefaultConversation ( ) ;
2022-03-04 16:14:52 -05:00
return {
2022-04-14 20:08:46 -04:00
conversationId : sender.id ,
2022-03-04 16:14:52 -05:00
getPreferredBadge : ( ) = > undefined ,
group : undefined ,
2022-05-06 15:02:44 -04:00
hasAllStoriesMuted : false ,
2022-03-04 16:14:52 -05:00
i18n ,
2022-04-14 20:08:46 -04:00
loadStoryReplies : action ( 'loadStoryReplies' ) ,
2022-03-04 16:14:52 -05:00
markStoryRead : action ( 'markStoryRead' ) ,
onClose : action ( 'onClose' ) ,
2022-04-29 13:43:24 -04:00
onGoToConversation : action ( 'onGoToConversation' ) ,
onHideStory : action ( 'onHideStory' ) ,
2022-03-04 16:14:52 -05:00
onNextUserStories : action ( 'onNextUserStories' ) ,
onPrevUserStories : action ( 'onPrevUserStories' ) ,
onReactToStory : action ( 'onReactToStory' ) ,
onReplyToStory : action ( 'onReplyToStory' ) ,
onSetSkinTone : action ( 'onSetSkinTone' ) ,
onTextTooLong : action ( 'onTextTooLong' ) ,
onUseEmoji : action ( 'onUseEmoji' ) ,
preferredReactionEmoji : [ '❤️' , '👍' , '👎' , '😂' , '😮' , '😢' ] ,
2022-03-28 21:10:08 -04:00
queueStoryDownload : action ( 'queueStoryDownload' ) ,
2022-03-04 16:14:52 -05:00
renderEmojiPicker : ( ) = > < div / > ,
stories : [
{
attachment : fakeAttachment ( {
2022-05-03 19:50:44 -04:00
path : 'snow.jpg' ,
2022-03-04 16:14:52 -05:00
url : '/fixtures/snow.jpg' ,
} ) ,
2022-05-04 14:45:32 -04:00
canReply : true ,
2022-03-04 16:14:52 -05:00
messageId : '123' ,
2022-04-14 20:08:46 -04:00
sender ,
2022-03-04 16:14:52 -05:00
timestamp : Date.now ( ) ,
} ,
] ,
2022-05-06 15:02:44 -04:00
toggleHasAllStoriesMuted : action ( 'toggleHasAllStoriesMuted' ) ,
2022-03-04 16:14:52 -05:00
} ;
}
2022-06-06 20:48:02 -04:00
export const SomeonesStory = ( ) : JSX . Element = > (
< StoryViewer { ...getDefaultProps ( ) } / >
) ;
2022-03-04 16:14:52 -05:00
2022-06-06 20:48:02 -04:00
SomeonesStory . story = {
name : "Someone's story" ,
} ;
export const WideStory = ( ) : JSX . Element = > (
2022-03-04 16:14:52 -05:00
< StoryViewer
{ . . . getDefaultProps ( ) }
stories = { [
{
attachment : fakeAttachment ( {
2022-05-03 19:50:44 -04:00
path : 'file.jpg' ,
2022-03-04 16:14:52 -05:00
url : '/fixtures/nathan-anderson-316188-unsplash.jpg' ,
} ) ,
2022-05-04 14:45:32 -04:00
canReply : true ,
2022-03-04 16:14:52 -05:00
messageId : '123' ,
sender : getDefaultConversation ( ) ,
timestamp : Date.now ( ) ,
} ,
] }
/ >
2022-06-06 20:48:02 -04:00
) ;
WideStory . story = {
name : 'Wide story' ,
} ;
2022-03-04 16:14:52 -05:00
2022-06-06 20:48:02 -04:00
export const InAGroup = ( ) : JSX . Element = > (
2022-03-04 16:14:52 -05:00
< StoryViewer
{ . . . getDefaultProps ( ) }
group = { getDefaultConversation ( {
avatarPath : '/fixtures/kitten-4-112-112.jpg' ,
title : 'Family Group' ,
type : 'group' ,
} ) }
/ >
2022-06-06 20:48:02 -04:00
) ;
2022-03-04 16:14:52 -05:00
2022-06-06 20:48:02 -04:00
InAGroup . story = {
name : 'In a group' ,
} ;
export const MultiStory = ( ) : JSX . Element = > {
2022-03-04 16:14:52 -05:00
const sender = getDefaultConversation ( ) ;
return (
< StoryViewer
{ . . . getDefaultProps ( ) }
stories = { [
{
attachment : fakeAttachment ( {
2022-05-03 19:50:44 -04:00
path : 'snow.jpg' ,
2022-03-04 16:14:52 -05:00
url : '/fixtures/snow.jpg' ,
} ) ,
messageId : '123' ,
sender ,
timestamp : Date.now ( ) ,
} ,
{
attachment : fakeAttachment ( {
2022-05-03 19:50:44 -04:00
path : 'file.jpg' ,
2022-03-04 16:14:52 -05:00
url : '/fixtures/nathan-anderson-316188-unsplash.jpg' ,
} ) ,
2022-05-04 14:45:32 -04:00
canReply : true ,
2022-03-04 16:14:52 -05:00
messageId : '456' ,
sender ,
timestamp : Date.now ( ) - 3600 ,
} ,
] }
/ >
) ;
2022-06-06 20:48:02 -04:00
} ;
MultiStory . story = {
name : 'Multi story' ,
} ;
2022-03-04 16:14:52 -05:00
2022-06-06 20:48:02 -04:00
export const Caption = ( ) : JSX . Element = > (
2022-04-22 14:36:34 -04:00
< StoryViewer
{ . . . getDefaultProps ( ) }
2022-05-06 12:17:33 -04:00
group = { getDefaultConversation ( {
avatarPath : '/fixtures/kitten-4-112-112.jpg' ,
title : 'Broskis' ,
type : 'group' ,
} ) }
replyState = { {
messageId : '123' ,
replies : [
{
. . . getDefaultConversation ( ) ,
body : 'Cool' ,
id : 'abc' ,
timestamp : Date.now ( ) ,
} ,
] ,
} }
2022-04-22 14:36:34 -04:00
stories = { [
{
attachment : fakeAttachment ( {
caption : 'This place looks lovely' ,
2022-05-03 19:50:44 -04:00
path : 'file.jpg' ,
2022-04-22 14:36:34 -04:00
url : '/fixtures/nathan-anderson-316188-unsplash.jpg' ,
} ) ,
2022-05-04 14:45:32 -04:00
canReply : true ,
2022-04-22 14:36:34 -04:00
messageId : '123' ,
sender : getDefaultConversation ( ) ,
timestamp : Date.now ( ) ,
} ,
] }
/ >
2022-06-06 20:48:02 -04:00
) ;
2022-04-22 14:36:34 -04:00
2022-06-06 20:48:02 -04:00
export const LongCaption = ( ) : JSX . Element = > (
2022-04-22 14:36:34 -04:00
< StoryViewer
{ . . . getDefaultProps ( ) }
2022-05-06 15:02:44 -04:00
hasAllStoriesMuted
2022-04-22 14:36:34 -04:00
stories = { [
{
attachment : fakeAttachment ( {
caption :
'Snowycle, snowycle, snowycle\nI want to ride my snowycle, snowycle, snowycle\nI want to ride my snowycle\nI want to ride my snow\nI want to ride my snowycle\nI want to ride it where I like\nSnowycle, snowycle, snowycle\nI want to ride my snowycle, snowycle, snowycle\nI want to ride my snowycle\nI want to ride my snow\nI want to ride my snowycle\nI want to ride it where I like\nSnowycle, snowycle, snowycle\nI want to ride my snowycle, snowycle, snowycle\nI want to ride my snowycle\nI want to ride my snow\nI want to ride my snowycle\nI want to ride it where I like' ,
2022-05-03 19:50:44 -04:00
path : 'file.jpg' ,
2022-04-22 14:36:34 -04:00
url : '/fixtures/snow.jpg' ,
} ) ,
2022-05-04 14:45:32 -04:00
canReply : true ,
2022-04-22 14:36:34 -04:00
messageId : '123' ,
sender : getDefaultConversation ( ) ,
timestamp : Date.now ( ) ,
} ,
] }
/ >
2022-06-06 20:48:02 -04:00
) ;