Skip to content

Commit

Permalink
Make limits that are 0 show in red.
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Dec 20, 2024
1 parent f88f181 commit 96faee3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@
.different-better {
color: var(--different-text-color);
}
.default-zero,
.different-zero,
.different-worse {
color: var(--error-text-color);
}
Expand Down
19 changes: 13 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,18 +255,25 @@ function markDifferencesInLimits(adapter, device) {
mapLikeToKeyValueArray(adapter.limits)
.map(([k, v]) => {
const defaultLimit = defaultLimits[k];
const defaultClass = defaultLimit > 0
? 'nowrap default-limit'
: 'nowrap default-limit default-zero';
const info = kLimitInfo[k];
const isDiff = defaultLimit !== undefined && defaultLimit !== v;
const diffClass = defaultLimit !== undefined
? (isDiff
? differenceWorse(k, defaultLimit, v) ? 'different-worse' : 'different-better'
: 'different-none')
: 'unknown';
const diffClass = defaultLimit === undefined
? 'unknown'
: (isDiff
? differenceWorse(k, defaultLimit, v) ? 'different-worse' : 'different-better'
: (v === 0
? 'different-zero'
: 'different-none'
)
);
const shortSize = shortSizeByType(v, info?.type ?? 'count');
const defaultSize = shortSizeByType(defaultLimit, info?.type ?? 'count');
const value = v > 1024 ? `${v} (${shortSize})` : shortSize;
const defaultValue = defaultLimit > 1024 ? `${defaultLimit} (${defaultSize})` : defaultSize;
const defaultElem = el('span', {className: 'nowrap default-limit', textContent: defaultValue})
const defaultElem = el('span', {className: defaultClass, textContent: defaultValue})
const title = isDiff
? `default: ${defaultSize}\n${requestHint}`
: 'same as default'
Expand Down

0 comments on commit 96faee3

Please sign in to comment.