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

91 lines
1.9 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-20 22:09:46 +00:00
import * as React from 'react';
2024-03-04 18:03:11 +00:00
import type { ComponentMeta } from '../storybook/types';
2024-05-15 21:48:02 +00:00
import type { Props } from './I18n';
import { I18n } from './I18n';
2021-09-18 00:30:08 +00:00
import { setupI18n } from '../util/setupI18n';
2020-08-20 22:09:46 +00:00
import enMessages from '../../_locales/en/messages.json';
const i18n = setupI18n('en', enMessages);
2022-06-07 00:48:02 +00:00
export default {
2024-05-15 21:48:02 +00:00
title: 'Components/I18n',
component: I18n,
2024-03-04 18:03:11 +00:00
args: {
i18n,
id: 'icu:ok',
components: undefined,
},
} satisfies ComponentMeta<Props<'icu:ok'>>;
2020-08-20 22:09:46 +00:00
2024-03-04 18:03:11 +00:00
export function NoReplacements(
args: Props<'icu:deleteAndRestart'>
): JSX.Element {
2024-05-15 21:48:02 +00:00
return <I18n {...args} id="icu:deleteAndRestart" />;
2024-03-04 18:03:11 +00:00
}
2020-08-20 22:09:46 +00:00
2024-03-04 18:03:11 +00:00
export function SingleStringReplacement(
args: Props<'icu:leftTheGroup'>
): JSX.Element {
return (
2024-05-15 21:48:02 +00:00
<I18n {...args} id="icu:leftTheGroup" components={{ name: 'Theodora' }} />
2024-03-04 18:03:11 +00:00
);
}
2020-08-20 22:09:46 +00:00
2024-03-04 18:03:11 +00:00
export function SingleTagReplacement(
args: Props<'icu:leftTheGroup'>
): JSX.Element {
return (
2024-05-15 21:48:02 +00:00
<I18n
2024-03-04 18:03:11 +00:00
{...args}
id="icu:leftTheGroup"
components={{
name: (
<button type="button" key="a-button">
Theodora
</button>
),
}}
/>
);
}
2020-08-20 22:09:46 +00:00
2024-03-04 18:03:11 +00:00
export function MultipleStringReplacement(
args: Props<'icu:changedRightAfterVerify'>
): JSX.Element {
return (
2024-05-15 21:48:02 +00:00
<I18n
2024-03-04 18:03:11 +00:00
{...args}
id="icu:changedRightAfterVerify"
components={{ name1: 'Fred', name2: 'The Fredster' }}
/>
);
}
2020-08-20 22:09:46 +00:00
2024-03-04 18:03:11 +00:00
export function MultipleTagReplacement(
args: Props<'icu:changedRightAfterVerify'>
): JSX.Element {
return (
2024-05-15 21:48:02 +00:00
<I18n
2024-03-04 18:03:11 +00:00
{...args}
id="icu:changedRightAfterVerify"
components={{ name1: <b>Fred</b>, name2: <b>The Fredster</b> }}
/>
);
}
2024-03-04 18:03:11 +00:00
export function Emoji(
args: Props<'icu:Message__reaction-emoji-label--you'>
): JSX.Element {
return (
2024-05-15 21:48:02 +00:00
<I18n
2024-03-04 18:03:11 +00:00
{...args}
id="icu:Message__reaction-emoji-label--you"
components={{ emoji: '😛' }}
/>
);
}