forked from CoreBunch/Instatic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTooltip.module.css
More file actions
106 lines (90 loc) · 3.36 KB
/
Copy pathTooltip.module.css
File metadata and controls
106 lines (90 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
* Tooltip bubble — fixed-position, portal-rendered.
*
* Position is applied via CSS custom properties injected through inline style:
* --tooltip-x / --tooltip-y translate offset from top-left
* --tooltip-arrow-offset perpendicular position of the arrow along the edge
*
* The .visible class is added after the first layout measurement so the fade-in
* only plays once position is known (prevents flash at 0,0).
*
* No !important, no hardcoded colours, no Tailwind utilities.
*/
/* ── Bubble ─────────────────────────────────────────────────────────────────── */
.bubble {
position: fixed;
top: 0;
left: 0;
--tooltip-x: 0px;
--tooltip-y: 0px;
--tooltip-arrow-offset: 50%;
transform: translate3d(var(--tooltip-x), var(--tooltip-y), 0);
z-index: var(--tooltip-z-index);
padding: var(--space-xs) var(--space-m);
background: var(--bg-body);
color: var(--text-bright);
border: 1px solid var(--overlay-5);
border-radius: var(--tooltip-radius);
box-shadow: var(--shadow-tooltip);
font-size: var(--text-s);
font-weight: 500;
line-height: 1.3;
letter-spacing: 0.01em;
max-width: 240px;
word-wrap: break-word;
pointer-events: none;
user-select: none;
opacity: 0;
transition: opacity 80ms ease;
}
.visible {
opacity: 1;
}
/* ── Arrow ──────────────────────────────────────────────────────────────────── */
/*
* 6×6px square, rotated 45° to form a diamond ◇.
* Positioned so one corner pokes outside the bubble edge.
* Background matches the bubble; border on the two outward-facing sides
* creates the illusion of a 1px outlined triangle peeking out.
*/
.arrow {
position: absolute;
width: 6px;
height: 6px;
background: var(--bg-body);
transform: rotate(45deg);
}
/* Tooltip above trigger → arrow at bottom, pointing down */
.bubble[data-side='top'] .arrow {
bottom: -3px;
left: calc(var(--tooltip-arrow-offset) - 3px);
border-right: 1px solid var(--overlay-5);
border-bottom: 1px solid var(--overlay-5);
}
/* Tooltip below trigger → arrow at top, pointing up */
.bubble[data-side='bottom'] .arrow {
top: -3px;
left: calc(var(--tooltip-arrow-offset) - 3px);
border-top: 1px solid var(--overlay-5);
border-left: 1px solid var(--overlay-5);
}
/* Tooltip left of trigger → arrow at right edge, pointing right */
.bubble[data-side='left'] .arrow {
right: -3px;
top: calc(var(--tooltip-arrow-offset) - 3px);
border-top: 1px solid var(--overlay-5);
border-right: 1px solid var(--overlay-5);
}
/* Tooltip right of trigger → arrow at left edge, pointing left */
.bubble[data-side='right'] .arrow {
left: -3px;
top: calc(var(--tooltip-arrow-offset) - 3px);
border-bottom: 1px solid var(--overlay-5);
border-left: 1px solid var(--overlay-5);
}
/* ── Reduced motion ─────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
.bubble {
transition: none;
}
}