Icons via avif

This commit is contained in:
Kalle
2022-07-03 12:43:09 +03:00
parent 8d519d6b32
commit 12c59a40bf
28 changed files with 40 additions and 8 deletions

32
app/components/Image.tsx Normal file
View File

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

View File

@@ -1,6 +1,7 @@
import clsx from "clsx";
import { Link } from "@remix-run/react";
import navItems from "./nav-items.json";
import { Image } from "../Image";
// xxx: overflows but maybe on chrome mobile emulator only?
export function Menu({
@@ -25,9 +26,9 @@ export function Menu({
data-cy={`menu-link-${navItem.name}`}
tabIndex={!expanded ? -1 : undefined}
>
<img
<Image
className="layout__menu__link__icon"
src={`/img/layout/${navItem.name.replace(" ", "")}.webp`}
path={`/img/layout/${navItem.name.replace(" ", "")}`}
alt={navItem.name}
/>
<div>{navItem.displayName ?? navItem.name}</div>

View File

@@ -4,6 +4,7 @@ import { Menu } from "./Menu";
import { UserItem } from "./UserItem";
import navItems from "./nav-items.json";
import { useLocation } from "@remix-run/react";
import { Image } from "../Image";
export const Layout = React.memo(function Layout({
children,
@@ -22,13 +23,11 @@ export const Layout = React.memo(function Layout({
<header className="layout__header">
{currentPagesNavItem ? (
<h1 className="layout__page-heading">
<img
<Image
className="layout__icon"
// xxx: from constant... but this will be a component anyway?
// xxx: change to avif
src={`/img/layout/${currentPagesNavItem.name}.webp`}
width="40"
height="40"
path={`/img/layout/${currentPagesNavItem.name}`}
width={40}
height={40}
alt=""
/>
{currentPagesNavItem.displayName}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 635 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

BIN
public/img/layout/plus.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
public/img/layout/plus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB