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

112 lines
2.3 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 type { Meta } from '@storybook/react';
import type { PropsType } from './Tooltip';
import { Tooltip, TooltipPlacement } from './Tooltip';
import { Theme } from '../util/theme';
2020-11-19 18:11:35 +00:00
2022-06-07 00:48:02 +00:00
export default {
title: 'Components/Tooltip',
argTypes: {
content: { control: { type: 'text' } },
direction: {
control: { type: 'select' },
options: Object.values(TooltipPlacement),
},
sticky: { control: { type: 'boolean' } },
theme: {
control: { type: 'select' },
options: Object.keys(Theme),
mappings: Theme,
},
},
args: {
content: 'Hello World',
direction: TooltipPlacement.Top,
sticky: false,
},
} satisfies Meta<PropsType>;
2020-11-19 18:11:35 +00:00
const Trigger = (
<span
style={{
display: 'inline-block',
marginTop: 200,
marginBottom: 200,
2023-04-20 17:03:43 +00:00
marginInlineStart: 200,
marginInlineEnd: 200,
2020-11-19 18:11:35 +00:00
}}
>
Trigger
</span>
);
export function Top(args: PropsType): JSX.Element {
return (
<Tooltip {...args} direction={TooltipPlacement.Top}>
{Trigger}
</Tooltip>
);
}
2020-11-19 18:11:35 +00:00
export function Right(args: PropsType): JSX.Element {
return (
<Tooltip {...args} direction={TooltipPlacement.Right}>
{Trigger}
</Tooltip>
);
}
2020-11-19 18:11:35 +00:00
export function Bottom(args: PropsType): JSX.Element {
return (
<Tooltip {...args} direction={TooltipPlacement.Bottom}>
{Trigger}
</Tooltip>
);
}
2020-11-19 18:11:35 +00:00
export function Left(args: PropsType): JSX.Element {
return (
<Tooltip {...args} direction={TooltipPlacement.Left}>
{Trigger}
</Tooltip>
);
}
2020-11-19 18:11:35 +00:00
export function Sticky(args: PropsType): JSX.Element {
2022-11-18 00:45:19 +00:00
return (
<Tooltip {...args} sticky>
2022-11-18 00:45:19 +00:00
{Trigger}
</Tooltip>
);
}
2020-11-19 23:38:59 +00:00
export function WithAppliedPopperModifiers(args: PropsType): JSX.Element {
return (
<Tooltip
{...args}
direction={TooltipPlacement.Bottom}
popperModifiers={[
{
name: 'offset',
options: {
offset: [80, 80],
},
},
]}
>
{Trigger}
</Tooltip>
);
2022-11-18 00:45:19 +00:00
}
export function DarkTheme(args: PropsType): JSX.Element {
2022-11-18 00:45:19 +00:00
return (
<Tooltip {...args} sticky theme={Theme.Dark}>
2022-11-18 00:45:19 +00:00
{Trigger}
</Tooltip>
);
}