Skip to content

Commit

Permalink
Type header components (hashicorp-forge#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffdaley authored Jun 9, 2023
1 parent 64d6d65 commit bf6d127
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 12 deletions.
1 change: 0 additions & 1 deletion web/app/components/header/active-filter-list-item.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{{! @glint-nocheck: not typesafe yet }}
<LinkTo @query={{this.query}} class="active-filter-list-item">
<FlightIcon @name="x" />
{{@filter}}
Expand Down
6 changes: 6 additions & 0 deletions web/app/components/header/active-filter-list-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ export default class HeaderActiveFilterListItemComponent extends Component<Heade
};
}
}

declare module "@glint/environment-ember-loose/registry" {
export default interface Registry {
"Header::ActiveFilterListItem": typeof HeaderActiveFilterListItemComponent;
}
}
1 change: 0 additions & 1 deletion web/app/components/header/active-filter-list.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{{! @glint-nocheck: not typesafe yet }}
{{#if this.shownFilters.length}}
<div class="active-filter-list">
<h3>Showing</h3>
Expand Down
6 changes: 6 additions & 0 deletions web/app/components/header/active-filter-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ export default class HeaderActiveFilterListComponent extends Component<HeaderAct
page: 1,
};
}

declare module "@glint/environment-ember-loose/registry" {
export default interface Registry {
"Header::ActiveFilterList": typeof HeaderActiveFilterListComponent;
}
}
13 changes: 10 additions & 3 deletions web/app/components/header/facet-dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,25 @@ import { FacetDropdownObjects } from "hermes/types/facets";
import { inject as service } from "@ember/service";
import RouterService from "@ember/routing/router-service";

interface FacetDropdownComponentSignature {
interface HeaderFacetDropdownComponentSignature {
Element: HTMLDivElement;
Args: {
label: string;
facets: FacetDropdownObjects;
facets: FacetDropdownObjects | null;
disabled?: boolean;
};
}

export default class FacetDropdownComponent extends Component<FacetDropdownComponentSignature> {
export default class HeaderFacetDropdownComponent extends Component<HeaderFacetDropdownComponentSignature> {
@service declare router: RouterService;

protected get currentRouteName() {
return this.router.currentRouteName;
}
}

declare module "@glint/environment-ember-loose/registry" {
export default interface Registry {
"Header::FacetDropdown": typeof HeaderFacetDropdownComponent;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{{! @glint-nocheck: not typesafe yet }}
<header class="bg-color-page-faint border-b border-b-color-border-faint mb-7">
<Header::Nav />
</header>
Expand Down
14 changes: 14 additions & 0 deletions web/app/components/header/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Component from "@glimmer/component";
import { FacetDropdownGroups } from "hermes/types/facets";

interface HeaderComponentSignature {
Args: {
facets: FacetDropdownGroups;
sortControlIsHidden?: boolean;
};
}

export default class extends Component<HeaderComponentSignature> {}
declare module "@glint/environment-ember-loose/registry" {
export default interface Registry {}
}
11 changes: 9 additions & 2 deletions web/app/components/header/nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import AuthenticatedUserService, {
import window from "ember-window-mock";
import { tracked } from "@glimmer/tracking";

interface NavComponentSignature {
interface HeaderNavComponentSignature {
Args: {};
}

export default class NavComponent extends Component<NavComponentSignature> {
export default class HeaderNavComponent extends Component<HeaderNavComponentSignature> {
@service("config") declare configSvc: ConfigService;
@service declare session: SessionService;
@service declare router: RouterService;
Expand Down Expand Up @@ -84,3 +84,10 @@ export default class NavComponent extends Component<NavComponentSignature> {
this.session.invalidate();
}
}

declare module "@glint/environment-ember-loose/registry" {
export default interface Registry {
'Header::Nav': typeof HeaderNavComponent;
}
}

13 changes: 12 additions & 1 deletion web/app/components/header/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ interface BasicDropdownAPI {
};
}

export default class Search extends Component {
interface HeaderSearchComponentSignature {
Element: HTMLDivElement;
Args: {};
}

export default class HeaderSearchComponent extends Component<HeaderSearchComponentSignature> {
@service declare algolia: AlgoliaService;
@service declare router: RouterService;

Expand Down Expand Up @@ -87,3 +92,9 @@ export default class Search extends Component {
}
);
}

declare module "@glint/environment-ember-loose/registry" {
export default interface Registry {
"Header::Search": typeof HeaderSearchComponent;
}
}
8 changes: 8 additions & 0 deletions web/app/components/header/sort-dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import Component from "@glimmer/component";
import { SortByFacets, SortByValue } from "./toolbar";
import { inject as service } from "@ember/service";
import RouterService from "@ember/routing/router-service";
import { Placement } from "@floating-ui/dom";

interface HeaderSortDropdownComponentSignature {
Args: {
label: string;
facets: SortByFacets;
disabled: boolean;
currentSortByValue: SortByValue;
dropdownPlacement: Placement;
};
}

Expand All @@ -27,3 +29,9 @@ export default class HeaderSortDropdownComponent extends Component<HeaderSortDro
return SortByValue.DateAsc;
}
}

declare module "@glint/environment-ember-loose/registry" {
export default interface Registry {
"Header::SortDropdown": typeof HeaderSortDropdownComponent;
}
}
1 change: 0 additions & 1 deletion web/app/components/header/toolbar.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{{! @glint-nocheck: not typesafe yet }}
{{#if @facets}}
<div class="toolbar mb-7">
<div class="x-container">
Expand Down
6 changes: 6 additions & 0 deletions web/app/components/header/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,9 @@ export default class ToolbarComponent extends Component<ToolbarComponentSignatur
});
}
}

declare module "@glint/environment-ember-loose/registry" {
export default interface Registry {
"Header::Toolbar": typeof ToolbarComponent;
}
}
10 changes: 8 additions & 2 deletions web/app/components/header/user-menu-highlight.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import Component from "@glimmer/component";

interface HeaderUserMenuHighlightsSignature {
interface HeaderUserMenuHighlightSignature {
Args: {};
}

export default class HeaderUserMenuHighlights extends Component<HeaderUserMenuHighlightsSignature> {}
export default class HeaderUserMenuHighlight extends Component<HeaderUserMenuHighlightSignature> {}

declare module "@glint/environment-ember-loose/registry" {
export default interface Registry {
"Header::UserMenuHighlight": typeof HeaderUserMenuHighlight;
}
}

0 comments on commit bf6d127

Please sign in to comment.