Skip to content

Commit 684faa4

Browse files
kushchoudhary98mlodicabheektripathySyedAhkam
authored
[Enhancement]: Added a typing animation to the Landing Page (#22)
* Fix invalid import in contentlayer config * [Enhancement]: Added a typing animation to the Landing Page --------- Co-authored-by: Matteo Lodi <30625432+mlodic@users.noreply.github.com> Co-authored-by: Abheek Tripathy <90976669+abheektripathy@users.noreply.github.com> Co-authored-by: Syed Ahkam <smahkam57@gmail.com>
1 parent bd6155a commit 684faa4

File tree

4 files changed

+89
-12
lines changed

4 files changed

+89
-12
lines changed

components/sections/HeroSection.tsx

+22-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* eslint-disable @next/next/no-img-element */
44
import Link from "next/link";
55
import { motion } from "framer-motion";
6-
import { useState, useEffect } from "react";
6+
import { TypeAnimation } from 'react-type-animation';
77

88
/* eslint-disable react/jsx-no-undef */
99
interface HeroSectionProps {
@@ -12,15 +12,8 @@ interface HeroSectionProps {
1212

1313
export default function HeroSection(props: HeroSectionProps) {
1414
const { isMobile } = props;
15-
const [words] = useState(["a hash.", "an ip.", "a malware.", "a domain."]);
16-
const [currentWordIndex, setCurrentWordIndex] = useState(0);
15+
const words = ["a hash.", 2000, "an ip.", 2000, "a malware.", 2000, "a domain.", 2000];
1716

18-
useEffect(() => {
19-
const intervalId = setInterval(() => {
20-
setCurrentWordIndex((currentIndex) => (currentIndex + 1) % words.length);
21-
}, 3000);
22-
return () => clearInterval(intervalId);
23-
}, [words]);
2417
return (
2518
<>
2619
{isMobile ? (
@@ -31,7 +24,16 @@ export default function HeroSection(props: HeroSectionProps) {
3124
<div className="bg-inherit w-full flex flex-col items-center justify-center px-5">
3225
<h1 className="text-white text-center text-3xl leading-snug lg:leading-snug xl:leading-snug font-SpaceGrotesk font-semibold ">
3326
Get Threat Intelligence data about {" "}
34-
<span className="text-[#00ADEF]">{words[currentWordIndex]}</span>
27+
<span className="text-[#00ADEF]">
28+
<TypeAnimation
29+
sequence={words}
30+
preRenderFirstString={false}
31+
wrapper="span"
32+
speed={20}
33+
style={{ fontSize: '1em', display: 'inline-block' }}
34+
repeat={Infinity}
35+
/>
36+
</span>
3537
</h1>
3638
<h2 className=" text-white text-center text-lg mt-8 font-SpaceGrotesk font-extralight px-4">
3739
From multiple sources with just a{" "}
@@ -69,7 +71,16 @@ export default function HeroSection(props: HeroSectionProps) {
6971
<div className="bg-inherit w-4/6 flex flex-col items-left justify-center px-16">
7072
<h1 className="text-white text-left text-5xl lg:text-6xl xl:text-7xl leading-snug lg:leading-snug xl:leading-snug font-SpaceGrotesk font-semibold ">
7173
Get Threat Intelligence data about {" "}
72-
<span className="text-[#00ADEF]">{words[currentWordIndex]}</span>
74+
<span className="text-[#00ADEF]">
75+
<TypeAnimation
76+
sequence={words}
77+
preRenderFirstString={false}
78+
wrapper="span"
79+
speed={20}
80+
style={{ fontSize: '1em', display: 'inline-block' }}
81+
repeat={Infinity}
82+
/>
83+
</span>
7384
</h1>
7485
<h2 className=" text-white text-left text-3xl lg:text-3xl xl:text-4xl mt-8 font-SpaceGrotesk font-extralight">
7586
From multiple sources with just a{" "}

contentlayer.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineDocumentType, makeSource } from '@contentlayer/source-files'
1+
import { defineDocumentType, makeSource } from 'contentlayer/source-files'
22

33
export const Post = defineDocumentType(() => ({
44
name: 'Post',

package-lock.json

+65
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"react": "18.2.0",
2525
"react-dom": "18.2.0",
2626
"react-scroll": "^1.8.9",
27+
"react-type-animation": "^3.2.0",
2728
"swiper": "^9.3.2",
2829
"tailwindcss": "3.3.2",
2930
"typescript": "5.0.4"

0 commit comments

Comments
 (0)