signal-desktop/ts/components/ShortcutGuide.stories.tsx

57 lines
1.7 KiB
TypeScript
Raw Normal View History

2020-10-30 20:34:04 +00:00
// Copyright 2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2020-08-19 22:53:56 +00:00
import * as React from 'react';
import { action } from '@storybook/addon-actions';
2021-09-18 00:30:08 +00:00
import { setupI18n } from '../util/setupI18n';
2020-08-19 22:53:56 +00:00
import enMessages from '../../_locales/en/messages.json';
import type { Props } from './ShortcutGuide';
import { ShortcutGuide } from './ShortcutGuide';
2020-08-19 22:53:56 +00:00
const i18n = setupI18n('en', enMessages);
2022-06-07 00:48:02 +00:00
export default {
title: 'Components/ShortcutGuide',
};
2020-08-19 22:53:56 +00:00
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
i18n,
close: action('close'),
isFormattingFlagEnabled:
overrideProps.isFormattingFlagEnabled === false
? overrideProps.isFormattingFlagEnabled
: true,
isFormattingSpoilersFlagEnabled:
overrideProps.isFormattingSpoilersFlagEnabled === false
? overrideProps.isFormattingSpoilersFlagEnabled
: true,
hasInstalledStickers: overrideProps.hasInstalledStickers === true || false,
platform: overrideProps.platform || 'other',
2020-08-19 22:53:56 +00:00
});
2022-11-18 00:45:19 +00:00
export function Default(): JSX.Element {
2020-08-19 22:53:56 +00:00
const props = createProps({});
return <ShortcutGuide {...props} />;
2022-11-18 00:45:19 +00:00
}
2020-08-19 22:53:56 +00:00
2022-11-18 00:45:19 +00:00
export function Mac(): JSX.Element {
2020-08-19 22:53:56 +00:00
const props = createProps({ platform: 'darwin' });
return <ShortcutGuide {...props} />;
2022-11-18 00:45:19 +00:00
}
2020-08-19 22:53:56 +00:00
2022-11-18 00:45:19 +00:00
export function HasStickers(): JSX.Element {
2020-08-19 22:53:56 +00:00
const props = createProps({ hasInstalledStickers: true });
return <ShortcutGuide {...props} />;
2022-11-18 00:45:19 +00:00
}
export function NoFormatting(): JSX.Element {
const props = createProps({ isFormattingFlagEnabled: false });
return <ShortcutGuide {...props} />;
}
export function NoSpoilerFormatting(): JSX.Element {
const props = createProps({ isFormattingSpoilersFlagEnabled: false });
return <ShortcutGuide {...props} />;
}