diff --git a/examples/storybook/src/stories/Tooltip.stories.tsx b/examples/storybook/src/stories/Tooltip.stories.tsx index 79df07a..524e866 100644 --- a/examples/storybook/src/stories/Tooltip.stories.tsx +++ b/examples/storybook/src/stories/Tooltip.stories.tsx @@ -6,13 +6,6 @@ const meta: Meta = { title: "Components/Tooltip", component: Tooltip.Root, tags: ["autodocs"], -}; - -export default meta; - -type Story = StoryObj; - -export const Uncontrolled: Story = { decorators: [ (Story) => (
@@ -20,6 +13,13 @@ export const Uncontrolled: Story = {
), ], +}; + +export default meta; + +type Story = StoryObj; + +export const Uncontrolled: Story = { render: (args: TooltipProps["Root"]) => ( @@ -65,13 +65,6 @@ export const Uncontrolled: Story = { }; export const Controlled: Story = { - decorators: [ - (Story) => ( -
- -
- ), - ], render: (args) => { const [open, setOpen] = React.useState(false); return ( @@ -87,18 +80,18 @@ export const Controlled: Story = { docs: { source: { code: ` - const ControlledTooltip = () => { - const [open, setOpen] = React.useState(false); +const ControlledTooltip = () => { + const [open, setOpen] = React.useState(false); - return ( - - - Hover me - - - - ); - }; + return ( + + + Hover me + + + + ); +}; `, language: "jsx", type: "code", @@ -108,13 +101,6 @@ export const Controlled: Story = { }; export const CustomContent: Story = { - decorators: [ - (Story) => ( -
- -
- ), - ], render: (args: TooltipProps["Root"]) => ( diff --git a/packages/ui/src/components/Tooltip/index.tsx b/packages/ui/src/components/Tooltip/index.tsx index 0eb86d4..9dc4a74 100644 --- a/packages/ui/src/components/Tooltip/index.tsx +++ b/packages/ui/src/components/Tooltip/index.tsx @@ -6,6 +6,7 @@ import type { TooltipContentProps, TooltipTriggerProps, } from "./types"; +import { sharedTooltipStyles } from "./styles"; export const TooltipRoot = ({ children, @@ -29,15 +30,6 @@ export const TooltipRoot = ({ TooltipRoot.displayName = "Tooltip.Root"; -const classnames = cn( - "py-2 px-3 rounded-md bg-gray-700 text-white max-w-[200px]", - "will-change-[transform,opacity]", - "data-[state=delayed-open]:data-[side=top]:animate-slide-up-and-fade", - "data-[state=delayed-open]:data-[side=right]:animate-slide-right-and-fade", - "data-[state=delayed-open]:data-[side=left]:animate-slide-left-and-fade", - "data-[state=delayed-open]:data-[side=bottom]:animate-slide-down-and-fade" -); - export const TooltipContent = ({ children, label, @@ -48,7 +40,7 @@ export const TooltipContent = ({ {label ? ( diff --git a/packages/ui/src/components/Tooltip/styles.ts b/packages/ui/src/components/Tooltip/styles.ts new file mode 100644 index 0000000..3b5f8fc --- /dev/null +++ b/packages/ui/src/components/Tooltip/styles.ts @@ -0,0 +1,10 @@ +import { cn } from "../../utils/cn"; + +export const sharedTooltipStyles = cn( + "py-2 px-3 rounded-md bg-gray-700 text-white max-w-[200px]", + "will-change-[transform,opacity]", + "data-[state=delayed-open]:data-[side=top]:animate-slide-up-and-fade", + "data-[state=delayed-open]:data-[side=right]:animate-slide-right-and-fade", + "data-[state=delayed-open]:data-[side=left]:animate-slide-left-and-fade", + "data-[state=delayed-open]:data-[side=bottom]:animate-slide-down-and-fade", +);