@@ -374,7 +430,7 @@ export class WccSidebar extends DeesElement {
}}
>
featured_video
-
${elementName}
+
${this.highlightMatch(elementName)}
`;
}
@@ -402,6 +458,29 @@ export class WccSidebar extends DeesElement {
this.expandedElements = newSet;
}
+ private handleSearchInput(e: Event) {
+ const input = e.target as HTMLInputElement;
+ this.searchQuery = input.value;
+ this.dispatchEvent(new CustomEvent('searchChanged', { detail: this.searchQuery }));
+ }
+
+ private matchesSearch(name: string): boolean {
+ if (!this.searchQuery) return true;
+ return name.toLowerCase().includes(this.searchQuery.toLowerCase());
+ }
+
+ private highlightMatch(text: string): TemplateResult {
+ if (!this.searchQuery) return html`${text}`;
+ const lowerText = text.toLowerCase();
+ const lowerQuery = this.searchQuery.toLowerCase();
+ const index = lowerText.indexOf(lowerQuery);
+ if (index === -1) return html`${text}`;
+ const before = text.slice(0, index);
+ const match = text.slice(index, index + this.searchQuery.length);
+ const after = text.slice(index + this.searchQuery.length);
+ return html`${before}