2021-01-29 22:16:48 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import * as React from 'react';
|
|
|
|
import { boolean, number, text } from '@storybook/addon-knobs';
|
|
|
|
import { action } from '@storybook/addon-actions';
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { PropsType } from './GroupV2JoinDialog';
|
|
|
|
import { GroupV2JoinDialog } from './GroupV2JoinDialog';
|
2021-09-18 00:30:08 +00:00
|
|
|
import { setupI18n } from '../util/setupI18n';
|
2021-01-29 22:16:48 +00:00
|
|
|
import enMessages from '../../_locales/en/messages.json';
|
|
|
|
|
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
|
|
|
const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({
|
|
|
|
memberCount: number('memberCount', overrideProps.memberCount || 12),
|
|
|
|
avatar: overrideProps.avatar,
|
|
|
|
title: text('title', overrideProps.title || 'Random Group!'),
|
|
|
|
approvalRequired: boolean(
|
|
|
|
'approvalRequired',
|
|
|
|
overrideProps.approvalRequired || false
|
|
|
|
),
|
2021-06-02 00:24:28 +00:00
|
|
|
groupDescription: overrideProps.groupDescription,
|
2021-01-29 22:16:48 +00:00
|
|
|
join: action('join'),
|
|
|
|
onClose: action('onClose'),
|
|
|
|
i18n,
|
|
|
|
});
|
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export default {
|
|
|
|
title: 'Components/GroupV2JoinDialog',
|
|
|
|
};
|
2021-01-29 22:16:48 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const Basic = (): JSX.Element => {
|
2021-01-29 22:16:48 +00:00
|
|
|
return <GroupV2JoinDialog {...createProps()} />;
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|
2021-01-29 22:16:48 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const ApprovalRequired = (): JSX.Element => {
|
2021-01-29 22:16:48 +00:00
|
|
|
return (
|
|
|
|
<GroupV2JoinDialog
|
|
|
|
{...createProps({
|
|
|
|
approvalRequired: true,
|
|
|
|
title: 'Approval required!',
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
);
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ApprovalRequired.story = {
|
|
|
|
name: 'Approval required',
|
|
|
|
};
|
2021-01-29 22:16:48 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const WithAvatar = (): JSX.Element => {
|
2021-01-29 22:16:48 +00:00
|
|
|
return (
|
|
|
|
<GroupV2JoinDialog
|
|
|
|
{...createProps({
|
|
|
|
avatar: {
|
|
|
|
url: '/fixtures/giphy-GVNvOUpeYmI7e.gif',
|
|
|
|
},
|
|
|
|
title: 'Has an avatar!',
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
);
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
WithAvatar.story = {
|
|
|
|
name: 'With avatar',
|
|
|
|
};
|
2021-01-29 22:16:48 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const WithOneMember = (): JSX.Element => {
|
2021-01-29 22:16:48 +00:00
|
|
|
return (
|
|
|
|
<GroupV2JoinDialog
|
|
|
|
{...createProps({
|
|
|
|
memberCount: 1,
|
|
|
|
title: 'Just one member!',
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
);
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
WithOneMember.story = {
|
|
|
|
name: 'With one member',
|
|
|
|
};
|
2021-01-29 22:16:48 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const AvatarLoadingState = (): JSX.Element => {
|
2021-01-29 22:16:48 +00:00
|
|
|
return (
|
|
|
|
<GroupV2JoinDialog
|
|
|
|
{...createProps({
|
|
|
|
avatar: {
|
|
|
|
loading: true,
|
|
|
|
},
|
|
|
|
title: 'Avatar loading!',
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
);
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|
2021-06-02 00:24:28 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
AvatarLoadingState.story = {
|
|
|
|
name: 'Avatar loading state',
|
|
|
|
};
|
|
|
|
|
|
|
|
export const Full = (): JSX.Element => {
|
2021-06-02 00:24:28 +00:00
|
|
|
return (
|
|
|
|
<GroupV2JoinDialog
|
|
|
|
{...createProps({
|
|
|
|
avatar: {
|
|
|
|
url: '/fixtures/giphy-GVNvOUpeYmI7e.gif',
|
|
|
|
},
|
|
|
|
memberCount: 16,
|
|
|
|
groupDescription: 'Discuss meets, events, training, and recruiting.',
|
|
|
|
title: 'Underwater basket weavers (LA)',
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
);
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|