Skip to content

Commit

Permalink
refactor: use Next image optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgoff committed Nov 21, 2024
1 parent 3432fa6 commit a3b3789
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
22 changes: 14 additions & 8 deletions components/molecules/Hero/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,21 @@ const Hero: FunctionComponent<PropsWithChildren<HeroProps>> = ({

if (!imageData?.url) return null;

const { width, height, url: src, altText: alt = "" } = imageData;

return (
<Styled.HeroContainer
data-cy="hero"
style={{
"--Hero-object-position": `${focalPointX || 50}% ${focalPointY || 50}%`,
}}
className={className}
>
<Styled.HeroImage image={{ ...imageData, priority: true }} />
<Styled.HeroContainer data-cy="hero" className={className}>
<Styled.HeroImage
{...{ width, height, src, alt }}
style={{
"--Hero-object-position": `${focalPointX || 50}% ${
focalPointY || 50
}%`,
}}
priority
fetchPriority="high"
quality={90}
/>
{children}
</Styled.HeroContainer>
);
Expand Down
3 changes: 2 additions & 1 deletion components/molecules/Hero/styles.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"use client";
import styled from "styled-components";
import { fluidScale, containerFullBleed } from "@/styles/globalStyles";
import Image from "@rubin-epo/epo-react-lib/Image";
// import Image from "@rubin-epo/epo-react-lib/Image";
import Image from "next/image";

export const HeroContainer = styled.div`
${containerFullBleed("CONTAINER_FULL")}
Expand Down
16 changes: 16 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ module.exports = {
},
];
},
images: {
remotePatterns: [
{
protocol: "https",
hostname: "storage.googleapis.com",
},
{
protocol: "https",
hostname: "rubin.canto.com",
},
{
protocol: "https",
hostname: "noirlab.edu",
},
],
},
experimental: {
forceSwcTransforms: true,
},
Expand Down

0 comments on commit a3b3789

Please sign in to comment.