From 5c3890cb1929c55fb8e047f2d4a0bdac8075682f Mon Sep 17 00:00:00 2001
From: "Kalle (Sendou)" <38327916+Sendouc@users.noreply.github.com>
Date: Mon, 1 Nov 2021 01:06:27 +0200
Subject: [PATCH] Use next/image in more places
---
frontend/components/layout/Layout.tsx | 12 +++----
frontend/components/layout/MobileNav.tsx | 11 +++----
frontend/components/tournament/MapPoolTab.tsx | 32 +++++++++----------
frontend/next.config.js | 5 +++
4 files changed, 29 insertions(+), 31 deletions(-)
create mode 100644 frontend/next.config.js
diff --git a/frontend/components/layout/Layout.tsx b/frontend/components/layout/Layout.tsx
index e08ba2276..bd5e95f43 100644
--- a/frontend/components/layout/Layout.tsx
+++ b/frontend/components/layout/Layout.tsx
@@ -38,8 +38,10 @@ export function Layout({ children }: { children: ReactNode }) {
{navItem.title}
{navItem.items.map((item) => (
-
{item}
@@ -127,6 +129,7 @@ const S_NavItemColumn = styled("div", {
const S_NavLink = styled("a", {
display: "flex",
alignItems: "center",
+ gap: "$2",
color: "$text",
textDecoration: "none",
fontSize: "$sm",
@@ -139,13 +142,6 @@ const S_NavLink = styled("a", {
},
});
-// TODO: figure out whether to server items from asset or public and migrate all images there
-// + if not using next image do some adjusting of the image size, format etc.
-const S_NavLinkImage = styled("img", {
- width: "1.75rem",
- marginRight: "$2",
-});
-
const S_NavGroupTitle = styled("div", {
textTransform: "uppercase",
fontWeight: "$bold",
diff --git a/frontend/components/layout/MobileNav.tsx b/frontend/components/layout/MobileNav.tsx
index fba862f06..b4d22cdce 100644
--- a/frontend/components/layout/MobileNav.tsx
+++ b/frontend/components/layout/MobileNav.tsx
@@ -3,6 +3,7 @@ import { styled } from "stitches.config";
import { navItems } from "utils/constants";
import NextLink from "next/link";
import { Fragment } from "react";
+import NextImage from "next/image";
export function MobileNav({ isExpanded }: { isExpanded: boolean }) {
return (
@@ -30,8 +31,10 @@ export function MobileNav({ isExpanded }: { isExpanded: boolean }) {
: undefined
}
>
-
{item}
@@ -90,11 +93,6 @@ const S_LinksContainer = styled("div", {
gridAutoRows: "4rem",
});
-const S_NavLinkImage = styled("img", {
- width: "2.5rem",
- marginRight: "$3",
-});
-
const S_GroupTitle = styled("div", {
textTransform: "uppercase",
alignSelf: "flex-end",
@@ -110,6 +108,7 @@ const S_GroupTitle = styled("div", {
const S_NavLink = styled("div", {
display: "flex",
alignItems: "center",
+ gap: "$2",
textTransform: "capitalize",
borderTop: "3px solid $bgLighter",
fontWeight: "$bold",
diff --git a/frontend/components/tournament/MapPoolTab.tsx b/frontend/components/tournament/MapPoolTab.tsx
index cc0b00d2f..23d0a6f84 100644
--- a/frontend/components/tournament/MapPoolTab.tsx
+++ b/frontend/components/tournament/MapPoolTab.tsx
@@ -1,4 +1,5 @@
import { styled } from "stitches.config";
+import NextImage from "next/image";
import { useTournamentData } from "hooks/data/useTournamentData";
import { stages, modesShort } from "@sendou-ink/shared/constants";
import type { Mode } from "@sendou-ink/api/common";
@@ -22,17 +23,24 @@ export function MapPoolTab() {
alt={stage}
src={`/img/stages/${stage.replaceAll(" ", "-").toLowerCase()}.png`}
filter={modesPerStage(data.mapPool)[stage] ? undefined : "bw"}
+ width={256}
+ height={144}
/>
{modesPerStage(data.mapPool)[stage] && (
{modesShort.map((mode) => {
- if (!modesPerStage(data.mapPool)[stage]?.includes(mode as Mode))
+ if (
+ !modesPerStage(data.mapPool)[stage]?.includes(mode as Mode)
+ ) {
return null;
+ }
return (
-
);
})}
@@ -64,15 +72,12 @@ const S_InfoSquare = styled("div", {
fontSize: "$xl",
backgroundImage: `url(/svg/background-pattern.svg)`,
backgroundColor: "$bgLighter",
-
- "@xs": {
- borderRadius: "$rounded",
- },
+ borderRadius: "$rounded",
});
const S_Container = styled("div", {
display: "grid",
- gridTemplateColumns: "1fr",
+ gridTemplateColumns: "repeat(2, 1fr)",
gap: "1rem",
"@xs": {
@@ -92,12 +97,8 @@ const S_StageImageContainer = styled("div", {
position: "relative",
});
-const S_StageImage = styled("img", {
- width: "100%",
-
- "@xs": {
- borderRadius: "$rounded",
- },
+const S_StageImage = styled(NextImage, {
+ borderRadius: "$rounded",
variants: {
filter: {
@@ -115,9 +116,6 @@ const S_ModeImagesContainer = styled("div", {
top: 0,
left: 0,
borderRadius: "$rounded 0 $rounded 0",
-});
-
-const S_ModeImage = styled("img", {
- width: "2.5rem",
padding: "$1",
+ gap: "$2",
});
diff --git a/frontend/next.config.js b/frontend/next.config.js
new file mode 100644
index 000000000..125403951
--- /dev/null
+++ b/frontend/next.config.js
@@ -0,0 +1,5 @@
+module.exports = {
+ images: {
+ formats: ["image/avif", "image/webp"],
+ },
+};