Make search filters type-safe and config-driven#2993
Conversation
Co-authored-by: imolorhe <4608143+imolorhe@users.noreply.github.com>
Co-authored-by: imolorhe <4608143+imolorhe@users.noreply.github.com>
Co-authored-by: imolorhe <4608143+imolorhe@users.noreply.github.com>
Co-authored-by: imolorhe <4608143+imolorhe@users.noreply.github.com>
|
Visit the preview URL for this PR (updated for commit 87b10b7): https://altair-gql--pr2993-copilot-add-search-f-ji7b6gt8.web.app (expires Thu, 12 Feb 2026 22:32:57 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 02d6323d75a99e532a38922862e269d63351a6cf |
| } | ||
|
|
||
| .doc-viewer-search-filters { | ||
| margin-top: 15px; |
There was a problem hiding this comment.
| margin-top: 15px; | |
| margin: 10px 0; |
There was a problem hiding this comment.
Applied in commit 87b10b7. Changed container margin to margin: 10px 0 for better vertical spacing.
|
|
||
| .doc-viewer-search-filter-button { | ||
| font-size: fontsize(11); | ||
| padding: 5px 10px; |
There was a problem hiding this comment.
| padding: 5px 10px; | |
| padding: 2px 5px; |
There was a problem hiding this comment.
Applied in commit 87b10b7. Reduced button padding to 2px 5px for a more compact appearance.
| background: rgba(var(--rgb-secondary), 0.15); | ||
| border-color: var(--secondary-color); | ||
| color: var(--secondary-color); | ||
| font-weight: bold; |
There was a problem hiding this comment.
| font-weight: bold; |
There was a problem hiding this comment.
Applied in commit 87b10b7. Removed font-weight: bold from active state for consistency.
|
|
||
| &.active { | ||
| background: rgba(var(--rgb-secondary), 0.15); | ||
| border-color: var(--secondary-color); |
There was a problem hiding this comment.
| border-color: var(--secondary-color); |
There was a problem hiding this comment.
Applied in commit 87b10b7. Removed border-color from active state for cleaner visual hierarchy.
|
|
||
| &:hover { | ||
| background: rgba(var(--rgb-secondary), 0.05); | ||
| border-color: var(--secondary-color); |
There was a problem hiding this comment.
| border-color: var(--secondary-color); |
There was a problem hiding this comment.
Applied in commit 87b10b7. Removed border-color from hover state to simplify the transition.
| .doc-viewer-search-filter-button { | ||
| font-size: fontsize(11); | ||
| padding: 5px 10px; | ||
| border: 1px solid var(--theme-border-color); |
There was a problem hiding this comment.
| border: 1px solid var(--theme-border-color); | |
| border: 0px; |
There was a problem hiding this comment.
Applied in commit 87b10b7. Removed button border for a cleaner look.
Co-authored-by: imolorhe <4608143+imolorhe@users.noreply.github.com>

Refactoring: Type-Safe and Maintainable Search Filters
Changes Implemented
1. Type Safety (
models/index.ts)Created strongly-typed filter system:
2. Translations Moved (
default.json)Moved all filter translation keys from
en-US.jsontodefault.json:DOCS_TYPES_TEXT,DOCS_FIELDS_TEXT,DOCS_QUERIES_TEXTDOCS_MUTATIONS_TEXT,DOCS_SUBSCRIPTIONS_TEXT,DOCS_FILTER_BY_TEXT3. Config-Driven Template (
doc-viewer.component.html)Before (48 lines of duplicated code):
After (17 lines, single loop):
@for (filter of availableSearchFilters; track filter.key) { <button (click)="toggleSearchFilter(filter.key)"> {{ filter.translationKey | translate }} </button> }4. Type-Safe Components
doc-viewer.component.ts: UsesSet<DocSearchFilterKey>instead ofSet<string>doc-viewer-search-results.component.ts: Uses typed filter parameterDocSearchFilterKeytype5. Updated Tests
DocSearchFilterKeyimport to test files6. Style Adjustments (
_doc-viewer.scss)5px 10pxto2px 5pxfor more compact appearance1px solidto0pxfor cleaner lookborder-colortransitions in hover and active statesfont-weight: boldfrom active state for consistencymargin-top: 15pxtomargin: 10px 0Benefits
✅ Type Safety: Compiler catches typos and invalid filter keys at build time
✅ Maintainability: Adding new filters only requires updating the
DOC_SEARCH_FILTERSarray✅ DRY Principle: Reduced template code duplication from 48 lines to 17 lines (64% reduction)
✅ Single Source of Truth: Filter configuration centralized in one location
✅ Better i18n Structure: Translation keys properly organized in
default.json✅ Cleaner UI: More compact button styling with simplified visual states
✅ No Behavior Changes: Purely refactoring - no runtime behavior changes
Files Changed
packages/altair-app/src/app/modules/altair/components/doc-viewer/models/index.ts- Added types and configpackages/altair-app/src/app/modules/altair/components/doc-viewer/doc-viewer/doc-viewer.component.ts- Type-safe implementationpackages/altair-app/src/app/modules/altair/components/doc-viewer/doc-viewer/doc-viewer.component.html- Config-driven templatepackages/altair-app/src/app/modules/altair/components/doc-viewer/doc-viewer-search-results/doc-viewer-search-results.component.ts- Typed filterspackages/altair-app/src/scss/components/_doc-viewer.scss- Style adjustmentspackages/altair-app/src/assets/i18n/default.json- Added translationspackages/altair-app/src/assets/i18n/en-US.json- Removed duplicate translationsOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.