Skip to content

Commit 0e389f4

Browse files
author
Carla Goncalves
committed
Update image and avatar
1 parent 5735b9d commit 0e389f4

5 files changed

Lines changed: 28 additions & 12 deletions

File tree

apps/site/next.config.mjs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ if (
3030
!process.env.NEXT_BLOG_ORIGIN && "BLOG_ORIGIN is required in production",
3131
]
3232
.filter(Boolean)
33-
.join("; ")
33+
.join("; "),
3434
);
3535
}
3636

37-
3837
const ContentSecurityPolicy = `
3938
default-src 'self';
4039
script-src 'self' 'unsafe-inline' 'unsafe-eval'
@@ -257,7 +256,7 @@ const config = {
257256
allowedDevOrigins,
258257
reactStrictMode: true,
259258
images: {
260-
unoptimized: true,
259+
unoptimized: false,
261260
remotePatterns: [
262261
{
263262
protocol: "https",
@@ -757,9 +756,8 @@ const config = {
757756
destination: "https://accelerate-speed-test.vercel.app/:path*",
758757
},
759758

760-
761-
// Proxy canonical docs path to docs infrastructure
762-
{
759+
// Proxy canonical docs path to docs infrastructure
760+
{
763761
source: "/docs",
764762
destination: `${DOCS_ORIGIN}/docs`,
765763
missing: [{ type: "host", value: DOCS_ORIGIN_HOST }],
@@ -806,7 +804,6 @@ const config = {
806804
// Pages
807805
// TODO We have a redirect for this above to /careers, so should probably be removed here?
808806

809-
810807
{
811808
source: "/dataguide/:any*",
812809
destination: "https://dataguide.vercel.app/dataguide/:any*",

apps/site/src/components/homepage/bento.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { useCallback, useEffect, useRef, useState } from "react";
44
import Link from "next/link";
5+
import Image from "next/image";
56
import { Action } from "@prisma/eclipse";
67
import { cn } from "@prisma-docs/ui/lib/cn";
78
import { useTheme } from "@prisma-docs/ui/components/theme-provider";
@@ -193,14 +194,16 @@ export const Card = ({ card, color }: CardProps) => {
193194
</div>
194195
</div>
195196
{card.image && (
196-
// eslint-disable-next-line @next/next/no-img-element
197-
<img
197+
<Image
198198
src={
199199
mounted && resolvedTheme === "light"
200200
? `${card.image}_light.svg`
201201
: `${card.image}.svg`
202202
}
203203
alt={card.title}
204+
width={1200}
205+
height={800}
206+
loading="lazy"
204207
className="px-4 z-2 pt-0 pb-0 min-w-full min-h-[60%] object-fill object-[top_left] [mask-image:linear-gradient(to_bottom,rgba(0,0,0,1)_60%,transparent_90%)] [-webkit-mask-image:linear-gradient(to_bottom,rgba(0,0,0,1)_60%,transparent_90%)]"
205208
/>
206209
)}

apps/site/src/components/homepage/card-section/card-section.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useInView } from "react-intersection-observer";
66
import { cn } from "../../../lib/cn";
77
import { useTheme } from "@prisma-docs/ui/components/theme-provider";
88
import { Action } from "@prisma/eclipse";
9+
import Image from "next/image";
910

1011
interface TwoColumnItem {
1112
content: ReactNode;
@@ -166,8 +167,8 @@ export const CardSection = ({ cardSection }: CardSectionProps) => {
166167
<LogoGrid color={item.color} />
167168
)}
168169
{item.visualType === "image" && item.imageUrl && (
169-
<div key={`images-${index}`}>
170-
<img
170+
<div key={`images-${index}`} className="relative w-full">
171+
<Image
171172
key={`desktop-img-${index}`}
172173
className={cn(
173174
"hidden sm:block w-full h-auto",
@@ -180,9 +181,13 @@ export const CardSection = ({ cardSection }: CardSectionProps) => {
180181
: `${item.imageUrl}.svg`
181182
}
182183
alt={item.imageAlt || ""}
184+
width={1200}
185+
height={800}
186+
priority={index === 0}
187+
loading={index === 0 ? "eager" : "lazy"}
183188
/>
184189
{item.mobileImageUrl && (
185-
<img
190+
<Image
186191
key={`mobile-img-${index}`}
187192
className={cn(
188193
"w-full h-auto sm:hidden",
@@ -195,6 +200,10 @@ export const CardSection = ({ cardSection }: CardSectionProps) => {
195200
: `${item.mobileImageUrl}.svg`
196201
}
197202
alt={item.mobileImageAlt || ""}
203+
width={800}
204+
height={600}
205+
priority={index === 0}
206+
loading={index === 0 ? "eager" : "lazy"}
198207
/>
199208
)}
200209
</div>

apps/site/src/components/homepage/testimonials/testimonial-item.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export const TestimonialItem = ({
4444
imageUrl || "https://avatar.vercel.sh/" + encodeURIComponent(author)
4545
}
4646
alt={imageAlt || `Profile photo of ${author}`}
47+
loading="lazy"
4748
></Avatar>
4849
<div
4950
className={cn(

packages/eclipse/src/components/avatar.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ export interface AvatarProps extends Omit<
6666
* Alt text for image format
6767
*/
6868
alt?: string;
69+
/**
70+
* Loading behavior for image format
71+
*/
72+
loading?: "lazy" | "eager";
6973
/**
7074
* Icon or initials content
7175
*/
@@ -108,6 +112,7 @@ const Avatar = React.forwardRef<HTMLDivElement, AvatarProps>(
108112
format = "image",
109113
src,
110114
alt,
115+
loading,
111116
children,
112117
...props
113118
},
@@ -123,6 +128,7 @@ const Avatar = React.forwardRef<HTMLDivElement, AvatarProps>(
123128
<img
124129
src={src}
125130
alt={alt || "Avatar"}
131+
loading={loading}
126132
className={cn(avatarContentVariants({ format }))}
127133
/>
128134
) : (

0 commit comments

Comments
 (0)