Skip to content

Commit 5576813

Browse files
authored
Merge pull request #47 from posit-dev/feat-tippy-tooltips
feat: utilize Tippy.js tooltips throughout
2 parents 530bb6d + 0c520f4 commit 5576813

6 files changed

Lines changed: 606 additions & 11 deletions

File tree

‎ROADMAP.md‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,6 @@ Add icon support for sidebar and navbar entries.
133133
- Dark mode color adaptation
134134
- Consistent sizing and alignment across navigation levels
135135

136-
### Custom Tooltips
137-
138-
Replace native browser `title` tooltips with styled, consistent tooltips.
139-
140-
- Instant appearance (no 400ms delay)
141-
- Consistent styling across all browsers
142-
- Dark mode support
143-
- Smart positioning (i.e., avoids viewport edges)
144-
- Optional arrow pointing to element
145-
- Convert existing `title` attributes site-wide (copy buttons, dark mode toggle, GitHub widget, page metadata, citation links)
146-
147136
---
148137

149138
## Planned — Medium Term

‎great_docs/assets/great-docs.scss‎

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4085,6 +4085,192 @@ html[data-bs-theme="dark"] .gd-page-metadata {
40854085
}
40864086

40874087

4088+
/*---------------------------------------------------------------------------
4089+
* Custom Tooltips (Tippy.js) — Material Filling Effect
4090+
* Replaces native browser title tooltips with instant, styled tooltips.
4091+
*---------------------------------------------------------------------------*/
4092+
4093+
/* Base Tippy.js overrides for Great Docs theming */
4094+
.tippy-box {
4095+
/* Material-inspired styling */
4096+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
4097+
font-size: 0.8125rem;
4098+
line-height: 1.4;
4099+
border-radius: 6px;
4100+
font-weight: 500;
4101+
/* Material filling effect: clip overflow for smooth fill animation */
4102+
overflow: hidden;
4103+
}
4104+
4105+
/* Light mode theme — Material Filling Effect */
4106+
.tippy-box[data-theme~="gd-material"] {
4107+
background-color: $gray-800;
4108+
color: $white;
4109+
box-shadow:
4110+
0 4px 14px -2px rgba($black, 0.2),
4111+
0 2px 4px -1px rgba($black, 0.1);
4112+
4113+
/* Material filling effect background */
4114+
&::before {
4115+
content: "";
4116+
position: absolute;
4117+
inset: 0;
4118+
background: linear-gradient(
4119+
135deg,
4120+
rgba($white, 0.12) 0%,
4121+
rgba($white, 0) 50%
4122+
);
4123+
pointer-events: none;
4124+
opacity: 0;
4125+
transition: opacity 150ms ease-in-out;
4126+
}
4127+
4128+
&[data-state="visible"]::before {
4129+
opacity: 1;
4130+
}
4131+
4132+
/* Arrow styling */
4133+
> .tippy-arrow {
4134+
color: $gray-800;
4135+
}
4136+
4137+
> .tippy-arrow::before {
4138+
/* Subtle shadow on arrow */
4139+
filter: drop-shadow(0 1px 2px rgba($black, 0.15));
4140+
}
4141+
4142+
/* Content padding */
4143+
> .tippy-content {
4144+
padding: 6px 10px;
4145+
position: relative;
4146+
z-index: 1;
4147+
}
4148+
}
4149+
4150+
/* Dark mode theme — Material Filling Effect */
4151+
.tippy-box[data-theme~="gd-material-dark"] {
4152+
background-color: $gray-200;
4153+
color: $gray-900;
4154+
box-shadow:
4155+
0 4px 14px -2px rgba($black, 0.35),
4156+
0 2px 4px -1px rgba($black, 0.2);
4157+
4158+
/* Material filling effect background */
4159+
&::before {
4160+
content: "";
4161+
position: absolute;
4162+
inset: 0;
4163+
background: linear-gradient(
4164+
135deg,
4165+
rgba($black, 0.06) 0%,
4166+
rgba($black, 0) 50%
4167+
);
4168+
pointer-events: none;
4169+
opacity: 0;
4170+
transition: opacity 150ms ease-in-out;
4171+
}
4172+
4173+
&[data-state="visible"]::before {
4174+
opacity: 1;
4175+
}
4176+
4177+
/* Arrow styling */
4178+
> .tippy-arrow {
4179+
color: $gray-200;
4180+
}
4181+
4182+
> .tippy-arrow::before {
4183+
filter: drop-shadow(0 1px 3px rgba($black, 0.25));
4184+
}
4185+
4186+
/* Content padding */
4187+
> .tippy-content {
4188+
padding: 6px 10px;
4189+
position: relative;
4190+
z-index: 1;
4191+
}
4192+
}
4193+
4194+
/* Animation: shift-away (included with Tippy but customized) */
4195+
.tippy-box[data-animation="shift-away"][data-state="hidden"] {
4196+
opacity: 0;
4197+
}
4198+
4199+
.tippy-box[data-animation="shift-away"][data-state="hidden"][data-placement^="top"] {
4200+
transform: translateY(6px);
4201+
}
4202+
4203+
.tippy-box[data-animation="shift-away"][data-state="hidden"][data-placement^="bottom"] {
4204+
transform: translateY(-6px);
4205+
}
4206+
4207+
.tippy-box[data-animation="shift-away"][data-state="hidden"][data-placement^="left"] {
4208+
transform: translateX(6px);
4209+
}
4210+
4211+
.tippy-box[data-animation="shift-away"][data-state="hidden"][data-placement^="right"] {
4212+
transform: translateX(-6px);
4213+
}
4214+
4215+
/* Mounted state for material fill transition */
4216+
.gd-tooltip-mounted .tippy-box::before {
4217+
animation: gd-tooltip-fill 200ms ease-out forwards;
4218+
}
4219+
4220+
@keyframes gd-tooltip-fill {
4221+
from {
4222+
opacity: 0;
4223+
transform: scale(0.95);
4224+
}
4225+
to {
4226+
opacity: 1;
4227+
transform: scale(1);
4228+
}
4229+
}
4230+
4231+
/* Arrow placement adjustments */
4232+
.tippy-box[data-placement^="top"] > .tippy-arrow {
4233+
bottom: -5px;
4234+
}
4235+
4236+
.tippy-box[data-placement^="bottom"] > .tippy-arrow {
4237+
top: -5px;
4238+
}
4239+
4240+
.tippy-box[data-placement^="left"] > .tippy-arrow {
4241+
right: -5px;
4242+
}
4243+
4244+
.tippy-box[data-placement^="right"] > .tippy-arrow {
4245+
left: -5px;
4246+
}
4247+
4248+
/* Ensure tooltips appear above other elements */
4249+
.tippy-popper,
4250+
[data-tippy-root] {
4251+
z-index: 9999 !important;
4252+
}
4253+
4254+
/* Interactive tooltip styling (for tooltips with links, etc.) */
4255+
.tippy-box[data-theme~="gd-material"] a,
4256+
.tippy-box[data-theme~="gd-material-dark"] a {
4257+
color: inherit;
4258+
text-decoration: underline;
4259+
text-underline-offset: 2px;
4260+
}
4261+
4262+
.tippy-box[data-theme~="gd-material"] a:hover,
4263+
.tippy-box[data-theme~="gd-material-dark"] a:hover {
4264+
opacity: 0.85;
4265+
}
4266+
4267+
/* Disable native tooltips on elements that have Tippy */
4268+
[data-tippy-content] {
4269+
/* Ensure no lingering title attribute displays */
4270+
title: none;
4271+
}
4272+
4273+
40884274
/*-- scss:functions --*/
40894275

40904276
/*-- scss:uses --*/

‎great_docs/assets/post-render.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2547,6 +2547,14 @@ def fix_script_paths():
25472547
content = content.replace(old_page_meta, new_page_meta)
25482548
modified = True
25492549

2550+
# Fix tooltips.js path
2551+
old_tooltips = '<script src="tooltips.js"></script>'
2552+
new_tooltips = f'<script src="{prefix}tooltips.js"></script>'
2553+
2554+
if old_tooltips in content:
2555+
content = content.replace(old_tooltips, new_tooltips)
2556+
modified = True
2557+
25502558
if modified:
25512559
with open(html_file, "w") as file:
25522560
file.write(content)

0 commit comments

Comments
 (0)