Skip to content

refactor: images-loading #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions frontend/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
const nextConfig = {
reactStrictMode: true,
images: {
minimumCacheTTL: 31536000,
deviceSizes: [640, 750, 828, 1080, 1200, 1920],
remotePatterns: [
{
protocol: "https",
hostname: "delicate-eggs-595f0e58b8.media.strapiapp.com"
}
]
}
hostname: "delicate-eggs-595f0e58b8.media.strapiapp.com",
},
],
},
};

export default nextConfig;
1 change: 1 addition & 0 deletions frontend/src/app/for-lawyers/components/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const Hero: React.FC = async () => {
alt="Hero Image Background"
fill
priority
sizes="100vw"
className="absolute left-0 top-0 z-[-1] h-full object-cover"
/>
</div>
Expand Down
18 changes: 18 additions & 0 deletions frontend/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import Navbar from "@/components/Navbar";
import { navbarQuery, NavbarQueryType } from "@/queries/navbar";
import "@/styles/globals.css";
import { request } from "@/utils/graphQLClient";
import { HeroQueryType, herosQuery } from "@/queries/heros";

import { getImageProps } from "next/image";

const urbanist = Urbanist({
weight: ["400", "500"],
Expand All @@ -20,9 +23,24 @@ export default async function RootLayout({
children: React.ReactNode;
}) {
const navbarData = await request<NavbarQueryType>(navbarQuery);
const herosImgs = await request<HeroQueryType>(herosQuery);
const props = getImageProps({
src: herosImgs.earnPageHero.background.url,
alt: "earn",
fill: true,
priority: true,
});

return (
<html lang="en">
<head>
<link
rel="preload"
as="image"
imageSrcSet={props.props.srcSet}
imageSizes="100vw"
/>
</head>
<body className="min-w-80 bg-background-1 antialiased">
<main className={clsx(urbanist.className)}>
<Navbar {...{ navbarData }} />
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/BrandAssets/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const Hero: React.FC<IHero> = ({ heroData }) => {
alt="Hero Image Background"
fill
priority
sizes="100vw"
className="absolute left-0 top-0 z-[-1] h-full object-cover"
/>
</div>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/Community/hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const Hero: React.FC<IHero> = ({ heroData }) => {
alt="Hero Image Background"
fill
priority
sizes="100vw"
className="absolute left-0 top-0 z-[-1] h-full object-cover"
/>
</div>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/Cooperative/hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const Hero: React.FC<IHero> = ({ heroData }) => {
alt="Hero Image Background"
fill
priority
sizes="100vw"
className="absolute left-0 top-0 z-[-1] h-full object-cover"
/>
</div>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/Earn/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const Hero: React.FC<IHero> = ({ heroData }) => {
alt="Hero Image Background"
fill
priority
sizes="100vw"
className="absolute left-0 top-0 z-[-1] h-full object-cover"
/>
</div>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/ForBuilders/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const Hero: React.FC<IHero> = ({ heroData }) => {
alt="Hero Image Background"
fill
priority
sizes="100vw"
className="absolute left-0 top-0 z-[-1] h-full object-cover"
/>
</div>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/PNKToken/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const Hero: React.FC<IHero> = ({ heroData }) => {
alt="Hero Image Background"
fill
priority
sizes="100vw"
className="absolute left-0 top-0 z-[-1] h-full object-cover"
/>
</div>
Expand Down
29 changes: 29 additions & 0 deletions frontend/src/queries/heros.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { gql } from "graphql-request";

export const herosQuery = gql`
{
pnkTokenPageHero {
background {
url
}
}
earnPageHero {
background {
url
}
}
}
`;

export type HeroQueryType = {
pnkTokenPageHero: {
background: {
url: string;
};
};
earnPageHero: {
background: {
url: string;
};
};
};