Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(web-components): add Tooltip component #32852

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

davatron5000
Copy link
Contributor

Previous Behavior

  • No Tooltip component

New Behavior

  • Add Tooltip component
    • Follows the React positioning shorthands
    • Does not currently implement the arrow functionality due to a Shadow DOM limitation with CSS anchor position.

Note

Needs feedback! Tooltip requires CSS anchor position polyfill for older browsers but polyfill is still in-progress.

Related Issue(s)

@fabricteam
Copy link
Collaborator

fabricteam commented Sep 17, 2024

📊 Bundle size report

✅ No changes found

@fabricteam
Copy link
Collaborator

fabricteam commented Sep 17, 2024

🕵 fluentui-web-components-v3 No visual regressions between this PR and main

packages/web-components/src/tooltip/tooltip.options.ts Outdated Show resolved Hide resolved
packages/web-components/src/tooltip/tooltip.styles.ts Outdated Show resolved Hide resolved
* @public
*/
export const template = html<Tooltip>`
<template id="tooltip-${x => x.anchor}" popover aria-hidden="true">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this get properly overridden if someone wants to assign a specific id attribute?

packages/web-components/src/tooltip/tooltip.ts Outdated Show resolved Hide resolved
public connectedCallback(): void {
super.connectedCallback();
if (this.anchorElement) {
this.anchorElement.setAttribute('aria-describedby', `tooltip-${this.anchor}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as with the template: what happens if the id of the tooltip is overridden?

font-size: ${fontSizeBase200};
inset-area: block-start;
line-height: ${lineHeightBase200};
margin: 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, yes it does. [popover] applies a margin: auto in the default stylesheet. So we need this to unset that value otherwise it tries to center itself. Three options:

  1. Keep as margin: 0
  2. Update to margin: unset for clarity
  3. Create two declarations to explicitly unset in the :host(:is([positioning^... rules.

box-sizing: border-box;
color: ${colorNeutralForeground1};
display: inline-flex;
filter: drop-shadow(0 0 2px ${colorNeutralShadowAmbient}) drop-shadow(0 4px 8px ${colorNeutralShadowKey});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a preference for filter over box-shadow?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little future-proofing, but filter will work with the arrow better by going around that shape while box-shadow only does the box. Also keeping parity with the React implementation here.

line-height: ${lineHeightBase200};
margin: 0;
max-width: 240px;
padding: 4px 11px 6px;
Copy link
Contributor

@eljefe223 eljefe223 Sep 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does 11px come from design? Or the react component? Seems out of place

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comes from the React component. The padding-block-* values seem to be font-metric based but yea, not sure where 11px comes from in a token sense. If we wanted to tokenize we could move it up or down 1px.

mNudge: '10px',
m: '12px',

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Component: Tooltip
7 participants