-
Notifications
You must be signed in to change notification settings - Fork 71
[LG-3416] feat: Icon - added title element #3245
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
Conversation
🦋 Changeset detectedLatest commit: 2ef518f The changes in this PR will be included in the next version bump. This PR includes changesets to release 73 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Size Change: +176 kB (+10.86%) Total Size: 1.8 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements native tooltip support for icons by adding a <title> SVG element when a title prop is provided, improving accessibility in accordance with LG-3416.
Key changes:
- Icons now render a
<title>element inside the SVG when thetitleprop is passed - Accessibility handling updated to use
aria-labelledbyreferencing the title element's ID instead of the HTMLtitleattribute - Build system refactored to generate icon components directly rather than wrapping them with
createGlyphComponent
Reviewed Changes
Copilot reviewed 15 out of 200 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/icon/src/glyphCommon.ts | Updated accessibility prop generation to handle title element with ID and aria-labelledby |
| packages/icon/src/Icon.spec.tsx | Added tests for title element rendering and aria-labelledby behavior |
| packages/icon/scripts/prebuild/svgrTemplate.ts | Modified template to inject title element and useIdAllocator hook into generated components |
| packages/icon/src/glyphs/index.ts | Removed dynamic component creation, now exports raw SVG components |
| packages/icon/scripts/prebuild/indexTemplate.ts | Added new template for generated component exports |
| packages/icon/scripts/prebuild/index.ts | Added generation of index file for component exports |
| packages/icon/src/Icon.tsx | Changed import to use generated components directly |
| packages/icon/src/createGlyphComponent.tsx | Marked as deprecated, updated to support new title functionality |
| packages/icon/scripts/build/compare-checksum.ts | Excluded index file from icon name collection |
| packages/icon-button/src/IconButton/IconButton.spec.tsx | Updated test to verify title element instead of title attribute |
| packages/icon/package.json | Added @leafygreen-ui/hooks dependency |
| packages/icon/tsconfig.json | Added hooks package reference |
| packages/icon/src/Icon.stories.tsx | Exposed title control in Storybook |
| .changeset/puny-paws-yell.md | Documented the feature addition |
| packages/emotion/src/version.ts | Version bump |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
| import { LGGlyph, SVGR } from './types'; | ||
|
|
||
| /** | ||
| * @deprecated - No longer needed for icon generation. Keeping it for backwards compatibility. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just remembered that this is being used in other components and by consumers, so I'm not sure if we want to deprecate it. If you check out the readme, we encourage consumers to use this util to create a custom glyph that behaves like a leafygreen icon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth bringing this up in slack with the team to see if we want to continue to support this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do! I originally synced with @TheSonOfThomp before he went on PTO and we agreed that we can mark this as deprecated. I wasn't aware we were encourage consumers to actively use it. But good idea, I'll bring it up with the team :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good callout @shaneeza. The reason we initially decided to deprecate was because this is doing the same thing as the prebuild step, but differently (notably, we don't inject the <title> element in this function)
I agree with Shaneeza that we should probably keep this un-deprecated for now, and look into ways to consolidate and DRY the prebuild steps and this function.
@adamrasheed I don't think DRY-ing should hold back this PR. Could you open a ticket and replace the @deprecated with a note on how this differs from prebuild + a link to that ticket?
|
Coverage after merging ar/LG-3416-icon-title into main will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
✍️ Proposed changes
🎟 Jira ticket: Add native tooltip on icons
This PR updates the icon component to include a
<title>element inside the SVG when a title prop value is passed in✅ Checklist
For new components
For bug fixes, new features & breaking changes
pnpm changesetand documented my changes🧪 How to test changes