feat: #420 reimplement icon picker (#421)

This commit is contained in:
Manuel
2024-05-04 23:00:15 +02:00
committed by GitHub
parent 51aaab2f23
commit 60a35e2583
37 changed files with 2974 additions and 10 deletions

View File

@@ -1,3 +1,4 @@
export * from "./object";
export * from "./string";
export * from "./cookie";
export * from "./stopwatch";

View File

@@ -0,0 +1,44 @@
import dayjs from "dayjs";
import relativeTime from "dayjs/plugin/relativeTime";
import updateLocale from "dayjs/plugin/updateLocale";
dayjs.extend(relativeTime);
dayjs.extend(updateLocale);
dayjs.updateLocale("en", {
relativeTime: {
future: "in %s",
past: "%s ago",
s: "one second",
ss: "%d seconds",
m: "a minute",
mm: "%d minutes",
h: "an hour",
hh: "%d hours",
d: "a day",
dd: "%d days",
M: "a month",
MM: "%d months",
y: "a year",
yy: "%d years",
},
});
export class Stopwatch {
private startTime: number;
constructor() {
this.startTime = performance.now();
}
getElapsedInHumanWords() {
const difference = performance.now() - this.startTime;
if (difference < 1000) {
return `${Math.floor(difference)} ms`;
}
return dayjs().millisecond(this.startTime).fromNow(true);
}
reset() {
this.startTime = performance.now();
}
}