From 332c00dac2db3c9474d54f8d6486c098f469effc Mon Sep 17 00:00:00 2001 From: "GitStart-Cal.com" <121884634+gitstart-calcom@users.noreply.github.com> Date: Thu, 31 Aug 2023 19:17:59 +0000 Subject: [PATCH] fix: Fix tooltip control on ButtonPlayground storybook file (fix-ButtonTooltip) (#10937) Co-authored-by: gitstart-calcom --- .../ui/components/button/button.stories.mdx | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/packages/ui/components/button/button.stories.mdx b/packages/ui/components/button/button.stories.mdx index c4cafd4e95..4ee81d5b30 100644 --- a/packages/ui/components/button/button.stories.mdx +++ b/packages/ui/components/button/button.stories.mdx @@ -1,3 +1,4 @@ +import { TooltipProvider } from "@radix-ui/react-tooltip"; import { Canvas, Meta, Story, ArgsTable } from "@storybook/addon-docs"; import { @@ -17,7 +18,7 @@ import { Button } from "./Button"; - +<Title title="Buttons" suffix="Brief" subtitle="Version 2.1 — Last Update: 24 Aug 2023" /> ## Definition @@ -170,6 +171,15 @@ Button are clickable elements that initiates user actions. Labels in the button </Story> <Story name="Button Playground" + play={({ canvasElement }) => { + const darkVariantContainer = canvasElement.querySelector('[data-mode="dark"]'); + const buttonElement = darkVariantContainer.querySelector("button"); + buttonElement?.addEventListener("mouseover", () => { + setTimeout(() => { + document.querySelector('[data-testid="tooltip"]').classList.add("dark"); + }, 55); + }); + }} args={{ color: "primary", size: "base", @@ -177,6 +187,7 @@ Button are clickable elements that initiates user actions. Labels in the button disabled: false, children: "Button text", className: "", + tooltip: "tooltip", }} argTypes={{ color: { @@ -212,19 +223,20 @@ Button are clickable elements that initiates user actions. Labels in the button options: ["", "sb-pseudo--hover", "sb-pseudo--focus"], }, }, + tooltip: { + control: { + type: "text", + }, + }, }}> - {({ color, size, loading, disabled, children, className }) => ( + {({ children, ...args }) => ( <VariantsTable titles={["Light & Dark Modes"]} columnMinWidth={150}> <VariantRow variant="Button"> - <Button - color={color} - size={size} - variant="default" - loading={loading} - disabled={disabled} - className={className}> - {children} - </Button> + <TooltipProvider> + <Button variant="default" {...args}> + {children} + </Button> + </TooltipProvider> </VariantRow> </VariantsTable> )}