Meta: add tooltipped and addToolTip helpers#9449
Conversation
Agent-Logs-Url: https://github.com/refined-github/refined-github/sessions/1965ca98-3688-4757-99bb-0b656a9ee0c1 Co-authored-by: fregante <1402241+fregante@users.noreply.github.com>
…rtions Agent-Logs-Url: https://github.com/refined-github/refined-github/sessions/1965ca98-3688-4757-99bb-0b656a9ee0c1 Co-authored-by: fregante <1402241+fregante@users.noreply.github.com>
…pacing Agent-Logs-Url: https://github.com/refined-github/refined-github/sessions/1965ca98-3688-4757-99bb-0b656a9ee0c1 Co-authored-by: fregante <1402241+fregante@users.noreply.github.com>
… before shortcuts Agent-Logs-Url: https://github.com/refined-github/refined-github/sessions/1965ca98-3688-4757-99bb-0b656a9ee0c1 Co-authored-by: fregante <1402241+fregante@users.noreply.github.com>
addToolTip helper for the tool-tip custom element
…ng DOM elements Agent-Logs-Url: https://github.com/refined-github/refined-github/sessions/80d53c48-921e-4da6-ab3a-998c4453d3ad Co-authored-by: fregante <1402241+fregante@users.noreply.github.com>
addToolTip helper for the tool-tip custom elementtooltipped and addToolTip helpers for the tool-tip custom element
Agent-Logs-Url: https://github.com/refined-github/refined-github/sessions/1e4272d0-d45e-4e05-9dfd-f4846d66cfab Co-authored-by: fregante <1402241+fregante@users.noreply.github.com>
tooltipped and addToolTip helpers for the tool-tip custom elementtooltipped and addToolTip helper
tooltipped and addToolTip helpertooltipped and addToolTip helpers
Agent-Logs-Url: https://github.com/refined-github/refined-github/sessions/d3b309f7-fd60-42d5-b103-135bcb248ab0 Co-authored-by: fregante <1402241+fregante@users.noreply.github.com>
| element.id ||= crypto.randomUUID(); | ||
|
|
||
| const tooltipId = crypto.randomUUID(); | ||
| element.setAttribute('aria-labelledby', tooltipId); |
There was a problem hiding this comment.
Not sure we always want that, but ok for now
Co-authored-by: Grigory <grigory.orlov.set@gmail.com>
| padding: var(--base-size-2, 0.125rem); | ||
| line-height: var(--base-size-8, 0.5rem); | ||
| min-width: var(--base-size-16, 1rem); |
There was a problem hiding this comment.
I don't think we should use fuchsia-like fallbacks here. If our styles are automatically adapted, good. If not, that's fine too.
There was a problem hiding this comment.
Only because it's a lot of values and it's easier to just keep the whole block in sync.
But in practice fuchsia is exactly the notification we need to force us to update the whole rule when it becomes outdated.
|
Good changes 👌 |
| padding: var(--base-size-2, 0.125rem); | ||
| line-height: var(--base-size-8, 0.5rem); | ||
| min-width: var(--base-size-16, 1rem); |
There was a problem hiding this comment.
Only because it's a lot of values and it's easier to just keep the whole block in sync.
But in practice fuchsia is exactly the notification we need to force us to update the whole rule when it becomes outdated.
|
Handy helpers: easy to use and make updates and migrations easier. Good job |
|
🙌 there's a PR coming to attempt an automated upgrade. Let's see how that goes |




Replaces repetitive manual UUID wiring +
<tool-tip>JSX boilerplate with two focused utility functions. Previously each usage required twocrypto.randomUUID()calls, manualid/for/aria-labelledbylinking, and ~12 lines of JSX per tooltip.New helpers:
source/helpers/tooltip.tsxtooltipped(content, element)— for building JSX trees with new elements. Returns[element, tooltip]as a tuple for direct inline embedding:addToolTip(content, element)— for elements already in the DOM. Inserts the tooltip immediately after the element and returnsvoid. Throws if the element has no parent node (usetooltippedinstead):Both helpers:
idto the element if absentaria-labelledbyon the element pointing to the tooltipshortcutkeys as<kbd>elements ('g b'→<kbd>g</kbd> <kbd>b</kbd>)Refactored
update-pr-from-base-branch.tsx—<button>inlined directly intotooltipped(), no intermediateconsttable-input.tsx—<summary>inlined directly intotooltipped()inside the<details>JSX treeunwrap-unnecessary-dropdowns.tsx—tooltippedused inline via ternary expressionType
globals.d.ts: addedfor?: stringtotool-tipJSX intrinsic typeTest URLs
Screenshot
AI GOT NO EYES