Skip to content
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

Fix hydration errors #439

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Changes from all 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
105 changes: 53 additions & 52 deletions src/components/Index/Hero.component.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
"use client";

import React, { Suspense } from "react";
import React from "react";
import dynamic from "next/dynamic";

import Icons from "./Icons.component";
import FadeDown from "@/components/Animations/FadeDown.component";
import FadeUp from "@/components/Animations/FadeUp.component";
import RotatingLoader from "@/components/Animations/RotatingLoader.component";
import FadeDown from "../Animations/FadeDown.component";
import FadeUp from "../Animations/FadeUp.component";
import RotatingLoader from "../Animations/RotatingLoader.component";
import MobileBackground from "./MobileBackground.component";

const ReactMatrixAnimation = dynamic(
() => import("../Animations/Matrix.component"),
{ ssr: false },
{
ssr: false,
loading: () => (
<div className="text-center">
<RotatingLoader />
</div>
),
}
);

type THero = { text: string };
Expand All @@ -25,55 +32,49 @@ interface IContent {
* @param {THero[]} props.content - Array of text content for the hero section
* @returns {JSX.Element} The rendered Hero component
*/
const Hero = ({ content }: IContent) => (
<article
aria-label="Kontainer for animasjoner av introtekst"
id="main-hero"
data-testid="main-hero"
className="relative flex flex-col justify-center text-lg h-[26rem] md:h-[28.125rem] overflow-hidden w-full"
>
<MobileBackground />
<div className="hidden md:block absolute inset-0 w-full h-full">
<Suspense
fallback={
<div className="text-center">
<RotatingLoader />
</div>
}
>
const Hero = ({ content }: IContent) => {
return (
<article
aria-label="Kontainer for animasjoner av introtekst"
id="main-hero"
data-testid="main-hero"
className="relative flex flex-col justify-center text-lg h-[26rem] md:h-[28.125rem] overflow-hidden w-full"
>
<MobileBackground />
<div className="hidden md:block absolute inset-0 w-full h-full">
<ReactMatrixAnimation />
</Suspense>
</div>
<FadeDown delay={0.1}>
<div className="relative z-10 mt-12 md:mb-4 p-2 md:mt-4 lg:mt-4 xl:mt-4 mb-14 md:mb-6">
<div className="rounded">
<section>
<FadeDown delay={0.5} cssClass="text-center">
<h1
data-cy="hei"
className="introtekst inline-block text-5xl text-slate-300"
</div>
<FadeDown delay={0.1}>
<div className="relative z-10 mt-12 md:mb-4 p-2 md:mt-4 lg:mt-4 xl:mt-4 mb-14 md:mb-6">
<div className="rounded">
<section>
<FadeDown delay={0.5} cssClass="text-center">
<h1
data-cy="hei"
className="introtekst inline-block text-5xl text-slate-300"
>
{content.length > 0 ? content[0].text : "Hei!"}
</h1>
</FadeDown>
<FadeUp
delay={0.9}
cssClass="mt-4 px-6 text-lg md:mx-auto md:p-0 md:text-center md:text-xl lg:w-2/3 lg:p-0 lg:text-center lg:text-xl xl:p-0 xl:text-center xl:text-2xl text-slate-300"
>
<h2>{content.length > 0 && content[1].text}</h2>
</FadeUp>
<FadeDown
delay={1.4}
cssClass="mt-4 px-6 text-lg md:mx-auto md:p-0 md:text-center md:text-xl lg:w-2/3 lg:p-0 lg:text-center lg:text-xl xl:p-0 xl:text-center xl:text-2xl text-slate-300"
>
{content.length > 0 ? content[0].text : "Hei!"}
</h1>
</FadeDown>
<FadeUp
delay={0.9}
cssClass="mt-4 px-6 text-lg md:mx-auto md:p-0 md:text-center md:text-xl lg:w-2/3 lg:p-0 lg:text-center lg:text-xl xl:p-0 xl:text-center xl:text-2xl text-slate-300"
>
<h2>{content.length > 0 && content[1].text}</h2>
</FadeUp>
<FadeDown
delay={1.4}
cssClass="mt-4 px-6 text-lg md:mx-auto md:p-0 md:text-center md:text-xl lg:w-2/3 lg:p-0 lg:text-center lg:text-xl xl:p-0 xl:text-center xl:text-2xl text-slate-300"
>
<p>{content.length > 0 && content[2].text}</p>
</FadeDown>
<Icons />
</section>
<p>{content.length > 0 && content[2].text}</p>
</FadeDown>
<Icons />
</section>
</div>
</div>
</div>
</FadeDown>
</article>
);
</FadeDown>
</article>
);
};

export default Hero;
Loading