perf(hero): remove artificial JS fade-in delay for LCP image
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import React, { useState } from 'react'
|
import React from 'react'
|
||||||
import { motion } from 'framer-motion'
|
import { motion } from 'framer-motion'
|
||||||
import type { Page, Media } from '../../payload-types'
|
import type { Page, Media } from '../../payload-types'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
@@ -43,7 +43,6 @@ export const HeroBlock: React.FC<Props> = ({
|
|||||||
floatingStat,
|
floatingStat,
|
||||||
whatsappNumber,
|
whatsappNumber,
|
||||||
}) => {
|
}) => {
|
||||||
const [imageLoaded, setImageLoaded] = useState(false)
|
|
||||||
const whatsappLink = whatsappNumber ? `https://wa.me/${whatsappNumber}` : '#'
|
const whatsappLink = whatsappNumber ? `https://wa.me/${whatsappNumber}` : '#'
|
||||||
|
|
||||||
const heroMedia = typeof image === 'object' && image !== null ? (image as Media) : null
|
const heroMedia = typeof image === 'object' && image !== null ? (image as Media) : null
|
||||||
@@ -69,10 +68,7 @@ export const HeroBlock: React.FC<Props> = ({
|
|||||||
fill
|
fill
|
||||||
priority
|
priority
|
||||||
sizes="100vw"
|
sizes="100vw"
|
||||||
onLoad={() => setImageLoaded(true)}
|
className="object-cover object-center"
|
||||||
className={`object-cover object-center transition-all duration-1000 ${
|
|
||||||
imageLoaded ? 'opacity-100 scale-100' : 'opacity-0 scale-105'
|
|
||||||
}`}
|
|
||||||
/>
|
/>
|
||||||
{/* Ciemny gradient pod spodem, by biały tekst był świetnie czytelny, a zdjęcie pozostało nasycone */}
|
{/* Ciemny gradient pod spodem, by biały tekst był świetnie czytelny, a zdjęcie pozostało nasycone */}
|
||||||
<div className="absolute inset-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent lg:bg-gradient-to-r lg:from-black/90 lg:via-black/40 lg:to-transparent" />
|
<div className="absolute inset-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent lg:bg-gradient-to-r lg:from-black/90 lg:via-black/40 lg:to-transparent" />
|
||||||
|
|||||||
Reference in New Issue
Block a user