Skip to content

Commit

Permalink
Add Tooltip bgColor prop for content and arrow slots (#120)
Browse files Browse the repository at this point in the history
* feat: add color prop for content and arrow

* chore: add changeset

* chore: remove duplicate style props

* chore: modify changeset summary and update prop types
  • Loading branch information
Twonarly1 authored Sep 21, 2023
1 parent bcccf60 commit a5a9d0a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-colts-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@animareflection/ui": patch
---

Added `Tooltip` bgColor prop for content and arrow slots
3 changes: 2 additions & 1 deletion src/components/client/core/Tooltip/Tooltip.recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ export const tooltipRecipe = defineSlotRecipe({
},
arrow: {
"--arrow-size": "var(--sizes-3)",
"--arrow-background": "var(--colors-bg-default)",
rotate: "45deg",
},
arrowTip: {
borderTopWidth: "1px",
borderColor: "border.default",
borderLeftWidth: "1px",
rotate: "-45deg",
},
},
});
7 changes: 5 additions & 2 deletions src/components/client/core/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import { tooltip } from "generated/panda/recipes";
import { useIsMounted } from "lib/hooks";

import type { TooltipProps } from "components/primitives";
import type { JsxStyleProps } from "generated/panda/types";
import type { ReactNode } from "react";

export interface Props extends TooltipProps {
trigger: ReactNode;
content: ReactNode;
bgColor?: JsxStyleProps["bgColor"];
}

/**
Expand All @@ -27,6 +29,7 @@ const Tooltip = ({
content,
openDelay = 0,
closeDelay = 0,
bgColor = "bg.default",
...rest
}: Props) => {
const classNames = tooltip();
Expand All @@ -43,11 +46,11 @@ const Tooltip = ({
<Portal>
<TooltipPositioner className={classNames.positioner}>
{isOpen && (
<TooltipArrow className={classNames.arrow}>
<TooltipArrow bgColor={bgColor} className={classNames.arrow}>
<TooltipArrowTip className={classNames.arrowTip} />
</TooltipArrow>
)}
<TooltipContent className={classNames.content}>
<TooltipContent bgColor={bgColor} className={classNames.content}>
{content}
</TooltipContent>
</TooltipPositioner>
Expand Down

0 comments on commit a5a9d0a

Please sign in to comment.