feat(tooltip): s2 fidelity#6331
Conversation
…web-components into seckles/tooltip-s2-fidelity
|
📚 Branch Preview Links🔍 First Generation Visual Regression Test ResultsWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
Deployed to Azure Blob Storage: If the changes are expected, update the |
| * Pixel-accurate anchoring requires `PlacementController` (additive phase); these stories | ||
| * temporarily use Floating UI directly to verify visual appearance across placements. | ||
| */ | ||
| export const Placements: Story = { |
There was a problem hiding this comment.
Love this display here ✨
| :host([placement="bottom-start"]) .swc-Tooltip, | ||
| :host([placement="bottom-end"]) .swc-Tooltip { |
There was a problem hiding this comment.
Let's talk about these compound placement variants (bottom-start, bottom-end, right-top, etc. etc.)! Will they stay or go in 2nd-gen?
It feels reasonable to keep the placements simple (top, bottom, left, right, start, end only) as you have demonstrated currently, and that's what matches the design and React. This would definitely be something we'd want to communicate to consumers at the appropriate phase in the migration.
I also see that React has a cool crossOffset property that allows you to adjust tip placement, which could be something we think about eventually? Seems like that would be different than our current offset.
If we have no plans to implement compound placement variants later, can we cut out the selectors?
| - [x] Copy S2 source from `spectrum-css/components/tooltip/index.css` (`spectrum-two` branch, not `/dist`) into `tooltip.css` as baseline | ||
| - [x] Map Spectrum CSS selectors to SWC equivalents following CSS selector guidance in CONTRIBUTOR_DOCS | ||
| - [x] Remove `.spectrum-Tooltip-typeIcon` styles (no icon in S2) | ||
| - [x] Add all six logical placement classes, consolidated with their non-logical equivalents: `start`, `start-top`, `start-bottom`, `end`, `end-top`, `end-bottom` |
There was a problem hiding this comment.
I asked about this in a different comment, but are we implementing the combined/compound placements like start-top, start-bottom, etc.?
|
|
||
| position: absolute; | ||
| inset: auto; | ||
| max-inline-size: min(100%, token("tooltip-maximum-width")); |
There was a problem hiding this comment.
The reason we add these extra styles to the :host here is because we need them on the popover, is that right? Could be worth documenting the exception in the style guide docs for future work.
| ```css | ||
| .swc-Tooltip { | ||
| --_swc-tooltip-border-radius: token("corner-radius-400"); | ||
| --_swc-tooltip-tip-corner-offset: var(--_swc-tooltip-border-radius); | ||
|
|
||
| border-radius: var(--_swc-tooltip-border-radius); | ||
| } | ||
|
|
||
| :host([placement="top-start"]) .swc-Tooltip-tip { | ||
| inset-inline-start: var(--_swc-tooltip-tip-corner-offset); | ||
| } | ||
| ``` |
There was a problem hiding this comment.
I can see this example becoming confusing for the agent, since we aren't really doing this in tooltip.css, is there another example in a shipped component we could use to illustrate this instead?
| /* ───────────────────────────────────────────────────────────────────────────── | ||
| HOST | ||
| Reset browser UA popover styles. All visual styles live on .swc-Tooltip. | ||
| PlacementController (additive phase) will apply inset/left/top for | ||
| positioning. | ||
| ───────────────────────────────────────────────────────────────────────────── */ |
There was a problem hiding this comment.
I like these banner comments, could be a place to expand documentation on comment conventions and section headers
| } | ||
|
|
||
| /* ───────────────────────────────────────────────────────────────────────────── | ||
| BASE TOOLTIP |
There was a problem hiding this comment.
A nit, but this could mention these are styles for top placement, I know you mention it above styles for placement margins but initially I didn't see that one.
|
|
||
| @media (forced-colors: active) { | ||
| .swc-Tooltip { | ||
| border: 1px solid CanvasText; |
Description
Implements the 2nd-gen
<swc-tooltip>Phase 5 — Styling: full S2 token stylesheet, RTL-aware placement margins and open-state animations, directional tip geometry (physicalright/left, logicalstart/end), forced-colors block, scaffold Storybook storiesNotable API change from the feature branch plan
This is not style impacting or demonstrated yet in this work, but was discovered during this phase
The
delayed: boolean(defaultfalse, opt-in) property has been replaced withdelay: number(default1500, warm-up inherent). Settingdelay="0"opts out of warm-up delay. This aligns with Spectrum's intent that warm-up is the default behavior for tooltips, not an add-on. The 1st-gen behavioral difference is called out in the migration plan.Infrastructure and Docs/Skills Changes
These will be moved to a new PR to merge into main ASAP
stylelint.config.js— All CSS system color keywords (CanvasText,ButtonFace, etc.) added to thescale-unlimited/declaration-strict-valueallowlist so forced-colors overrides can assign system colors without triggering the design token lint rule.linters/stylelint-property-order.js— Missing transition property added to order definition.Motivation and context
Continues the Spectrum 2 component migration workstream. This branch delivers the full implementation through styling.
Related issue(s)
Manual review test cases
Variant colors are correct
Variantsstory, validate that:Handles text wrapping, matching tooltip content size
Anatomystory, validate:Placement margins and tip direction are correct for all six placements
top,bottom,left,right,start,end)RTL placement is correct for logical placements
Placementsstory, set "RTL" from the Storybook toolbarstartandendplacementsForced-colors (high contrast mode) renders correctly
Device review
Accessibility testing checklist
Keyboard (required)
Screen reader (required)
HoverController