Skip to content

Commit 2d18d22

Browse files
authored
chore(tooltip.tsx): add property borderColor (#618)
* chore(tooltip.tsx): add property borderColor * chore(tooltip.tsx): apply borderColor to arrow
1 parent 4137f05 commit 2d18d22

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/components/Tooltip/Tooltip.stories.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,12 @@ WithNoArrow.args = {
5959
as: "div",
6060
showArrow: false,
6161
};
62+
63+
export const WithBorderColor = Default.bind({});
64+
65+
WithBorderColor.args = {
66+
placement: "top",
67+
content: "This is a tooltip with a border color",
68+
as: "div",
69+
borderColor: "red",
70+
};

src/components/Tooltip/Tooltip.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export type TooltipProps = TippyProps & {
3131
content: TippyProps["content"];
3232
maxWidth?: number;
3333
showArrow?: boolean;
34+
borderColor?: string;
3435
};
3536

3637
const Tooltip: FC<TooltipProps> = ({
@@ -42,6 +43,7 @@ const Tooltip: FC<TooltipProps> = ({
4243
maxWidth = 350,
4344
interactive = true,
4445
showArrow = true,
46+
borderColor,
4547
...rest
4648
}) => {
4749
const Tag = as;
@@ -59,7 +61,7 @@ const Tooltip: FC<TooltipProps> = ({
5961
<div
6062
className="tooltip"
6163
role="alert"
62-
css={(theme) => tooltipContainer(maxWidth, theme)}
64+
css={(theme) => tooltipContainer(maxWidth, theme, borderColor)}
6365
{...attrs}
6466
>
6567
{content}

src/components/Tooltip/styles.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import { css, Theme, SerializedStyles } from "@emotion/react";
33
export const tooltipContainer = (
44
maxWidth: number,
55
{ typeScaleSizes, tooltip }: Theme,
6+
borderColor?: string,
67
): SerializedStyles => {
78
return css`
89
max-width: ${maxWidth}px;
910
background: ${tooltip.background};
10-
border: 1px solid ${tooltip.border};
11+
border: 1px solid ${borderColor || tooltip.border};
1112
border-radius: 5px;
1213
color: ${tooltip.color};
1314
padding: 0.5rem;
@@ -44,7 +45,7 @@ export const tooltipContainer = (
4445
#arrow::before {
4546
content: "";
4647
transform: rotate(45deg);
47-
background: ${tooltip.border};
48+
background: ${borderColor || tooltip.border};
4849
}
4950
`;
5051
};

0 commit comments

Comments
 (0)