-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use priority image loading for heroes
- Loading branch information
Showing
8 changed files
with
56 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { FunctionComponent, PropsWithChildren } from "react"; | ||
import * as Styled from "./styles"; | ||
|
||
interface HeroProps { | ||
data: Array<any>; | ||
focalPointX?: number; | ||
focalPointY?: number; | ||
className?: string; | ||
} | ||
const Hero: FunctionComponent<PropsWithChildren<HeroProps>> = ({ | ||
data, | ||
focalPointX = 50, | ||
focalPointY = 50, | ||
className, | ||
children, | ||
}) => { | ||
const imageData = data && data[0]; | ||
|
||
if (!imageData?.url) return null; | ||
|
||
return ( | ||
<Styled.HeroContainer | ||
data-cy="hero" | ||
style={{ | ||
"--Hero-object-position": `${focalPointX || 50}% ${focalPointY || 50}%`, | ||
}} | ||
className={className} | ||
> | ||
<Styled.HeroImage image={{ ...imageData, priority: true }} /> | ||
{children} | ||
</Styled.HeroContainer> | ||
); | ||
}; | ||
|
||
Hero.displayName = "Molecule.Hero"; | ||
|
||
export default Hero; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
declare module "csstype" { | ||
interface Properties { | ||
// Allow any CSS Custom Properties | ||
[index: `--${string}`]: any; | ||
} | ||
} |