mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-21 12:53:56 +01:00
optimize html, css, svg's, and webp delivery
This commit is contained in:
75 files changed
+452
-331
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import { RANKING_COLORS, RANKING_STEPS } from "../../../config/rankings";
|
||||
|
||||
export { getStaticPaths } from "../_index";
|
||||
|
||||
const SEGMENTS = RANKING_COLORS.length - 1;
|
||||
|
||||
// Exposes the progress and blended color of each step to anything ranked
|
||||
function stepStyles(step: number) {
|
||||
const progress = step / RANKING_STEPS;
|
||||
const position = progress * SEGMENTS;
|
||||
const segment = Math.min(Math.floor(position), SEGMENTS);
|
||||
const from = RANKING_COLORS[segment];
|
||||
const to = RANKING_COLORS[Math.min(segment + 1, SEGMENTS)];
|
||||
const weight = (1 - (position - segment)) * 100;
|
||||
|
||||
return `[data-ranking="${step}"]{--ranking-progress:${
|
||||
progress * 100
|
||||
}%;--ranking-color:color-mix(in srgb,var(--${from}-7) ${weight}%,var(--${to}-7));}`;
|
||||
}
|
||||
|
||||
export function GET() {
|
||||
let styles = "";
|
||||
|
||||
for (let step = 0; step <= RANKING_STEPS; step++) {
|
||||
styles += stepStyles(step);
|
||||
}
|
||||
|
||||
return new Response(styles);
|
||||
}
|
||||
Reference in new issue
Block a user