Skip to content

Commit

Permalink
Hide sprint tab when no sprint (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcokreeft87 authored Aug 5, 2023
1 parent 4016f1e commit 5376b53
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 14 deletions.
10 changes: 5 additions & 5 deletions formulaone-card.js

Large diffs are not rendered by default.

Binary file modified formulaone-card.js.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "formulaone-card",
"version": "1.8.2",
"version": "1.8.3",
"description": "Frontend card for Home Assistant to display Formula One data",
"main": "index.js",
"scripts": {
Expand Down
7 changes: 4 additions & 3 deletions src/cards/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export default class Results extends BaseCard {
}, {
title: 'Sprint',
icon: this.icon('sprint'),
content: this.renderSprint(selectedRace)
content: this.renderSprint(selectedRace),
hide: !selectedRace?.SprintResults
}];

return tabs;
Expand Down Expand Up @@ -221,7 +222,7 @@ export default class Results extends BaseCard {
@MDCTabBar:activated=${(ev: mwcTabBarEvent) =>
(this.setSelectedTabIndex(ev.detail.index))}
>
${tabs.map(
${tabs.filter(tab => !tab.hide).map(
(tab) => html`
<mwc-tab
?hasImageIcon=${tab.icon}
Expand All @@ -235,7 +236,7 @@ export default class Results extends BaseCard {
</mwc-tab-bar>
<section>
<article>
${tabs.find((_, index) => index == selectedTabIndex).content}
${tabs.filter(tab => !tab.hide).find((_, index) => index == selectedTabIndex).content}
</article>
</section>
</td>
Expand Down
3 changes: 2 additions & 1 deletion src/types/formulaone-card-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ export interface ActionHandlerElement extends HTMLElement {
export interface FormulaOneCardTab {
title: string
icon: string
content: HTMLTemplateResult
content: HTMLTemplateResult,
hide?: boolean
}

export interface SelectChangeEvent {
Expand Down
4 changes: 2 additions & 2 deletions tests/cards/results.test.ts

Large diffs are not rendered by default.

0 comments on commit 5376b53

Please sign in to comment.