Skip to content

Commit

Permalink
Draft
Browse files Browse the repository at this point in the history
  • Loading branch information
katydecorah committed Apr 21, 2024
1 parent fb4cab1 commit 544e4b9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"no-console": "error",
"no-unused-vars": "error",
"import/extensions": "off",
"import/no-cycle": "off",
"unicorn/template-indent": "off",
"unicorn/prefer-string-replace-all": "off",
"@typescript-eslint/explicit-member-accessibility": "error",
Expand Down
22 changes: 10 additions & 12 deletions components/main-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ class MainApp extends HTMLElement {
private selectedSearchElm: HTMLInputElement =
this.querySelector("#selectedSearch");

public get pageSize(): number {
return 10;
}
public pageSize = 10;

public get currentPage(): number {
return Number.parseInt(this.getAttribute("current-page"), 10);
Expand Down Expand Up @@ -169,21 +167,21 @@ class MainApp extends HTMLElement {
break;
}
case "selectedVariable": {
this.removeCheckbox();
MainApp.removeCheckbox();
break;
}
default: {
this.removeSelect(currentFilter);
MainApp.removeSelect(currentFilter);
}
}
}

private removeAllFilters(): void {
if (this.selectedCategory) this.removeSelect("selectedCategory");
if (this.selectedSubset) this.removeSelect("selectedSubset");
if (this.selectedVariant) this.removeSelect("selectedVariant");
if (this.selectedVariable) this.removeCheckbox();
if (this.selectedTag) this.removeSelect("selectedTag");
if (this.selectedCategory) MainApp.removeSelect("selectedCategory");
if (this.selectedSubset) MainApp.removeSelect("selectedSubset");
if (this.selectedVariant) MainApp.removeSelect("selectedVariant");
if (this.selectedVariable) MainApp.removeCheckbox();
if (this.selectedTag) MainApp.removeSelect("selectedTag");
if (this.selectedSearch) this.removeSearch();
}

Expand All @@ -192,15 +190,15 @@ class MainApp extends HTMLElement {
(this.selectedSearchElm as HTMLInputElement).value = "";
}

private removeSelect(value: string): void {
private static removeSelect(value: string): void {
window.dispatchEvent(
customEvent("remove-select", {
value,
}),
);
}

private removeCheckbox(): void {
private static removeCheckbox(): void {
window.dispatchEvent(customEvent("remove-checkbox"));
}

Expand Down
6 changes: 2 additions & 4 deletions components/pagination-buttons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ export type ButtonType = MouseEvent & { target: HTMLButtonElement };
class PaginationButtons extends HTMLElement {
private mainApp = document.querySelector("main-app");

private pageSize = 10;

public constructor() {
super();
this.handlePage = this.handlePage.bind(this);
Expand All @@ -25,10 +27,6 @@ class PaginationButtons extends HTMLElement {
return Number.parseInt(this.getAttribute("results-length"), 10);
}

public get pageSize(): number {
return 10;
}

private get totalPages(): number {
return Math.ceil(this.resultsLength / this.pageSize);
}
Expand Down
4 changes: 2 additions & 2 deletions components/search-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class SearchStatus extends HTMLElement {
if (hasSelectedFilters) {
elm.push(
this.selectedFilters
.map((filter) => this.renderFilter(filter))
.map((filter): string => SearchStatus.renderFilter(filter))
.join(""),
`<button is="clear-button" aria-label="remove all filters" class="btn btn-clear">Clear</button>`,
);
Expand All @@ -65,7 +65,7 @@ class SearchStatus extends HTMLElement {
this.innerHTML = `${elm.join("\n")}`;
}

private renderFilter({
private static renderFilter({
label,
value,
id,
Expand Down

0 comments on commit 544e4b9

Please sign in to comment.