mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-12-05 07:43:49 +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
@@ -10,10 +10,8 @@ const { locale } = Astro.props;
|
||||
|
||||
<BaseLayout accent="pink" {locale}>
|
||||
<ColorScale color="red" />
|
||||
<ColorScale color="red" alpha />
|
||||
<ColorScale color="jade" />
|
||||
<ColorScale color="amber" />
|
||||
<ColorScale color="amber" alpha />
|
||||
<ColorScale color="blue" />
|
||||
|
||||
<Page {locale} client:load />
|
||||
|
||||
@@ -17,106 +17,97 @@ const extraColors = ["red", "amber", "green"] satisfies Color[];
|
||||
---
|
||||
|
||||
<BaseLayout accent="blue" {locale}>
|
||||
{
|
||||
extraColors.map((color) => (
|
||||
<>
|
||||
<ColorScale {color} />
|
||||
<ColorScale {color} alpha />
|
||||
</>
|
||||
))
|
||||
}
|
||||
{extraColors.map((color) => (
|
||||
<ColorScale {color} />
|
||||
))}
|
||||
|
||||
<div class="page">
|
||||
<h1>Badge</h1>
|
||||
|
||||
{
|
||||
sizes.map((size) => (
|
||||
<section>
|
||||
<h2>size="{size}"</h2>
|
||||
{sizes.map((size) => (
|
||||
<section>
|
||||
<h2>size="{size}"</h2>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th />
|
||||
{variants.map((variant) => (
|
||||
<th>{variant}</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{colors.map((color) => (
|
||||
<tr>
|
||||
<th>{color ?? "accent"}</th>
|
||||
{variants.map((variant) => (
|
||||
<td>
|
||||
<Badge {color} {variant} {size}>
|
||||
Badge
|
||||
</Badge>
|
||||
</td>
|
||||
))}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
))
|
||||
}
|
||||
|
||||
{
|
||||
sizes.map((size) => (
|
||||
<section>
|
||||
<h2>size="{size}" with icons</h2>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th />
|
||||
{iconLayouts.map((layout) => (
|
||||
<th>{layout}</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th />
|
||||
{variants.map((variant) => (
|
||||
<tr>
|
||||
<th>{variant}</th>
|
||||
|
||||
<td>
|
||||
<Badge {variant} {size}>
|
||||
<StarFilledIcon />
|
||||
Badge
|
||||
</Badge>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Badge {variant} {size}>
|
||||
Badge
|
||||
<CheckIcon />
|
||||
</Badge>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Badge {variant} {size}>
|
||||
<StarFilledIcon />
|
||||
Badge
|
||||
<CheckIcon />
|
||||
</Badge>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Badge {variant} {size}>
|
||||
<StarFilledIcon />
|
||||
</Badge>
|
||||
</td>
|
||||
</tr>
|
||||
<th>{variant}</th>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
))
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{colors.map((color) => (
|
||||
<tr>
|
||||
<th>{color ?? "accent"}</th>
|
||||
{variants.map((variant) => (
|
||||
<td>
|
||||
<Badge {color} {variant} {size}>
|
||||
Badge
|
||||
</Badge>
|
||||
</td>
|
||||
))}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
))}
|
||||
|
||||
{sizes.map((size) => (
|
||||
<section>
|
||||
<h2>size="{size}" with icons</h2>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th />
|
||||
{iconLayouts.map((layout) => (
|
||||
<th>{layout}</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{variants.map((variant) => (
|
||||
<tr>
|
||||
<th>{variant}</th>
|
||||
|
||||
<td>
|
||||
<Badge {variant} {size}>
|
||||
<StarFilledIcon />
|
||||
Badge
|
||||
</Badge>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Badge {variant} {size}>
|
||||
Badge
|
||||
<CheckIcon />
|
||||
</Badge>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Badge {variant} {size}>
|
||||
<StarFilledIcon />
|
||||
Badge
|
||||
<CheckIcon />
|
||||
</Badge>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Badge {variant} {size}>
|
||||
<StarFilledIcon />
|
||||
</Badge>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
))}
|
||||
</div>
|
||||
</BaseLayout>
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
---
|
||||
import "@radix-ui/colors/violet-dark.css";
|
||||
import { api } from "../../../../../api/dynamic";
|
||||
import { mixStaticPaths } from "../../../../../astro/mixStaticPaths";
|
||||
import ColorScale from "../../../../../components/ColorScale.astro";
|
||||
import ColorRanks from "../../../../../components/ColorRanks.astro";
|
||||
import BaseLayout from "../../../../../layouts/BaseLayout.astro";
|
||||
import { getStaticPaths as _getStaticPaths } from "../index.astro";
|
||||
import { Page } from "./_index";
|
||||
@@ -20,15 +20,10 @@ const { id, locale } = Astro.props;
|
||||
---
|
||||
|
||||
<BaseLayout {locale} accent="violet">
|
||||
<ColorScale color="amber" alpha />
|
||||
<ColorScale color="red" />
|
||||
<ColorScale color="ruby" alpha />
|
||||
<ColorScale color="orange" />
|
||||
<ColorScale color="amber" />
|
||||
<ColorScale color="jade" />
|
||||
<ColorScale color="jade" alpha />
|
||||
<ColorScale color="cyan" alpha />
|
||||
<ColorScale color="ruby" />
|
||||
<ColorScale color="cyan" />
|
||||
<ColorScale color="green" />
|
||||
<ColorRanks />
|
||||
|
||||
<Page {id} {locale} client:load />
|
||||
</BaseLayout>
|
||||
@@ -19,6 +19,7 @@ const { locale } = Astro.props;
|
||||
<ToolBanner {locale} tool={tools.tanks} />
|
||||
|
||||
<Section>
|
||||
<!-- TODO: eliminate all client:only's -->
|
||||
<Page {locale} client:only="react">
|
||||
<Page {locale} skeleton slot="fallback" />
|
||||
</Page>
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import type { APIContext } from "astro";
|
||||
import sharp from "sharp";
|
||||
import { mixStaticPaths } from "../../astro/mixStaticPaths";
|
||||
import { getStaticPaths as _getStaticPaths } from "./_index";
|
||||
|
||||
interface IconProps {
|
||||
size: number;
|
||||
background?: string;
|
||||
}
|
||||
|
||||
export const getStaticPaths = mixStaticPaths(_getStaticPaths, () => [
|
||||
{
|
||||
params: { icon: "favicon" },
|
||||
props: { size: 32 } satisfies IconProps,
|
||||
},
|
||||
|
||||
// iOS fills transparency with black, so flatten onto white
|
||||
{
|
||||
params: { icon: "apple-touch-icon" },
|
||||
props: { size: 180, background: "#fff" } satisfies IconProps,
|
||||
},
|
||||
]);
|
||||
|
||||
export async function GET({ props }: APIContext<IconProps>) {
|
||||
let image = sharp("src/media/favicon.png").resize(props.size, props.size);
|
||||
|
||||
if (props.background) {
|
||||
image = image.flatten({ background: props.background });
|
||||
}
|
||||
|
||||
const buffer = await image.png().toBuffer();
|
||||
const bytes = new Uint8Array(buffer);
|
||||
|
||||
return new Response(bytes);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import type { APIContext } from "astro";
|
||||
import {
|
||||
COLORS,
|
||||
colorAliasStyles,
|
||||
colorScaleStyles,
|
||||
} from "../../../../astro/colorStyles";
|
||||
import { mixStaticPaths } from "../../../../astro/mixStaticPaths";
|
||||
import { COLORS_ALPHA_ONLY, COLOR_ALIASES } from "../../../../config/styles";
|
||||
import { getStaticPaths as _getStaticPaths } from "../../_index";
|
||||
|
||||
interface ColorStylesProps {
|
||||
styles: string;
|
||||
}
|
||||
|
||||
function path(name: string, styles: string) {
|
||||
return {
|
||||
params: { name },
|
||||
props: { styles } satisfies ColorStylesProps,
|
||||
};
|
||||
}
|
||||
|
||||
export const getStaticPaths = mixStaticPaths(_getStaticPaths, () => [
|
||||
...COLORS_ALPHA_ONLY.map((color) => path(color, colorScaleStyles(color))),
|
||||
|
||||
...COLORS.flatMap((color) => [
|
||||
path(color, colorScaleStyles(color)),
|
||||
|
||||
...COLOR_ALIASES.map((alias) =>
|
||||
path(`${color}-as-${alias}`, colorAliasStyles(color, alias)),
|
||||
),
|
||||
]),
|
||||
]);
|
||||
|
||||
export function GET({ props }: APIContext<ColorStylesProps>) {
|
||||
return new Response(props.styles);
|
||||
}
|
||||
Reference in new issue
Block a user