[WIP] Fix app images in Next.js

Yeah, cool, now we use the `next/image` tag, and our images are showing up again!

There's still lint errors for using bare img tags in some places, but I'm not sure I really care…
This commit is contained in:
Emi Matchu 2021-11-02 00:50:39 -07:00
parent 7fd85e5e2a
commit 405b3ded77
17 changed files with 55 additions and 55 deletions

View file

@ -13,11 +13,10 @@ import { HamburgerIcon } from "@chakra-ui/icons";
import { Link, useLocation } from "react-router-dom"; import { Link, useLocation } from "react-router-dom";
import { useAuth0 } from "@auth0/auth0-react"; import { useAuth0 } from "@auth0/auth0-react";
import { ChevronLeftIcon } from "@chakra-ui/icons"; import { ChevronLeftIcon } from "@chakra-ui/icons";
import Image from "next/image";
import useCurrentUser from "./components/useCurrentUser"; import useCurrentUser from "./components/useCurrentUser";
import HomeLinkIcon from "./images/home-link-icon.png"; import HomeLinkIcon from "./images/home-link-icon.png";
import HomeLinkIcon2x from "./images/home-link-icon@2x.png";
function GlobalHeader() { function GlobalHeader() {
return ( return (
@ -69,16 +68,15 @@ function HomeLink(props) {
> >
<ChevronLeftIcon /> <ChevronLeftIcon />
</Box> </Box>
<Box <Box height="32px" borderRadius="lg" boxShadow="md" overflow="hidden">
as="img" <Image
src={HomeLinkIcon} src={HomeLinkIcon}
srcSet={`${HomeLinkIcon} 1x, ${HomeLinkIcon2x} 2x`}
alt="" alt=""
height="2em" width={32}
width="2em" height={32}
borderRadius="lg" layout="fixed"
boxShadow="md"
/> />
</Box>
<Box <Box
height="2em" height="2em"
width="2em" width="2em"

View file

@ -26,6 +26,7 @@ import {
import { ArrowForwardIcon, SearchIcon } from "@chakra-ui/icons"; import { ArrowForwardIcon, SearchIcon } from "@chakra-ui/icons";
import { Link, useHistory, useLocation } from "react-router-dom"; import { Link, useHistory, useLocation } from "react-router-dom";
import { useLazyQuery, useQuery } from "@apollo/client"; import { useLazyQuery, useQuery } from "@apollo/client";
import Image from "next/image";
import { import {
Delay, Delay,
@ -45,9 +46,7 @@ import SquareItemCard, {
import WIPCallout from "./components/WIPCallout"; import WIPCallout from "./components/WIPCallout";
import HomepageSplashImg from "./images/homepage-splash.png"; import HomepageSplashImg from "./images/homepage-splash.png";
import HomepageSplashImg2x from "./images/homepage-splash@2x.png";
import FeedbackXweeImg from "./images/feedback-xwee.png"; import FeedbackXweeImg from "./images/feedback-xwee.png";
import FeedbackXweeImg2x from "./images/feedback-xwee@2x.png";
function HomePage() { function HomePage() {
usePageTitle(null); usePageTitle(null);
@ -71,11 +70,12 @@ function HomePage() {
wornItemIds={[]} wornItemIds={[]}
loadingDelayMs={1500} loadingDelayMs={1500}
placeholder={ placeholder={
<Box <Image
as="img"
src={HomepageSplashImg} src={HomepageSplashImg}
srcSet={`${HomepageSplashImg} 1x, ${HomepageSplashImg2x} 2x`} width={200}
height={200}
alt="" alt=""
layout="fixed"
/> />
} }
/> />
@ -621,33 +621,19 @@ function FeedbackFormSection() {
flex="0 0 auto" flex="0 0 auto"
marginTop="4" marginTop="4"
> >
<Box <Image
as="img"
src={FeedbackXweeImg} src={FeedbackXweeImg}
srcSet={`${FeedbackXweeImg} 1x, ${FeedbackXweeImg2x} 2x`} alt="Smiling green Xweetok"
height="90px" width={90}
width="90px" height={90}
layout="fixed"
opacity="0.9" opacity="0.9"
alt=""
/> />
</Box> </Box>
<FeedbackFormPitch /> <FeedbackFormPitch />
</Flex> </Flex>
</FeedbackFormContainer> </FeedbackFormContainer>
<FeedbackFormContainer <FeedbackFormContainer borderColor={formBorderColor}>
borderColor={formBorderColor}
image={
<Box
as="img"
src={FeedbackXweeImg}
srcSet={`${FeedbackXweeImg} 1x, ${FeedbackXweeImg2x} 2x`}
height="90px"
width="90px"
opacity="0.9"
alt=""
/>
}
>
<FeedbackForm /> <FeedbackForm />
</FeedbackFormContainer> </FeedbackFormContainer>
</VStack> </VStack>

View file

@ -17,6 +17,7 @@ import {
useToast, useToast,
} from "@chakra-ui/react"; } from "@chakra-ui/react";
import { loadable } from "../util"; import { loadable } from "../util";
import Image from "next/image";
import { petAppearanceFragment } from "../components/useOutfitAppearance"; import { petAppearanceFragment } from "../components/useOutfitAppearance";
import getVisibleLayers from "../../shared/getVisibleLayers"; import getVisibleLayers from "../../shared/getVisibleLayers";
@ -493,7 +494,7 @@ function PoseOption({
</Box> </Box>
) : ( ) : (
<Flex align="center" justify="center" width="100%" height="100%"> <Flex align="center" justify="center" width="100%" height="100%">
<EmojiImage src={twemojiQuestion} boxSize="24px" /> <EmojiImage src={twemojiQuestion} boxSize={24} />
</Flex> </Flex>
)} )}
</Box> </Box>
@ -512,8 +513,16 @@ function PoseOption({
); );
} }
function EmojiImage({ src, alt, boxSize = "16px" }) { function EmojiImage({ src, alt, boxSize = 16 }) {
return <img src={src} alt={alt} width={boxSize} height={boxSize} />; return (
<Image
src={src}
alt={alt}
width={boxSize}
height={boxSize}
layout="fixed"
/>
);
} }
function usePoses(speciesId, colorId, selectedPose) { function usePoses(speciesId, colorId, selectedPose) {

View file

@ -1,10 +1,8 @@
import React from "react";
import { Box, Flex, Tooltip } from "@chakra-ui/react"; import { Box, Flex, Tooltip } from "@chakra-ui/react";
import Image from "next/image";
import { useCommonStyles } from "../util"; import { useCommonStyles } from "../util";
import WIPXweeImg from "../images/wip-xwee.png"; import WIPXweeImg from "../images/wip-xwee.png";
import WIPXweeImg2x from "../images/wip-xwee@2x.png";
function WIPCallout({ function WIPCallout({
children, children,
@ -30,14 +28,18 @@ function WIPCallout({
fontSize={size === "sm" ? "xs" : "sm"} fontSize={size === "sm" ? "xs" : "sm"}
> >
<Box <Box
as="img"
src={WIPXweeImg}
srcSet={`${WIPXweeImg} 1x, ${WIPXweeImg2x} 2x`}
alt=""
width={size === "sm" ? "24px" : "36px"} width={size === "sm" ? "24px" : "36px"}
height={size === "sm" ? "24px" : "36px"} height={size === "sm" ? "24px" : "36px"}
marginRight="2" marginRight="2"
>
<Image
src={WIPXweeImg}
alt="Curious blue Xweetok, tilted head"
width={size === "sm" ? 24 : 36}
height={size === "sm" ? 24 : 36}
layout="fixed"
/> />
</Box>
{children || ( {children || (
<> <>
<Box display={{ base: "none", md: "block" }}> <Box display={{ base: "none", md: "block" }}>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

BIN
src/app/images/error-grundo.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

View file

@ -9,10 +9,10 @@ import {
} from "@chakra-ui/react"; } from "@chakra-ui/react";
import loadableLibrary from "@loadable/component"; import loadableLibrary from "@loadable/component";
import * as Sentry from "@sentry/react"; import * as Sentry from "@sentry/react";
import { WarningIcon } from "@chakra-ui/icons";
import NextImage from "next/image";
import ErrorGrundoImg from "./images/error-grundo.png"; import ErrorGrundoImg from "./images/error-grundo.png";
import ErrorGrundoImg2x from "./images/error-grundo@2x.png";
import { WarningIcon } from "@chakra-ui/icons";
/** /**
* Delay hides its content at first, then shows it after the given delay. * Delay hides its content at first, then shows it after the given delay.
@ -451,16 +451,21 @@ export function MajorErrorMessage({ error = null, variant = "unexpected" }) {
> >
<Box gridArea="icon" marginTop="2"> <Box gridArea="icon" marginTop="2">
<Box <Box
as="img"
src={ErrorGrundoImg}
srcSet={`${ErrorGrundoImg} 1x, ${ErrorGrundoImg2x} 2x`}
borderRadius="full" borderRadius="full"
boxShadow="md" boxShadow="md"
overflow="hidden"
width="100px" width="100px"
height="100px" height="100px"
alt="" >
<NextImage
src={ErrorGrundoImg}
alt="Distressed Grundo programmer"
width={100}
height={100}
layout="fixed"
/> />
</Box> </Box>
</Box>
<Box gridArea="title" fontSize="lg" marginBottom="1"> <Box gridArea="title" fontSize="lg" marginBottom="1">
{variant === "unexpected" && <>Ah dang, I broke it 😖</>} {variant === "unexpected" && <>Ah dang, I broke it 😖</>}
{variant === "network" && <>Oops, it didn't work, sorry 😖</>} {variant === "network" && <>Oops, it didn't work, sorry 😖</>}