-
Notifications
You must be signed in to change notification settings - Fork 7
feat: Added highlight container #1880
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
base: master
Are you sure you want to change the base?
Conversation
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 introduces a new IgcHighlightComponent that enables efficient text searching and highlighting within projected content. The component leverages the CSS Custom Highlight API for performant text highlighting.
Key Changes:
- Added
IgcHighlightComponentwith search and navigation capabilities - Refactored
escapeRegexutility into a shared function - Integrated component into the library's component registry and exports
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| stories/highlight.stories.ts | Storybook stories demonstrating the highlight component with various use cases including search UI and performance scenarios |
| src/index.ts | Exported the new IgcHighlightComponent for public API access |
| src/components/highlight/service.ts | Core service implementing highlight logic using CSS Custom Highlight API with navigation and search capabilities |
| src/components/highlight/highlight.ts | Main component class exposing search properties and navigation methods |
| src/components/highlight/highlight.spec.ts | Unit tests covering component initialization, search functionality, and navigation behavior |
| src/components/date-time-input/date-util.ts | Refactored to use shared escapeRegex utility function |
| src/components/common/util.ts | Added shared escapeRegex utility function and updated scrollIntoView signature |
| src/components/common/definitions/defineAllComponents.ts | Registered the new highlight component in the component registry |
| ::highlight(${this._key}) { | ||
| background-color: var(--resting-background, hsla(var(--ig-gray-300), var(--ig-gray-a))); | ||
| color: var(--resting-color, white); | ||
| } | ||
| ::highlight(${this._activeKey}) { | ||
| background-color: var(--active-background, hsla(333deg , calc( 78% * 1.23), calc( 49% * 1.34), 1)); |
Copilot
AI
Nov 13, 2025
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.
The default active background color uses inline calculations that are difficult to understand and maintain. Consider extracting this to a named constant or CSS custom property with a descriptive name that explains what color this represents.
| ::highlight(${this._key}) { | |
| background-color: var(--resting-background, hsla(var(--ig-gray-300), var(--ig-gray-a))); | |
| color: var(--resting-color, white); | |
| } | |
| ::highlight(${this._activeKey}) { | |
| background-color: var(--active-background, hsla(333deg , calc( 78% * 1.23), calc( 49% * 1.34), 1)); | |
| :host { | |
| --igc-highlight-active-bg-default: hsla(333deg, calc(78% * 1.23), calc(49% * 1.34), 1); | |
| } | |
| ::highlight(${this._key}) { | |
| background-color: var(--resting-background, hsla(var(--ig-gray-300), var(--ig-gray-a))); | |
| color: var(--resting-color, white); | |
| } | |
| ::highlight(${this._activeKey}) { | |
| background-color: var(--active-background, var(--igc-highlight-active-bg-default)); |
|
|
||
| private _createRegex(value: string): RegExp { | ||
| return new RegExp( | ||
| `${escapeRegex(value)}`, |
Copilot
AI
Nov 13, 2025
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.
The template literal wrapping escapeRegex(value) is unnecessary. You can directly pass escapeRegex(value) as the first argument to RegExp constructor.
| `${escapeRegex(value)}`, | |
| escapeRegex(value), |
No description provided.