mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 21:21:02 +00:00
feat(frontend): add visual indicator to top lists
This commit is contained in:
parent
3228b22741
commit
8377b2f6d0
6 changed files with 79 additions and 13 deletions
11
frontend/src/util/getMaxCount.ts
Normal file
11
frontend/src/util/getMaxCount.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
interface TopListItemEntity {
|
||||
count: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get max count for top list. Returns at least 1 to make sure we do not run into issues
|
||||
* with empty list (would normally return -Infinity) or 0 (could cause divide by zero error).
|
||||
*/
|
||||
export function getMaxCount(items: TopListItemEntity[]): number {
|
||||
return Math.max(1, ...items.map(({ count }) => count));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue