Skip to content

Commit 996c30b

Browse files
committed
udpate toolbar button to include tooltip
1 parent 135e9a6 commit 996c30b

File tree

2 files changed

+56
-17
lines changed

2 files changed

+56
-17
lines changed

src/features/common/components/card-toolbar-button/card-toolbar-button.component.tsx

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import { MonoFont } from "@/libs/theme/fonts";
77
export interface CardToolbarButtonComponentProps
88
extends AriaButtonOptions<"span"> {
99
variant: "standard" | "icon";
10+
tooltipText?: string;
1011
}
1112

1213
export const CardToolbarButtonComponent: React.FC<
1314
PropsWithChildren<CardToolbarButtonComponentProps>
1415
> = (props) => {
15-
const { variant, children } = props;
16+
const { variant, tooltipText, children } = props;
1617

1718
const ref = useRef<HTMLButtonElement | null>(null);
1819

@@ -22,20 +23,25 @@ export const CardToolbarButtonComponent: React.FC<
2223
elementType: "span",
2324
preventFocusOnPress: true,
2425
},
25-
ref,
26+
ref
2627
);
2728

2829
return (
29-
<button
30-
{...buttonProps}
31-
type="button"
32-
className={clsx(
33-
variant === "icon" ? styles.button__icon : styles.button__standard,
34-
MonoFont.className,
30+
<div className={styles.button__tooltipContainer}>
31+
<button
32+
{...buttonProps}
33+
type="button"
34+
className={clsx(
35+
variant === "icon" ? styles.button__icon : styles.button__standard,
36+
MonoFont.className
37+
)}
38+
data-style="compact"
39+
>
40+
{children}
41+
</button>
42+
{tooltipText && (
43+
<span className={styles.button__tooltip}>{tooltipText}</span>
3544
)}
36-
data-style="compact"
37-
>
38-
{children}
39-
</button>
45+
</div>
4046
);
4147
};

src/features/common/components/card-toolbar-button/card-toolbar-button.module.scss

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1+
.button__tooltipContainer {
2+
position: relative;
3+
display: inline-block;
4+
&:hover {
5+
.button__tooltip {
6+
opacity: 1;
7+
}
8+
}
9+
}
110
.button__standard {
211
gap: 0.75rem;
12+
border: none;
313
border-radius: 0.25rem;
4-
border: 1px solid var(--color_border_button);
514
color: var(--color_fg_on_button_subtle);
615
font-variant-numeric: slashed-zero;
716
font-feature-settings:
@@ -20,6 +29,12 @@
2029
cursor: not-allowed;
2130
}
2231

32+
&:hover {
33+
background-color: var(--color_bg_layer);
34+
border: 1px solid var(--color_border_default);
35+
transition: all .2s ease-out;
36+
}
37+
2338
padding: 0 0.75rem;
2439
width: 5rem;
2540
height: 2rem;
@@ -46,6 +61,25 @@
4661
}
4762
}
4863

64+
.button__tooltip {
65+
position: absolute;
66+
top: -30px;
67+
left: 50%;
68+
transform: translateX(-50%);
69+
padding: 4px 8px;
70+
color: var(--color_fg_bold);
71+
background-color: var(--color_bg_layer);
72+
border: 1px solid var(--color_border_default);
73+
border-radius: .5rem;
74+
font-size: .75rem;
75+
white-space: nowrap;
76+
opacity: 0;
77+
pointer-events: none;
78+
transition: opacity .2s ease-in-out;
79+
box-shadow: 0 2px 4px rgba(0,0,0,.1);
80+
z-index: 1000;
81+
}
82+
4983
.button__icon {
5084
gap: 0.75rem;
5185
border-radius: 0.25rem;
@@ -72,10 +106,9 @@
72106
}
73107

74108
&:hover {
75-
background-color: var(--color_bg_layer_alternate-bold);
76-
svg {
77-
stroke: var(--color_fg_selected);
78-
}
109+
background-color: var(--color_bg_layer);
110+
border: 1px solid var(--color_border_default);
111+
transition: all .2s ease-out;
79112
}
80113

81114
&:focus-visible {

0 commit comments

Comments
 (0)