Skip to content

Commit

Permalink
highlight unknown
Browse files Browse the repository at this point in the history
WebGPUReport wants to highlight when an avaiable limit is better
than the default (or worse in the case of compat)

To do that it needs to know the default limits.

This PR highlights limits it is unaware so hopefull the
defaults will be added. It doesn't error because we still
want the site to be useful for unknown limits.
  • Loading branch information
greggman committed Dec 8, 2023
1 parent b773c8e commit f1bede2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
5 changes: 5 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
--header-background-color: #DDD;
--header-text-color: #00A;
--different-text-color: magenta;
--unknown-text-color: #458;
}
@media (prefers-color-scheme: dark) {

Expand All @@ -58,6 +59,7 @@
--header-background-color: #333;
--header-text-color: lightgreen;
--different-text-color: orange;
--unknown-text-color: #8AF;
}
}
body {
Expand Down Expand Up @@ -133,6 +135,9 @@
.different-worse {
color: var(--error-text-color);
}
.unknown {
color: var(--unknown-text-color);
}

.limit>td:first-child,
.feature>td:first-child,
Expand Down
13 changes: 9 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,20 @@ function markDifferencesInLimits(adapter) {
.map(([k, v]) => {
const info = kLimitInfo[k];
const isDiff = info && info.default !== v;
const diffClass = isDiff
? differenceWorse(info, v) ? 'different-worse' : 'different-better'
: '';
const diffClass = info
? (isDiff
? differenceWorse(info, v) ? 'different-worse' : 'different-better'
: '')
: 'unknown';
const value = v > 1024 && info ? `${v} (${shortSizeByType(v, info.type)})` : v;
return [
k,
isDiff
? [value, {className: `${diffClass} nowrap`, title: `default${adapter.isCompatibilityMode ? ' in compat' : ''}: ${shortSizeByType(adapter.isCompatibilityMode ? info.compat : info.default, info.type)}`}]
: [value, {className: 'nowrap', title: 'same as default'}]
: info
? [value, {className: 'nowrap', title: 'same as default'}]
: [value, {className: 'unknown nowrap', title: 'unknown limit (new?)'}]

];
})
);
Expand Down

0 comments on commit f1bede2

Please sign in to comment.