-
Notifications
You must be signed in to change notification settings - Fork 433
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1031 from tailwarden/fix-tooltip
fix: fix tooltip component positioning and add it to storybook
- Loading branch information
Showing
3 changed files
with
83 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import WarningIcon from '@components/icons/WarningIcon'; | ||
import Tooltip from './Tooltip'; | ||
|
||
// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction | ||
const meta: Meta<typeof Tooltip> = { | ||
title: 'Komiser/Tooltip', | ||
component: Tooltip, | ||
parameters: { | ||
docs: { | ||
description: { | ||
component: | ||
// eslint-disable-next-line no-multi-str | ||
'The tooltip component required to be wrapped inside an relative positioned container. There also need to be a trigger element which is required to have `className="peer"`!\ | ||
In this example the strigger element is the Info icon.\ | ||
The Storybook preview gives you an idea about possible parameters but might not work 100% because you should either define top **or** bottom, **not** both.\ | ||
To allow to show all possible options, we define both top, bottom and left, right in this example. Please keep this in mind!' | ||
} | ||
} | ||
}, | ||
tags: ['autodocs'], | ||
decorators: [ | ||
Story => ( | ||
<div className="flex h-96 items-center justify-center"> | ||
<div className="relative h-[16px] w-[16px]"> | ||
<WarningIcon className="peer" height="16" width="16" /> | ||
<Story /> | ||
</div> | ||
</div> | ||
) | ||
], | ||
argTypes: { | ||
top: { | ||
control: { | ||
type: 'inline-radio' | ||
} | ||
}, | ||
bottom: { | ||
control: { | ||
type: 'inline-radio' | ||
} | ||
}, | ||
align: { | ||
control: { | ||
type: 'inline-radio' | ||
} | ||
}, | ||
width: { | ||
control: { | ||
type: 'inline-radio' | ||
} | ||
} | ||
} | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof Tooltip>; | ||
|
||
// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args | ||
export const TopTiny: Story = { | ||
args: { | ||
top: 'xs', | ||
align: 'left', | ||
width: 'lg', | ||
children: "That's a tooltip" | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters