Badge thumbnail images

This commit is contained in:
Kalle
2022-07-04 22:01:51 +03:00
parent 89a16d4ff3
commit 9f50b04f2e
98 changed files with 30 additions and 13 deletions

View File

@@ -35,3 +35,17 @@ sendou.ink/
├── public/ -- Images, built assets etc. static files to be served as is
└── scripts/ -- Stand-alone scripts to be run outside of the app
```
## Commands
### Converting gifs (badges) to thumbnail
### png
```bash
sips -s format png ./*.gif --out .
```
### avif
https://github.com/lovell/avif-cli

View File

@@ -1,18 +1,20 @@
export function Image({
path,
alt,
title,
className,
width,
height,
}: {
path: string;
alt: string;
className: string;
title?: string;
className?: string;
width?: number;
height?: number;
}) {
return (
<picture>
<picture title={title}>
<source
type="image/avif"
srcSet={`${path}.avif`}

View File

@@ -27,7 +27,6 @@ const allStm = sql.prepare(`
export type All = Array<Pick<Badge, "id" | "displayName" | "code">>;
export function all() {
return []; // TODO: remove when page is done
return allStm.all() as All;
}

View File

@@ -1,5 +1,6 @@
import type { LinksFunction, LoaderFunction } from "@remix-run/node";
import { Link, Outlet, useLoaderData, useParams } from "@remix-run/react";
import { Image } from "~/components/Image";
import { Main } from "~/components/Main";
import { db } from "~/db";
import type { All } from "~/db/models/badges.server";
@@ -19,7 +20,6 @@ export const loader: LoaderFunction = () => {
return jsonCached<BadgesLoaderData>({ badges: db.badges.all() }, 120);
};
// xxx: https://web.dev/replace-gifs-with-videos/ check possibility to replace gif
export default function BadgesPageLayout() {
const data = useLoaderData<BadgesLoaderData>();
const params = useParams();
@@ -34,13 +34,14 @@ export default function BadgesPageLayout() {
{data.badges
.filter((b) => !badgeIdBeingViewed || b.id !== badgeIdBeingViewed)
.map((badge) => (
// xxx: firefox and squid junction avif fails to display
<Link key={badge.id} to={String(badge.id)}>
<img
src={badgeUrl({ code: badge.code, extension: "gif" })}
alt={badge.displayName}
<Image
path={badgeUrl({ code: badge.code })}
title={badge.displayName}
width="64"
height="64"
alt={badge.displayName}
width={64}
height={64}
/>
</Link>
))}

View File

@@ -12,6 +12,7 @@ import { TwitchIcon } from "~/components/icons/Twitch";
import { TwitterIcon } from "~/components/icons/Twitter";
import { YouTubeIcon } from "~/components/icons/YouTube";
import { badgeExplanationText } from "../badges/$id";
import { badgeUrl } from "~/utils/urls";
export const links: LinksFunction = () => {
return [{ rel: "stylesheet", href: styles }];
@@ -136,7 +137,7 @@ function BadgeContainer(props: { badges: UserPageLoaderData["badges"] }) {
>
<img
key={bigBadge.code}
src={`/gif/badges/${bigBadge.code}.gif`}
src={badgeUrl({ code: bigBadge.code, extension: "gif" })}
alt={bigBadge.displayName}
title={bigBadge.displayName}
width="125"
@@ -147,7 +148,7 @@ function BadgeContainer(props: { badges: UserPageLoaderData["badges"] }) {
{smallBadges.map((badge) => (
<div key={badge.id} className="u__small-badge-container">
<img
src={`/gif/badges/${badge.code}.gif`}
src={badgeUrl({ code: badge.code, extension: "gif" })}
alt={badge.displayName}
title={badge.displayName}
onClick={() => setBadgeFirst(badge)}

View File

@@ -21,5 +21,5 @@ export const badgeUrl = ({
extension,
}: {
code: Badge["code"];
extension: "gif" | "avif" | "png";
}) => `/badges/${code}.${extension}`;
extension?: "gif";
}) => `/badges/${code}${extension ? `.${extension}` : ""}`;

BIN
public/badges/20xx.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
public/badges/20xx.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
public/badges/beta_top1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
public/badges/beta_top2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
public/badges/beta_top3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

BIN
public/badges/cake.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
public/badges/cake.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

BIN
public/badges/ebtv.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
public/badges/ebtv.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

BIN
public/badges/girls.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
public/badges/girls.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
public/badges/idtga.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
public/badges/idtga.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

BIN
public/badges/itz_blue.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
public/badges/itz_blue.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
public/badges/itz_pink.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
public/badges/itz_pink.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
public/badges/itz_red.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
public/badges/itz_red.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
public/badges/lobster.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
public/badges/lobster.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

BIN
public/badges/lutiblue.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
public/badges/lutiblue.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
public/badges/lutigreen.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
public/badges/lutipink.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
public/badges/lutipink.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
public/badges/lutired.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1007 B

BIN
public/badges/lutired.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
public/badges/lutitan.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 971 B

BIN
public/badges/lutitan.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
public/badges/monday.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
public/badges/monday.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

BIN
public/badges/pair.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
public/badges/pair.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

BIN
public/badges/patreon.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
public/badges/patreon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
public/badges/pool1.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

BIN
public/badges/pool1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

BIN
public/badges/pool2.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
public/badges/pool2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

BIN
public/badges/quad.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
public/badges/quad.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

BIN
public/badges/sundae.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
public/badges/sundae.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 815 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
public/badges/triton.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
public/badges/triton.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

BIN
public/badges/xp26.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
public/badges/xp26.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
public/badges/xp27.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
public/badges/xp27.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

BIN
public/badges/xp28.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
public/badges/xp28.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
public/badges/xp29.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
public/badges/xp29.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

BIN
public/badges/xp30.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
public/badges/xp30.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
public/badges/zones.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
public/badges/zones.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB