Skip to content

Commit 613d65d

Browse files
authored
Allow to style ExtendedTooltip via props (#765)
* allow styling of ExtendedTooltip * bumb version * restore removed icon from stories
1 parent fa4ee2f commit 613d65d

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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": "11.2.4",
4+
"version": "11.2.5",
55
"license": "MIT",
66
"repository": {
77
"type": "git",

src/components/extendedTooltip/ExtendedTooltip.tsx

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,18 @@ type Timeout = {
2020

2121
type Status = "accent" | "danger" | "notification" | "success" | "warning";
2222

23-
export type ExtendedTooltipProps = Timeout & {
24-
caption: React.ReactNode;
25-
children: React.ReactNode;
26-
placement?: Placement;
27-
position?: Position;
28-
margin?: Margin;
29-
status?: Status;
30-
zIndex?: number;
31-
display?: Display;
32-
adjustPositionToViewportSize?: boolean;
33-
};
23+
export type ExtendedTooltipProps = React.HTMLAttributes<HTMLDivElement> &
24+
Timeout & {
25+
caption: React.ReactNode;
26+
children: React.ReactNode;
27+
placement?: Placement;
28+
position?: Position;
29+
margin?: Margin;
30+
status?: Status;
31+
zIndex?: number;
32+
display?: Display;
33+
adjustPositionToViewportSize?: boolean;
34+
};
3435

3536
export function ExtendedTooltip({
3637
caption,
@@ -44,6 +45,7 @@ export function ExtendedTooltip({
4445
zIndex = theme.zindex.sticky,
4546
display,
4647
adjustPositionToViewportSize = false,
48+
...rest
4749
}: ExtendedTooltipProps) {
4850
const wrapperRef = React.useRef<HTMLDivElement>(null);
4951
const tooltipRef = React.useRef<HTMLDivElement>(null);
@@ -80,7 +82,7 @@ export function ExtendedTooltip({
8082
return <>{children}</>;
8183
}
8284

83-
const style = {
85+
const positionStyle = {
8486
...getStyle({
8587
wrapperDimensions,
8688
tooltipDimensions,
@@ -105,18 +107,19 @@ export function ExtendedTooltip({
105107
caption={caption}
106108
tooltipRef={tooltipRef}
107109
status={status}
108-
style={style}
110+
positionStyle={positionStyle}
111+
{...rest}
109112
/>
110113
{children}
111114
</TooltipWrapper>
112115
);
113116
}
114117

115-
type TooltipProps = {
118+
type TooltipProps = React.HTMLAttributes<HTMLDivElement> & {
116119
caption: React.ReactNode;
117120
isHovered: boolean;
118121
tooltipRef: React.RefObject<HTMLDivElement>;
119-
style: { top?: number; left?: number; zIndex?: number };
122+
positionStyle: { top?: number; left?: number; zIndex?: number };
120123
status?: Status;
121124
};
122125

@@ -125,16 +128,19 @@ function Tooltip({
125128
isHovered,
126129
tooltipRef,
127130
status,
131+
positionStyle,
128132
style,
133+
...rest
129134
}: TooltipProps) {
130-
const { zIndex = theme.zindex.sticky } = style;
135+
const { zIndex = theme.zindex.sticky } = positionStyle;
131136
return isHovered
132137
? ReactDOM.createPortal(
133138
<StyledTooltip
134139
ref={tooltipRef}
135140
status={status}
136-
style={style}
141+
style={{ ...positionStyle, ...style }}
137142
zIndex={zIndex}
143+
{...rest}
138144
>
139145
{caption}
140146
</StyledTooltip>,

0 commit comments

Comments
 (0)