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

41 lines
1.1 KiB
TypeScript
Raw Normal View History

// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React, { useState } from 'react';
import type { Meta } from '@storybook/react';
import type { Props } from './DisappearingTimerSelect';
import { DisappearingTimerSelect } from './DisappearingTimerSelect';
2021-09-18 00:30:08 +00:00
import { setupI18n } from '../util/setupI18n';
2022-11-16 20:18:02 +00:00
import { DurationInSeconds } from '../util/durations';
import enMessages from '../../_locales/en/messages.json';
2022-06-07 00:48:02 +00:00
export default {
title: 'Components/DisappearingTimerSelect',
} satisfies Meta<Props>;
const i18n = setupI18n('en', enMessages);
type Args = {
initialValue: number;
};
function TimerSelectWrap({ initialValue }: Args): JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<DisappearingTimerSelect
i18n={i18n}
2022-11-16 20:18:02 +00:00
value={DurationInSeconds.fromSeconds(value)}
onChange={newValue => setValue(newValue)}
/>
);
2022-11-18 00:45:19 +00:00
}
2022-11-18 00:45:19 +00:00
export function InitialValue1Day(): JSX.Element {
return <TimerSelectWrap initialValue={24 * 3600} />;
}
2022-06-07 00:48:02 +00:00
2022-11-18 00:45:19 +00:00
export function InitialValue3DaysCustomTime(): JSX.Element {
return <TimerSelectWrap initialValue={3 * 24 * 3600} />;
}