2022-03-04 21:14:52 +00:00
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2023-10-11 19:06:43 +00:00
import type { Meta } from '@storybook/react' ;
2022-03-04 21:14:52 +00:00
import React from 'react' ;
2023-10-11 19:06:43 +00:00
import { action } from '@storybook/addon-actions' ;
2022-03-04 21:14:52 +00:00
import type { PropsType } from './StoryViewer' ;
import enMessages from '../../_locales/en/messages.json' ;
2022-07-29 00:15:20 +00:00
import { SendStatus } from '../messages/MessageSendState' ;
2022-08-22 17:44:23 +00:00
import { StoryViewModeType } from '../types/Stories' ;
2023-08-10 16:43:33 +00:00
import { generateStoryDistributionId } from '../types/StoryDistributionId' ;
2022-07-29 00:15:20 +00:00
import { StoryViewer } from './StoryViewer' ;
2022-07-29 19:27:02 +00:00
import { VIDEO_MP4 } from '../types/MIME' ;
2022-03-04 21:14:52 +00:00
import { fakeAttachment } from '../test-both/helpers/fakeAttachment' ;
2022-07-29 00:15:20 +00:00
import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation' ;
2022-07-06 19:06:20 +00:00
import { getFakeStoryView } from '../test-both/helpers/getFakeStory' ;
2022-07-29 00:15:20 +00:00
import { setupI18n } from '../util/setupI18n' ;
2023-11-17 20:40:41 +00:00
import { DEFAULT_PREFERRED_REACTION_EMOJI } from '../reactions/constants' ;
2022-03-04 21:14:52 +00:00
const i18n = setupI18n ( 'en' , enMessages ) ;
2022-06-07 00:48:02 +00:00
export default {
title : 'Components/StoryViewer' ,
2022-07-06 19:06:20 +00:00
component : StoryViewer ,
argTypes : {
2023-10-11 19:06:43 +00:00
hasAllStoriesUnmuted : {
2022-10-25 22:18:42 +00:00
control : 'boolean' ,
2022-07-06 19:06:20 +00:00
} ,
2022-10-25 22:18:42 +00:00
hasViewReceiptSetting : {
control : 'boolean' ,
2022-07-06 19:06:20 +00:00
} ,
} ,
2022-10-13 21:40:43 +00:00
args : {
currentIndex : 0 ,
2023-10-11 19:06:43 +00:00
getPreferredBadge : ( ) = > undefined ,
group : undefined ,
hasAllStoriesUnmuted : true ,
hasViewReceiptSetting : true ,
i18n ,
platform : 'darwin' ,
loadStoryReplies : action ( 'loadStoryReplies' ) ,
markStoryRead : action ( 'markStoryRead' ) ,
numStories : 1 ,
onGoToConversation : action ( 'onGoToConversation' ) ,
onHideStory : action ( 'onHideStory' ) ,
onReactToStory : action ( 'onReactToStory' ) ,
onReplyToStory : action ( 'onReplyToStory' ) ,
onSetSkinTone : action ( 'onSetSkinTone' ) ,
onTextTooLong : action ( 'onTextTooLong' ) ,
onUseEmoji : action ( 'onUseEmoji' ) ,
onMediaPlaybackStart : action ( 'onMediaPlaybackStart' ) ,
2023-11-17 20:40:41 +00:00
preferredReactionEmoji : DEFAULT_PREFERRED_REACTION_EMOJI ,
2023-10-11 19:06:43 +00:00
queueStoryDownload : action ( 'queueStoryDownload' ) ,
renderEmojiPicker : ( ) = > < > EmojiPicker < / > ,
retryMessageSend : action ( 'retryMessageSend' ) ,
showToast : action ( 'showToast' ) ,
skinTone : 0 ,
story : getFakeStoryView ( ) ,
storyViewMode : StoryViewModeType.All ,
viewStory : action ( 'viewStory' ) ,
isWindowActive : true ,
2022-10-13 21:40:43 +00:00
} ,
2023-10-11 19:06:43 +00:00
} satisfies Meta < PropsType > ;
2022-07-06 19:06:20 +00:00
2023-10-11 19:06:43 +00:00
export function SomeonesStory ( args : PropsType ) : JSX . Element {
return < StoryViewer { ...args } / > ;
}
2022-06-07 00:48:02 +00:00
2023-10-11 19:06:43 +00:00
export function WideStory ( args : PropsType ) : JSX . Element {
return (
< StoryViewer
{ . . . args }
story = { getFakeStoryView ( '/fixtures/nathan-anderson-316188-unsplash.jpg' ) }
/ >
) ;
}
2022-03-04 21:14:52 +00:00
2023-10-11 19:06:43 +00:00
export function InAGroup ( args : PropsType ) : JSX . Element {
return (
< StoryViewer
{ . . . args }
group = { getDefaultConversation ( {
avatarPath : '/fixtures/kitten-4-112-112.jpg' ,
title : 'Family Group' ,
type : 'group' ,
} ) }
/ >
) ;
}
2022-06-07 00:48:02 +00:00
2023-10-11 19:06:43 +00:00
export function MultiStory ( args : PropsType ) : JSX . Element {
return (
< StoryViewer
{ . . . args }
currentIndex = { 2 }
numStories = { 7 }
story = { {
. . . getFakeStoryView ( ) ,
attachment : fakeAttachment ( {
contentType : VIDEO_MP4 ,
fileName : 'pixabay-Soap-Bubble-7141.mp4' ,
url : '/fixtures/kitten-4-112-112.jpg' ,
screenshotPath : '/fixtures/kitten-4-112-112.jpg' ,
} ) ,
} }
/ >
) ;
}
2022-03-04 21:14:52 +00:00
2023-10-11 19:06:43 +00:00
export function Caption ( args : PropsType ) : JSX . Element {
return (
< StoryViewer
{ . . . args }
story = { {
. . . getFakeStoryView ( ) ,
attachment : fakeAttachment ( {
caption : 'This place looks lovely' ,
path : 'file.jpg' ,
url : '/fixtures/nathan-anderson-316188-unsplash.jpg' ,
} ) ,
} }
/ >
) ;
}
2022-04-22 18:36:34 +00:00
2023-10-11 19:06:43 +00:00
export function EmojiCaption ( args : PropsType ) : JSX . Element {
return (
< StoryViewer
{ . . . args }
story = { {
. . . getFakeStoryView ( ) ,
attachment : fakeAttachment ( {
caption : 'WOOOOOOOOW 🥰' ,
path : 'file.jpg' ,
url : '/fixtures/nathan-anderson-316188-unsplash.jpg' ,
} ) ,
} }
/ >
) ;
}
2022-10-25 17:15:18 +00:00
2023-10-11 19:06:43 +00:00
export function LongCaption ( args : PropsType ) : JSX . Element {
return (
< StoryViewer
{ . . . args }
story = { {
. . . getFakeStoryView ( ) ,
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' ,
path : 'file.jpg' ,
url : '/fixtures/snow.jpg' ,
} ) ,
} }
/ >
) ;
}
2022-07-25 18:55:44 +00:00
2023-10-11 19:06:43 +00:00
export function YourStory ( args : PropsType ) : JSX . Element {
2022-07-25 18:55:44 +00:00
const storyView = getFakeStoryView (
'/fixtures/nathan-anderson-316188-unsplash.jpg'
) ;
2023-10-11 19:06:43 +00:00
return (
< StoryViewer
{ . . . args }
distributionList = { {
id : generateStoryDistributionId ( ) ,
name : 'Close Friends' ,
} }
story = { {
. . . storyView ,
sender : {
. . . storyView . sender ,
isMe : true ,
2022-07-29 00:15:20 +00:00
} ,
2023-10-11 19:06:43 +00:00
sendState : [
{
recipient : getDefaultConversation ( ) ,
status : SendStatus.Viewed ,
} ,
{
recipient : getDefaultConversation ( ) ,
status : SendStatus.Delivered ,
} ,
{
recipient : getDefaultConversation ( ) ,
status : SendStatus.Pending ,
} ,
] ,
} }
/ >
) ;
2022-07-25 18:55:44 +00:00
}
2022-08-31 16:11:14 +00:00
2023-10-11 19:06:43 +00:00
export function YourStoryFailed ( args : PropsType ) : JSX . Element {
2022-11-16 22:10:11 +00:00
const storyView = getFakeStoryView (
'/fixtures/nathan-anderson-316188-unsplash.jpg'
) ;
2023-10-11 19:06:43 +00:00
return (
< StoryViewer
{ . . . args }
distributionList = { {
id : generateStoryDistributionId ( ) ,
name : 'Close Friends' ,
} }
story = { {
. . . storyView ,
sender : {
. . . storyView . sender ,
isMe : true ,
2022-11-16 22:10:11 +00:00
} ,
2023-10-11 19:06:43 +00:00
sendState : [
{
recipient : getDefaultConversation ( ) ,
status : SendStatus.Viewed ,
} ,
{
recipient : getDefaultConversation ( ) ,
status : SendStatus.Failed ,
} ,
] ,
} }
/ >
) ;
2022-11-16 22:10:11 +00:00
}
2023-10-11 19:06:43 +00:00
export function ReadReceiptsOff ( args : PropsType ) : JSX . Element {
2022-08-31 16:11:14 +00:00
const storyView = getFakeStoryView (
'/fixtures/nathan-anderson-316188-unsplash.jpg'
) ;
2023-10-11 19:06:43 +00:00
return (
< StoryViewer
{ . . . args }
hasViewReceiptSetting = { false }
story = { {
. . . storyView ,
sender : {
. . . storyView . sender ,
isMe : true ,
2022-08-31 16:11:14 +00:00
} ,
2023-10-11 19:06:43 +00:00
sendState : [
{
recipient : getDefaultConversation ( ) ,
status : SendStatus.Viewed ,
} ,
{
recipient : getDefaultConversation ( ) ,
status : SendStatus.Delivered ,
} ,
{
recipient : getDefaultConversation ( ) ,
status : SendStatus.Pending ,
} ,
] ,
} }
/ >
) ;
2022-08-31 16:11:14 +00:00
}