|
1 | 1 | /* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */ |
2 | 2 | import type { PropertyValues } from 'lit'; |
3 | | -import { html, unsafeCSS, nothing } from 'lit'; |
| 3 | +import { html, nothing, unsafeCSS } from 'lit'; |
4 | 4 | import { customElement, property } from 'lit/decorators.js'; |
5 | | -import type { MutantResult, MutationTestResult } from 'mutation-testing-report-schema/api'; |
6 | 5 | import type { |
7 | | - MetricsResult, |
8 | | - MutantModel, |
9 | | - TestModel, |
10 | 6 | FileUnderTestModel, |
11 | 7 | Metrics, |
| 8 | + MetricsResult, |
| 9 | + MutantModel, |
12 | 10 | MutationTestMetricsResult, |
13 | 11 | TestFileModel, |
14 | 12 | TestMetrics, |
| 13 | + TestModel, |
15 | 14 | } from 'mutation-testing-metrics'; |
16 | 15 | import { calculateMutationTestMetrics } from 'mutation-testing-metrics'; |
17 | | -import { tailwind, globals } from '../../style/index.js'; |
18 | | -import { locationChange$, View } from '../../lib/router.js'; |
| 16 | +import type { MutantResult, MutationTestResult } from 'mutation-testing-report-schema/api'; |
19 | 17 | import type { Subscription } from 'rxjs'; |
20 | 18 | import { fromEvent, sampleTime } from 'rxjs'; |
21 | | -import theme from './theme.scss?inline'; |
| 19 | +import { isLocalStorageAvailable } from '../../lib/browser.js'; |
| 20 | +import type { MteCustomEvent } from '../../lib/custom-events.js'; |
22 | 21 | import { createCustomEvent } from '../../lib/custom-events.js'; |
23 | 22 | import { toAbsoluteUrl } from '../../lib/html-helpers.js'; |
24 | | -import { isLocalStorageAvailable } from '../../lib/browser.js'; |
25 | 23 | import { mutantChanges } from '../../lib/mutant-changes.js'; |
| 24 | +import { locationChange$, View } from '../../lib/router.js'; |
| 25 | +import type { Theme } from '../../lib/theme.js'; |
| 26 | +import { globals, tailwind } from '../../style/index.js'; |
26 | 27 | import { RealTimeElement } from '../real-time-element.js'; |
| 28 | +import theme from './theme.scss?inline'; |
27 | 29 |
|
28 | 30 | interface BaseContext { |
29 | 31 | path: string[]; |
@@ -70,14 +72,14 @@ export class MutationTestReportAppComponent extends RealTimeElement { |
70 | 72 | @property({ attribute: false }) |
71 | 73 | public declare context: Context; |
72 | 74 |
|
73 | | - @property() |
| 75 | + @property({ type: Array }) |
74 | 76 | public declare path: readonly string[]; |
75 | 77 |
|
76 | 78 | @property({ attribute: 'title-postfix' }) |
77 | 79 | public declare titlePostfix: string | undefined; |
78 | 80 |
|
79 | 81 | @property({ reflect: true }) |
80 | | - public declare theme?: string; |
| 82 | + public declare theme?: Theme; |
81 | 83 |
|
82 | 84 | @property({ attribute: false }) |
83 | 85 | public get themeBackgroundColor(): string { |
@@ -155,11 +157,11 @@ export class MutationTestReportAppComponent extends RealTimeElement { |
155 | 157 | } |
156 | 158 | } |
157 | 159 |
|
158 | | - private getTheme(): string { |
| 160 | + private getTheme(): Theme { |
159 | 161 | // 1. check local storage |
160 | 162 | const theme = isLocalStorageAvailable() && localStorage.getItem('mutation-testing-elements-theme'); |
161 | 163 | if (theme) { |
162 | | - return theme; |
| 164 | + return theme as Theme; |
163 | 165 | // 2. check for user's OS preference |
164 | 166 | } else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)')?.matches) { |
165 | 167 | return 'dark'; |
@@ -225,7 +227,7 @@ export class MutationTestReportAppComponent extends RealTimeElement { |
225 | 227 | document.title = this.title; |
226 | 228 | } |
227 | 229 |
|
228 | | - public themeSwitch = (event: CustomEvent<string>) => { |
| 230 | + public themeSwitch = (event: MteCustomEvent<'theme-switch'>) => { |
229 | 231 | this.theme = event.detail; |
230 | 232 |
|
231 | 233 | if (isLocalStorageAvailable()) { |
|
0 commit comments