Skip to content

Conversation

@rkaraivanov
Copy link
Member

No description provided.

@rkaraivanov rkaraivanov requested a review from Copilot November 13, 2025 14:30
Copy link
Contributor

Copilot AI left a 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 IgcHighlightComponent with search and navigation capabilities
  • Refactored escapeRegex utility 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

Comment on lines +45 to +50
::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));
Copy link

Copilot AI Nov 13, 2025

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.

Suggested change
::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));

Copilot uses AI. Check for mistakes.

private _createRegex(value: string): RegExp {
return new RegExp(
`${escapeRegex(value)}`,
Copy link

Copilot AI Nov 13, 2025

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.

Suggested change
`${escapeRegex(value)}`,
escapeRegex(value),

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants