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

32 lines
795 B
TypeScript
Raw Normal View History

2021-05-28 16:15:17 +00:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React, { useState } from 'react';
import { action } from '@storybook/addon-actions';
import type { PropsType } from './Slider';
import { Slider } from './Slider';
2021-05-28 16:15:17 +00:00
2022-06-07 00:48:02 +00:00
export default {
title: 'Components/Slider',
};
2021-05-28 16:15:17 +00:00
const createProps = (): PropsType => ({
label: 'Slider Handle',
onChange: action('onChange'),
value: 30,
});
2022-06-07 00:48:02 +00:00
export const Default = (): JSX.Element => <Slider {...createProps()} />;
2021-05-28 16:15:17 +00:00
2022-06-07 00:48:02 +00:00
export const DraggableTest = (): JSX.Element => {
2021-05-28 16:15:17 +00:00
function StatefulSliderController(props: PropsType): JSX.Element {
const [value, setValue] = useState(30);
return <Slider {...props} onChange={setValue} value={value} />;
}
return <StatefulSliderController {...createProps()} />;
2022-06-07 00:48:02 +00:00
};