Skip to content

Commit 3caf24c

Browse files
authored
Merge pull request #1 from akcyp/ide-look
IDE look
2 parents e7ac852 + e62a576 commit 3caf24c

34 files changed

+1717
-515
lines changed

.husky/pre-commit

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/usr/bin/env sh
2-
. "$(dirname -- "$0")/_/husky.sh"
3-
4-
bun run precommit
1+
bun x biome check --write --staged

README.md

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
> [!WARNING]
44
> This package is still in the experimental phase. You can expect new functionalities, but with this comes the possibility of more frequent errors
55
6-
Directory summary (light theme) | File coverage (dark theme)
7-
:------------------------------:|:----------------------------:
8-
![Summary](images/summary.png) | ![Coverage](images/file.png)
6+
Home | Stats | Code
7+
:----:|:---:|:---:
8+
![Summary](images/home-dark.png) | ![Stats](images/stats-dark.png) | ![Coverage](images/code-dark.png)
9+
![Summary](images/home-light.png) | ![Stats](images/stats-light.png) | ![Coverage](images/code-light.png)
910

1011
## Installation
1112

@@ -45,17 +46,50 @@ export default defineConfig({
4546
});
4647
```
4748

48-
## Reading coverage report
49+
## Iframe - theme support
4950

50-
`coverage-pretty-html-reporter` does not support viewing web-page locally (via file:// protocol) (i.e. double clicking the .html file). You need to publish coverage directory on local network ex.:
51+
When the reporter UI is embedded in an iframe, the built-in theme toggle button is hidden. In this mode you are expected to control the theme from the parent window.
52+
53+
The iframe listens for postMessage events with the following payload:
54+
55+
```ts
56+
type CoverageThemeMessage = {
57+
type: "coverage-theme";
58+
theme: "light" | "dark";
59+
};
60+
```
61+
62+
Example integration in the parent page:
63+
64+
```html
65+
<iframe
66+
id="coverage-report"
67+
src="/path/to/coverage/index.html"
68+
style="width: 100%; height: 100%; border: 0;"
69+
></iframe>
70+
71+
<script>
72+
const iframe = document.getElementById("coverage-report");
73+
74+
function setCoverageTheme(theme) {
75+
iframe?.contentWindow?.postMessage({ type: "coverage-theme", theme }, "*");
76+
}
77+
78+
// Send initial theme once the iframe is loaded
79+
iframe.addEventListener("load", () => {
80+
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
81+
setCoverageTheme(prefersDark ? "dark" : "light");
82+
});
83+
84+
// Example: hook into your own app theme system
85+
window.addEventListener("app-theme-changed", (event) => {
86+
setCoverageTheme(event.detail.theme); // "light" | "dark"
87+
});
88+
<\/script>
89+
```
90+
91+
Inside the iframe, the selected theme is persisted in localStorage under the coverage-theme key and a coverage-theme-changed CustomEvent is dispatched on window so internal components can react to theme changes.
5192
52-
```sh
53-
# When using npm
54-
npx http-server ./coverage
55-
# When using pnpm
56-
pnpm dlx http-server ./coverage
57-
# When using bun
58-
bunx http-server ./coverage
5993
```
6094
6195
## Contributing

biome.json

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,50 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/1.2.2/schema.json",
3-
"organizeImports": {
4-
"enabled": true
2+
"$schema": "https://biomejs.dev/schemas/2.3.8/schema.json",
3+
"vcs": {
4+
"enabled": true,
5+
"clientKind": "git",
6+
"useIgnoreFile": true
7+
},
8+
"files": {
9+
"ignoreUnknown": false
510
},
611
"formatter": {
7-
"indentSize": 2,
12+
"enabled": true,
813
"indentStyle": "space",
9-
"ignore": ["**/dist", "**/node_modules", "**/coverage", "**/nyc-output"],
14+
"indentWidth": 2,
1015
"lineWidth": 160
1116
},
1217
"linter": {
1318
"enabled": true,
1419
"rules": {
1520
"recommended": true
21+
}
22+
},
23+
"assist": {
24+
"enabled": true,
25+
"actions": {
26+
"source": {
27+
"organizeImports": "on"
28+
}
29+
}
30+
},
31+
"overrides": [
32+
{
33+
"includes": ["**/*.vue"],
34+
"linter": {
35+
"rules": {
36+
"correctness": {
37+
"noUnusedVariables": "off",
38+
"noUnusedImports": "off"
39+
}
40+
}
41+
}
1642
},
17-
"ignore": ["**/dist", "**/node_modules", "**/coverage", "**/nyc-output"]
18-
}
43+
{
44+
"includes": ["packages/example/**"],
45+
"linter": {
46+
"enabled": false
47+
}
48+
}
49+
]
1950
}

bun.lockb

-38.8 KB
Binary file not shown.

images/code-dark.png

86.9 KB
Loading

images/code-light.png

86.4 KB
Loading

images/file.png

-60 KB
Binary file not shown.

images/home-dark.png

50.1 KB
Loading

images/home-light.png

50.1 KB
Loading

images/stats-dark.png

58.2 KB
Loading

0 commit comments

Comments
 (0)