-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
307 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# @vite-plugin-checker/runtime | ||
|
||
Runtime code for vite-plugin-checker, this package will be directly bundled into the vite-plugin-checker package in building process and hasn't be released to NPM for now. | ||
|
||
## Development | ||
|
||
### local | ||
|
||
Watch and compile code with mock diagnostics and html without vite-plugin-checker. | ||
|
||
```sh | ||
pnpm dev-local | ||
``` | ||
|
||
### with vite-plugin-checker | ||
|
||
Watch and compile bundled JS to `../vite-plugin-checker/lib/@runtime/main.js`. Run `pnpm dev` in monorepo root will invoke below scripts. | ||
|
||
```sh | ||
pnpm dev | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset='utf-8'> | ||
<meta name='viewport' content='width=device-width,initial-scale=1'> | ||
|
||
<title>Svelte app</title> | ||
|
||
<link rel='icon' type='image/png' href='/favicon.png'> | ||
<link rel='stylesheet' href='/global.css'> | ||
<link rel='stylesheet' href='/build/bundle.css'> | ||
|
||
<script defer src='/build/bundle.js'></script> | ||
</head> | ||
|
||
<body> | ||
</body> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width,initial-scale=1" /> | ||
<title>Svelte app</title> | ||
<link rel="icon" type="image/png" href="/favicon.png" /> | ||
<link rel="stylesheet" href="/global.css" /> | ||
<script defer type="module" src="/build/bundle.js"></script> | ||
</head> | ||
|
||
<body></body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<script> | ||
export let collapsed | ||
export let checkerResults | ||
export let onClick | ||
function calcSummary(results) { | ||
let errorCount = 0 | ||
let warningCount = 0 | ||
results.forEach((result) => { | ||
result.diagnostics.forEach((d) => { | ||
if (d.level === 1) errorCount++ | ||
if (d.level === 0) warningCount++ | ||
}) | ||
}) | ||
return { errorCount, warningCount } | ||
} | ||
$: summary = calcSummary(checkerResults) | ||
$: calcBgColorClass = () => { | ||
if (!summary) return '' | ||
if (summary.errorCount > 0) return 'summary-error' | ||
if (summary.warningCount > 0) return 'summary-warning' | ||
return 'summary-success' | ||
} | ||
$: bgColorClass = calcBgColorClass() | ||
</script> | ||
|
||
<button | ||
class={`badge-button ${collapsed ? `to-uncollpase ${bgColorClass}` : 'to-collpase'}`} | ||
on:click|stopPropagation={onClick} | ||
> | ||
{#if collapsed} | ||
{#if summary.errorCount + summary.warningCount > 0} | ||
<span class="summary"><span class="emoji">❗️</span>{summary.errorCount}</span> | ||
<span class="summary"><span class="emoji">⚠️</span>{summary.warningCount}</span> | ||
{/if} | ||
{:else} | ||
<span>Close</span> | ||
{/if} | ||
</button> | ||
|
||
<style> | ||
.badge-button { | ||
appearance: none; | ||
font-size: 0.9em; | ||
font-weight: bold; | ||
border: 0px; | ||
border-radius: 0.3em; | ||
padding: 0.5em; | ||
cursor: pointer; | ||
position: fixed; | ||
z-index: 99999; | ||
margin: 0.5em; | ||
bottom: 0px; | ||
left: 0px; | ||
} | ||
.to-collpase { | ||
color: white; | ||
background: rgb(63, 78, 96); | ||
} | ||
.to-uncollpase { | ||
color: white; | ||
} | ||
.emoji { | ||
margin-right: 0.5ch; | ||
font-family: 'apple color emoji,segoe ui emoji,noto color emoji,android emoji,emojisymbols,emojione mozilla,twemoji mozilla,segoe ui symbol'; | ||
} | ||
.summary { | ||
font-family: var(--monospace); | ||
margin-right: 1ch; | ||
} | ||
.summary:last-of-type { | ||
margin-right: 0; | ||
} | ||
.summary-error { | ||
background: var(--red); | ||
} | ||
.summary-warning { | ||
background: var(--yellow); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.