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

116 lines
2.1 KiB
TypeScript
Raw Normal View History

2020-11-19 18:11:35 +00:00
// Copyright 2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import * as React from 'react';
import { select } from '@storybook/addon-knobs';
import type { PropsType } from './Tooltip';
import { Tooltip, TooltipPlacement } from './Tooltip';
import { Theme } from '../util/theme';
2020-11-19 18:11:35 +00:00
const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({
content: overrideProps.content || 'Hello World',
direction: select('direction', TooltipPlacement, overrideProps.direction),
sticky: overrideProps.sticky,
2020-11-19 23:38:59 +00:00
theme: overrideProps.theme,
2020-11-19 18:11:35 +00:00
});
2022-06-07 00:48:02 +00:00
export default {
title: 'Components/Tooltip',
};
2020-11-19 18:11:35 +00:00
const Trigger = (
<span
style={{
display: 'inline-block',
marginTop: 200,
marginBottom: 200,
marginLeft: 200,
marginRight: 200,
}}
>
Trigger
</span>
);
2022-06-07 00:48:02 +00:00
export const _Top = (): JSX.Element => (
2020-11-19 18:11:35 +00:00
<Tooltip
{...createProps({
direction: TooltipPlacement.Top,
})}
>
{Trigger}
</Tooltip>
2022-06-07 00:48:02 +00:00
);
2020-11-19 18:11:35 +00:00
2022-06-07 00:48:02 +00:00
export const _Right = (): JSX.Element => (
2020-11-19 18:11:35 +00:00
<Tooltip
{...createProps({
direction: TooltipPlacement.Right,
})}
>
{Trigger}
</Tooltip>
2022-06-07 00:48:02 +00:00
);
2020-11-19 18:11:35 +00:00
2022-06-07 00:48:02 +00:00
export const _Bottom = (): JSX.Element => (
2020-11-19 18:11:35 +00:00
<Tooltip
{...createProps({
direction: TooltipPlacement.Bottom,
})}
>
{Trigger}
</Tooltip>
2022-06-07 00:48:02 +00:00
);
2020-11-19 18:11:35 +00:00
2022-06-07 00:48:02 +00:00
export const _Left = (): JSX.Element => (
2020-11-19 18:11:35 +00:00
<Tooltip
{...createProps({
direction: TooltipPlacement.Left,
})}
>
{Trigger}
</Tooltip>
2022-06-07 00:48:02 +00:00
);
2020-11-19 18:11:35 +00:00
2022-06-07 00:48:02 +00:00
export const Sticky = (): JSX.Element => (
2020-11-19 18:11:35 +00:00
<Tooltip
{...createProps({
sticky: true,
})}
>
{Trigger}
</Tooltip>
2022-06-07 00:48:02 +00:00
);
2020-11-19 23:38:59 +00:00
2022-06-07 00:48:02 +00:00
export const WithAppliedPopperModifiers = (): JSX.Element => {
return (
<Tooltip
{...createProps({
direction: TooltipPlacement.Bottom,
})}
popperModifiers={[
{
name: 'offset',
options: {
offset: [80, 80],
},
},
]}
>
{Trigger}
</Tooltip>
);
2022-06-07 00:48:02 +00:00
};
2022-06-07 00:48:02 +00:00
export const DarkTheme = (): JSX.Element => (
2020-11-19 23:38:59 +00:00
<Tooltip
{...createProps({
sticky: true,
theme: Theme.Dark,
2020-11-19 23:38:59 +00:00
})}
>
{Trigger}
</Tooltip>
2022-06-07 00:48:02 +00:00
);