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

34 lines
793 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-11-18 00:45:19 +00:00
export function Default(): JSX.Element {
return <Slider {...createProps()} />;
}
2021-05-28 16:15:17 +00:00
2022-11-18 00:45:19 +00:00
function StatefulSliderController(props: PropsType): JSX.Element {
const [value, setValue] = useState(30);
2021-05-28 16:15:17 +00:00
2022-11-18 00:45:19 +00:00
return <Slider {...props} onChange={setValue} value={value} />;
}
2021-05-28 16:15:17 +00:00
2022-11-18 00:45:19 +00:00
export function DraggableTest(): JSX.Element {
2021-05-28 16:15:17 +00:00
return <StatefulSliderController {...createProps()} />;
2022-11-18 00:45:19 +00:00
}