Skip to content

Commit edf65bd

Browse files
Karthik-B-06kodiakhq[bot]
authored andcommitted
chore(tooltip): ✨ wrap tailwind classnames with cx, move arrow style into tooltip theme
1 parent 5b8592f commit edf65bd

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

src/components/tooltip/Tooltip.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Popover } from "react-native-popper";
44

55
import { Box, Text } from "../../primitives";
66
import { useTheme } from "../../theme";
7-
import { createComponent, RenderPropType } from "../../utils";
7+
import { createComponent, cx, RenderPropType } from "../../utils";
88

99
import TooltipArrow from "./TooltipArrow";
1010

@@ -101,9 +101,11 @@ export const RNTooltip: React.FC<Partial<TooltipProps>> = props => {
101101
{Platform.OS !== "web" && <Popover.Backdrop />}
102102
<Popover.Content>
103103
{hasArrow && <TooltipArrow />}
104-
<Box style={tailwind.style(tooltipTheme.contentWrapper)}>
104+
<Box style={tailwind.style(cx(tooltipTheme.contentWrapper))}>
105105
{typeof content === "string" ? (
106-
<Text style={tailwind.style(tooltipTheme.content)}>{content}</Text>
106+
<Text style={tailwind.style(cx(tooltipTheme.content))}>
107+
{content}
108+
</Text>
107109
) : (
108110
content
109111
)}

src/components/tooltip/TooltipArrow.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ViewStyle } from "react-native";
33
import Svg, { Path } from "react-native-svg";
44

55
import { useTheme } from "../../theme";
6-
import { IconProps } from "../../utils";
6+
import { cx, IconProps } from "../../utils";
77
import { Icon } from "../icon";
88

99
import { TooltipPlacement } from "./Tooltip";
@@ -118,22 +118,22 @@ const TooltipArrow: React.FC<TooltipArrowProps> = ({
118118
arrowProps,
119119
}) => {
120120
const tailwind = useTheme();
121+
const tooltipTheme = useTheme("tooltip");
122+
121123
const additonalArrowStyles = getArrowStyles({
122124
placement: actualPlacement,
123125
height: 12,
124126
width: 12,
125127
});
126128
const arrowStyles: ViewStyle = {
127-
position: "absolute",
128-
height: 12,
129-
width: 12,
129+
...tailwind.style(cx(tooltipTheme.arrow.container)),
130130
...additonalArrowStyles,
131131
...arrowProps?.style,
132132
};
133133
if (actualPlacement?.split(" ")[0] === "top") {
134134
return (
135135
<Icon
136-
color={tailwind.getColor("text-gray-900")}
136+
color={tailwind.getColor(cx(tooltipTheme.arrow.iconColor))}
137137
style={arrowStyles}
138138
icon={<DownArrow />}
139139
size={12}
@@ -142,7 +142,7 @@ const TooltipArrow: React.FC<TooltipArrowProps> = ({
142142
} else if (actualPlacement?.split(" ")[0] === "left") {
143143
return (
144144
<Icon
145-
color={tailwind.getColor("text-gray-900")}
145+
color={tailwind.getColor(cx(tooltipTheme.arrow.iconColor))}
146146
style={arrowStyles}
147147
icon={<RightArrow />}
148148
size={12}
@@ -151,7 +151,7 @@ const TooltipArrow: React.FC<TooltipArrowProps> = ({
151151
} else if (actualPlacement?.split(" ")[0] === "right") {
152152
return (
153153
<Icon
154-
color={tailwind.getColor("text-gray-900")}
154+
color={tailwind.getColor(cx(tooltipTheme.arrow.iconColor))}
155155
style={arrowStyles}
156156
icon={<LeftArrow />}
157157
size={12}
@@ -160,7 +160,7 @@ const TooltipArrow: React.FC<TooltipArrowProps> = ({
160160
} else if (actualPlacement?.split(" ")[0] === "bottom") {
161161
return (
162162
<Icon
163-
color={tailwind.getColor("text-gray-900")}
163+
color={tailwind.getColor(cx(tooltipTheme.arrow.iconColor))}
164164
style={arrowStyles}
165165
icon={<UpArrow />}
166166
size={12}

src/theme/defaultTheme/tooltip.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@ export const tooltip = {
22
contentWrapper:
33
"relative items-center justify-center px-2 py-[5.5px] bg-gray-900 rounded-lg shadow-lg max-w-[160px]",
44
content: "text-cxs text-white-900 font-normal leading-4 text-center",
5+
arrow: {
6+
container: "absolute w-3 h-3",
7+
iconColor: "text-gray-900",
8+
},
59
};

0 commit comments

Comments
 (0)