2021-03-09 13:16:56 -06:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
2021-01-29 16:19:24 -05:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import * as React from 'react';
|
2021-03-09 13:16:56 -06:00
|
|
|
import { action } from '@storybook/addon-actions';
|
2023-10-11 12:06:43 -07:00
|
|
|
import type { Meta } from '@storybook/react';
|
2021-05-07 17:21:10 -05:00
|
|
|
import { getDefaultConversation } from '../../../test-both/helpers/getDefaultConversation';
|
2021-11-02 18:01:13 -05:00
|
|
|
import { getFakeBadges } from '../../../test-both/helpers/getFakeBadge';
|
2021-09-17 20:30:08 -04:00
|
|
|
import { setupI18n } from '../../../util/setupI18n';
|
2021-01-29 16:19:24 -05:00
|
|
|
import enMessages from '../../../../_locales/en/messages.json';
|
2021-11-02 18:01:13 -05:00
|
|
|
import { StorybookThemeContext } from '../../../../.storybook/StorybookThemeContext';
|
2021-10-26 14:15:33 -05:00
|
|
|
import type { ConversationType } from '../../../state/ducks/conversations';
|
|
|
|
import type { Props } from './ConversationDetailsHeader';
|
|
|
|
import { ConversationDetailsHeader } from './ConversationDetailsHeader';
|
2021-01-29 16:19:24 -05:00
|
|
|
|
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
2022-06-06 20:48:02 -04:00
|
|
|
export default {
|
|
|
|
title:
|
|
|
|
'Components/Conversation/ConversationDetails/ConversationDetailsHeader',
|
2023-10-11 12:06:43 -07:00
|
|
|
argTypes: {},
|
|
|
|
args: {},
|
|
|
|
} satisfies Meta<Props>;
|
2021-01-29 16:19:24 -05:00
|
|
|
|
2021-05-07 17:21:10 -05:00
|
|
|
const createConversation = (): ConversationType =>
|
|
|
|
getDefaultConversation({
|
|
|
|
id: '',
|
|
|
|
type: 'group',
|
|
|
|
lastUpdated: 0,
|
2023-10-11 12:06:43 -07:00
|
|
|
title: 'Some Conversation',
|
|
|
|
groupDescription: 'This is a group description. https://www.signal.org',
|
2021-05-07 17:21:10 -05:00
|
|
|
});
|
2021-01-29 16:19:24 -05:00
|
|
|
|
2022-11-17 16:45:19 -08:00
|
|
|
function Wrapper(overrideProps: Partial<Props>) {
|
2021-11-02 18:01:13 -05:00
|
|
|
const theme = React.useContext(StorybookThemeContext);
|
2021-08-26 17:12:07 -04:00
|
|
|
|
|
|
|
return (
|
|
|
|
<ConversationDetailsHeader
|
2021-11-30 10:29:57 -06:00
|
|
|
areWeASubscriber={false}
|
2021-11-02 18:01:13 -05:00
|
|
|
conversation={createConversation()}
|
|
|
|
i18n={i18n}
|
|
|
|
canEdit={false}
|
|
|
|
startEditing={action('startEditing')}
|
2024-03-26 08:38:18 -07:00
|
|
|
membersCount={0}
|
2021-11-02 18:01:13 -05:00
|
|
|
isGroup
|
|
|
|
isMe={false}
|
|
|
|
theme={theme}
|
2024-02-05 18:13:13 -08:00
|
|
|
toggleAboutContactModal={action('toggleAboutContactModal')}
|
2021-11-02 18:01:13 -05:00
|
|
|
{...overrideProps}
|
2021-08-26 17:12:07 -04:00
|
|
|
/>
|
|
|
|
);
|
2022-11-17 16:45:19 -08:00
|
|
|
}
|
2021-08-26 17:12:07 -04:00
|
|
|
|
2022-11-17 16:45:19 -08:00
|
|
|
export function Basic(): JSX.Element {
|
|
|
|
return <Wrapper />;
|
|
|
|
}
|
|
|
|
export function Editable(): JSX.Element {
|
|
|
|
return <Wrapper canEdit />;
|
|
|
|
}
|
2021-08-26 17:12:07 -04:00
|
|
|
|
2022-11-17 16:45:19 -08:00
|
|
|
export function BasicNoDescription(): JSX.Element {
|
|
|
|
return (
|
|
|
|
<Wrapper
|
|
|
|
conversation={getDefaultConversation({
|
|
|
|
title: 'My Group',
|
|
|
|
type: 'group',
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2021-10-20 19:46:41 -04:00
|
|
|
|
2022-11-17 16:45:19 -08:00
|
|
|
export function EditableNoDescription(): JSX.Element {
|
|
|
|
return (
|
|
|
|
<Wrapper
|
|
|
|
conversation={getDefaultConversation({
|
|
|
|
title: 'My Group',
|
|
|
|
type: 'group',
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2021-11-02 18:01:13 -05:00
|
|
|
|
2023-10-11 12:06:43 -07:00
|
|
|
export function OneOnOne(): JSX.Element {
|
2024-02-05 18:13:13 -08:00
|
|
|
return (
|
|
|
|
<Wrapper
|
|
|
|
isGroup={false}
|
|
|
|
badges={getFakeBadges(3)}
|
|
|
|
conversation={getDefaultConversation({
|
|
|
|
title: 'Maya Johnson',
|
|
|
|
type: 'direct',
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
);
|
2023-10-11 12:06:43 -07:00
|
|
|
}
|
2022-06-06 20:48:02 -04:00
|
|
|
|
2022-11-17 16:45:19 -08:00
|
|
|
export function NoteToSelf(): JSX.Element {
|
|
|
|
return <Wrapper isMe />;
|
|
|
|
}
|