2022-01-27 22:12:26 +00:00
|
|
|
// Copyright 2021-2022 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-08-21 22:03:25 +00:00
|
|
|
import * as React from 'react';
|
2021-11-01 18:43:02 +00:00
|
|
|
import { text } from '@storybook/addon-knobs';
|
2020-08-21 22:03:25 +00:00
|
|
|
import { action } from '@storybook/addon-actions';
|
|
|
|
|
2021-09-18 00:30:08 +00:00
|
|
|
import { setupI18n } from '../util/setupI18n';
|
2020-08-21 22:03:25 +00:00
|
|
|
import enMessages from '../../_locales/en/messages.json';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { PropsType } from './MainHeader';
|
|
|
|
import { MainHeader } from './MainHeader';
|
2021-11-08 16:29:54 +00:00
|
|
|
import { ThemeType } from '../types/Util';
|
2020-08-21 22:03:25 +00:00
|
|
|
|
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export default {
|
|
|
|
title: 'Components/MainHeader',
|
|
|
|
};
|
2020-08-21 22:03:25 +00:00
|
|
|
|
|
|
|
const requiredText = (name: string, value: string | undefined) =>
|
|
|
|
text(name, value || '');
|
|
|
|
const optionalText = (name: string, value: string | undefined) =>
|
|
|
|
text(name, value || '') || undefined;
|
|
|
|
|
|
|
|
const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({
|
2022-03-04 21:14:52 +00:00
|
|
|
areStoriesEnabled: false,
|
2021-11-08 16:29:54 +00:00
|
|
|
theme: ThemeType.light,
|
2020-08-21 22:03:25 +00:00
|
|
|
|
|
|
|
phoneNumber: optionalText('phoneNumber', overrideProps.phoneNumber),
|
|
|
|
title: requiredText('title', overrideProps.title),
|
|
|
|
name: optionalText('name', overrideProps.name),
|
|
|
|
avatarPath: optionalText('avatarPath', overrideProps.avatarPath),
|
2021-08-19 22:56:29 +00:00
|
|
|
hasPendingUpdate: Boolean(overrideProps.hasPendingUpdate),
|
2020-08-21 22:03:25 +00:00
|
|
|
|
|
|
|
i18n,
|
2021-02-12 21:58:14 +00:00
|
|
|
|
2021-08-19 22:56:29 +00:00
|
|
|
startUpdate: action('startUpdate'),
|
2020-08-21 22:03:25 +00:00
|
|
|
|
|
|
|
showArchivedConversations: action('showArchivedConversations'),
|
2021-02-23 20:34:28 +00:00
|
|
|
startComposing: action('startComposing'),
|
2021-07-19 19:26:06 +00:00
|
|
|
toggleProfileEditor: action('toggleProfileEditor'),
|
2022-03-04 21:14:52 +00:00
|
|
|
toggleStoriesView: action('toggleStoriesView'),
|
2020-08-21 22:03:25 +00:00
|
|
|
});
|
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const Basic = (): JSX.Element => {
|
2020-08-21 22:03:25 +00:00
|
|
|
const props = createProps({});
|
|
|
|
|
|
|
|
return <MainHeader {...props} />;
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|
2020-08-21 22:03:25 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const Name = (): JSX.Element => {
|
2020-08-21 22:03:25 +00:00
|
|
|
const props = createProps({
|
|
|
|
name: 'John Smith',
|
|
|
|
title: 'John Smith',
|
|
|
|
});
|
|
|
|
|
|
|
|
return <MainHeader {...props} />;
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|
2020-08-21 22:03:25 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const PhoneNumber = (): JSX.Element => {
|
2020-08-21 22:03:25 +00:00
|
|
|
const props = createProps({
|
|
|
|
name: 'John Smith',
|
|
|
|
phoneNumber: '+15553004000',
|
|
|
|
});
|
|
|
|
|
|
|
|
return <MainHeader {...props} />;
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|
2020-08-21 22:03:25 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const UpdateAvailable = (): JSX.Element => {
|
2021-08-19 22:56:29 +00:00
|
|
|
const props = createProps({ hasPendingUpdate: true });
|
|
|
|
|
|
|
|
return <MainHeader {...props} />;
|
2022-06-07 00:48:02 +00:00
|
|
|
};
|
2022-03-04 21:14:52 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export const Stories = (): JSX.Element => (
|
2022-03-04 21:14:52 +00:00
|
|
|
<MainHeader {...createProps({})} areStoriesEnabled />
|
2022-06-07 00:48:02 +00:00
|
|
|
);
|