Skip to content

Commit dd6e3e4

Browse files
authored
Extend tooltip color (#613)
1 parent d6a8304 commit dd6e3e4

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@nordcloud/gnui",
33
"description": "Nordcloud Design System - a collection of reusable React components used in Nordcloud's SaaS products",
4-
"version": "8.9.1",
4+
"version": "8.10.0",
55
"license": "MIT",
66
"repository": {
77
"type": "git",

src/components/extendedTooltip/ExtendedTooltip.stories.mdx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,21 @@ import { SVGIcon } from "../svgicon";
409409
<button type="button">Hover Me!</button>
410410
</ExtendedTooltip>
411411
</div>
412+
<div
413+
style={{
414+
display: "flex",
415+
flexDirection: "column",
416+
alignItems: "center",
417+
}}
418+
>
419+
<span style={{ color: "purple", marginBottom: "2rem" }}>Accent</span>
420+
<ExtendedTooltip
421+
caption="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sollicitudin."
422+
status="accent"
423+
>
424+
<button type="button">Hover Me!</button>
425+
</ExtendedTooltip>
426+
</div>
412427
</div>
413428
</Story>
414429
</Canvas>

src/components/extendedTooltip/ExtendedTooltip.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ import {
1111
Placement,
1212
Position,
1313
} from "../../utils/position";
14-
import { setColor } from "../../utils/setcolor";
1514
import { useTooltipHover } from "../tooltip/hooks";
1615

1716
type Timeout = {
1817
showTimeout?: number;
1918
hideTimeout?: number;
2019
};
2120

22-
type Status = "danger" | "notification" | "success" | "warning";
21+
type Status = "accent" | "danger" | "notification" | "success" | "warning";
2322

2423
export type ExtendedTooltipProps = Timeout & {
2524
caption: React.ReactNode;
@@ -171,10 +170,27 @@ const TooltipWrapper = styled.div<TooltipWrapperProps>`
171170

172171
function getColor(status: Status) {
173172
return css`
174-
background-color: ${setColor(status)};
173+
background-color: ${changeStatus(status)};
175174
color: ${theme.color.text.text04};
176175
&:after {
177-
border-top-color: ${setColor(status)};
176+
border-top-color: ${changeStatus(status)};
178177
}
179178
`;
180179
}
180+
181+
const changeStatus = (status?: Status) => {
182+
switch (status) {
183+
case "danger":
184+
return theme.color.interactive.error;
185+
case "warning":
186+
return theme.color.interactive.warning;
187+
case "success":
188+
return theme.color.interactive.success;
189+
case "notification":
190+
return theme.color.interactive.info;
191+
case "accent":
192+
return theme.color.interactive.accent;
193+
default:
194+
return theme.color.interactive.primary;
195+
}
196+
};

0 commit comments

Comments
 (0)