Skip to content

Commit

Permalink
D
Browse files Browse the repository at this point in the history
  • Loading branch information
neerajrekwar committed Aug 9, 2024
1 parent 3ed1cda commit 1e60d0b
Show file tree
Hide file tree
Showing 8 changed files with 243 additions and 36 deletions.
6 changes: 3 additions & 3 deletions app/components/CoverDemo.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"use client"

import React from "react";
import { Cover } from "@/components/ui/cover";
import { Cover } from "@/app/components/ui/cover";

export function CoverDemo() {
return (
<div>
<h2 className="text-4xl md:text-4xl lg:text-6xl font-semibold max-w-7xl mx-auto text-center mt-6 relative z-20 py-6 bg-clip-text text-transparent bg-gradient-to-b from-neutral-800 via-neutral-700 to-neutral-700 dark:from-neutral-800 dark:via-white dark:to-white">
<h2 className="text-2xl md:text-3xl lg:text-5xl font-semibold max-w-7xl mx-auto text-center mt-6 relative z-20 py-6 bg-clip-text text-transparent bg-gradient-to-b from-four via-five to-six dark:from-neutral-800 dark:via-white dark:to-white">
Balance innovation and stability<br /> at <Cover>warp speed</Cover>
</h2>
</div>
Expand Down
1 change: 1 addition & 0 deletions app/components/IfoLinks.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@


import Link from 'next/link';
import { motion } from 'framer-motion';

Expand Down
62 changes: 62 additions & 0 deletions app/components/MultiStepLoader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"use client";
import React, { useState } from "react";
import { MultiStepLoader as Loader } from "./ui/multi-step-loader";
import { IconSquareRoundedX } from "@tabler/icons-react";

const loadingStates = [
{
text: "Buying a condo",
},
{
text: "Travelling in a flight",
},
{
text: "Meeting Tyler Durden",
},
{
text: "He makes soap",
},
{
text: "We goto a bar",
},
{
text: "Start a fight",
},
{
text: "We like it",
},
{
text: "Welcome to F**** C***",
},
];

export function MultiStepLoader() {
const [loading, setLoading] = useState(false);
return (
<div className="w-full h-40 flex items-center justify-center">
{/* Core Loader Modal */}
<Loader loadingStates={loadingStates} loading={loading} duration={2000} />

{/* The buttons are for demo only, remove it in your actual code ⬇️ */}
<button
onClick={() => setLoading(true)}
className="bg-six hover:bg-seven text-four mx-auto text-sm md:text-base transition font-medium duration-200 h-10 rounded-lg px-8 flex items-center justify-center"
style={{
boxShadow:
"0px -1px 0px 0px #ffffff40 inset, 0px 1px 0px 0px #ffffff40 inset",
}}
>
Click to load
</button>

{loading && (
<button
className="fixed top-4 right-4 text-black dark:text-white z-[120]"
onClick={() => setLoading(false)}
>
<IconSquareRoundedX className="h-10 w-10" />
</button>
)}
</div>
);
}
29 changes: 11 additions & 18 deletions app/components/heroSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import CountAnimation from "./CountAnimation";
import { ImageSlides } from "./ImageSlides";
import Refresh from "./acceries/Refresh";
import TextRotator from "./TextsRefresh";
import CoverDemo from "./CoverDemo";
import {CoverDemo} from './CoverDemo';
import {MultiStepLoader} from "./MultiStepLoader"



export function HeroSection() {
Expand Down Expand Up @@ -731,7 +733,7 @@ export function HeroSection() {
transition={{ delay: 0.6 }}
className="m-2 w-full sm:w-auto rounded-lg text-right text-six bg-black"
>
<h4 className="px-2 text-3xl font-semibold">
<h4 className="px-2 text-4xl font-bold">
<TextRotator />
</h4>
<div className="m-2">
Expand All @@ -745,7 +747,7 @@ export function HeroSection() {
className="m-2 flex col-span-2 rounded-lg text-six bg-black"
>

<h4 className="px-2 basis-1/2 text-2xl m-2 font-semibold">
<h4 className="px-2 basis-1/2 text-4xl m-2 font-bold">
{" "}
Leveraging modern JavaScript features
</h4>
Expand All @@ -764,23 +766,19 @@ export function HeroSection() {
<div className="rounded-md m-2 h-40 overflow-hidden z-20">
<ImageSlides />
</div>
<h4 className="px-2 text-xl m-2 font-semibold">
<h4 className="px-2 text-4xl m-2 font-bold">
Efficient algorithms and data structures
</h4>
</motion.li>
<motion.li
initial={{ opacity: 0, x: -40, y: 40 }}
whileInView={{ opacity: 1, x: 0, y: 0 }}
transition={{ delay: 0.9 }}
className="m-2 rounded-lg text-six bg-black"
className="m-2 rounded-lg w-full sm:w-auto text-six bg-black"
>

<h4 className="px-2 text-xl font-semibold p-2">Improved User Experience</h4>
<p className="m-2 text-sm">
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Accusamus error alias unde optio deleniti. Deserunt vero,
ad a.
</p>
<h4 className="px-2 text-4xl md:text-2xl m-2 font-bold">Improved User Experience</h4>
<MultiStepLoader />
</motion.li>
<motion.li
initial={{ opacity: 0, x: -40, y: 40 }}
Expand All @@ -789,11 +787,10 @@ export function HeroSection() {
className="m-2 rounded-lg text-six bg-black"
>

<h4 className="px-2 text-xl font-semibold">
<h4 className="px-2 text-xl font-semibold font-bold bg-clip-text text-transparent bg-gradient-to-r from-red-400 via-yellow-400 to-blue-500">
versions to access the latest performance optimizations
</h4>
<p className="m-2">
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Accusamus error alias unde optio deleniti. Deserunt vero,
ad a.
</p>
Expand All @@ -802,13 +799,9 @@ export function HeroSection() {
initial={{ opacity: 0, x: -40, y: 40 }}
whileInView={{ opacity: 1, x: 0, y: 0 }}
transition={{ delay: 1.1 }}
className="m-2 col-span-2 rounded-lg text-six bg-black"
className="m-2 p-2 col-span-2 rounded-lg text-six bg-black"
>

<h4 className="px-2 text-xl font-semibold">Balance innovation and stability</h4>
<div className="m-2">
<CoverDemo />
</div>
</motion.li>
<motion.li
initial={{ opacity: 0, scale: 0.5, x: -40, y: 40 }}
Expand Down
2 changes: 1 addition & 1 deletion app/components/ui/cover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { useEffect, useId, useState } from "react";
import { AnimatePresence, motion } from "framer-motion";
import { useRef } from "react";
import { cn } from "@/lib/utils";
import { SparklesCore } from "@/components/ui/sparkles";
import { SparklesCore } from "@/app/components/ui/sparkles";

export const Cover = ({
children,
Expand Down
146 changes: 146 additions & 0 deletions app/components/ui/multi-step-loader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
"use client";
import { cn } from "@/lib/utils";
import { AnimatePresence, motion } from "framer-motion";
import { useState, useEffect } from "react";

const CheckIcon = ({ className }: { className?: string }) => {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth={1.5}
stroke="currentColor"
className={cn("w-6 h-6 ", className)}
>
<path d="M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />
</svg>
);
};

const CheckFilled = ({ className }: { className?: string }) => {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="currentColor"
className={cn("w-6 h-6 ", className)}
>
<path
fillRule="evenodd"
d="M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12Zm13.36-1.814a.75.75 0 1 0-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.094l3.75-5.25Z"
clipRule="evenodd"
/>
</svg>
);
};

type LoadingState = {
text: string;
};

const LoaderCore = ({
loadingStates,
value = 0,
}: {
loadingStates: LoadingState[];
value?: number;
}) => {
return (
<div className="flex relative justify-start max-w-xl mx-auto flex-col mt-40">
{loadingStates.map((loadingState, index) => {
const distance = Math.abs(index - value);
const opacity = Math.max(1 - distance * 0.2, 0); // Minimum opacity is 0, keep it 0.2 if you're sane.

return (
<motion.div
key={index}
className={cn("text-left flex gap-2 mb-4")}
initial={{ opacity: 0, y: -(value * 40) }}
animate={{ opacity: opacity, y: -(value * 40) }}
transition={{ duration: 0.5 }}
>
<div>
{index > value && (
<CheckIcon className="text-black dark:text-white" />
)}
{index <= value && (
<CheckFilled
className={cn(
"text-black dark:text-white",
value === index &&
"text-black dark:text-lime-500 opacity-100"
)}
/>
)}
</div>
<span
className={cn(
"text-black dark:text-white",
value === index && "text-black dark:text-lime-500 opacity-100"
)}
>
{loadingState.text}
</span>
</motion.div>
);
})}
</div>
);
};

export const MultiStepLoader = ({
loadingStates,
loading,
duration = 2000,
loop = true,
}: {
loadingStates: LoadingState[];
loading?: boolean;
duration?: number;
loop?: boolean;
}) => {
const [currentState, setCurrentState] = useState(0);

useEffect(() => {
if (!loading) {
setCurrentState(0);
return;
}
const timeout = setTimeout(() => {
setCurrentState((prevState) =>
loop
? prevState === loadingStates.length - 1
? 0
: prevState + 1
: Math.min(prevState + 1, loadingStates.length - 1)
);
}, duration);

return () => clearTimeout(timeout);
}, [currentState, loading, loop, loadingStates.length, duration]);
return (
<AnimatePresence mode="wait">
{loading && (
<motion.div
initial={{
opacity: 0,
}}
animate={{
opacity: 1,
}}
exit={{
opacity: 0,
}}
className="w-full h-full fixed inset-0 z-[100] flex items-center justify-center backdrop-blur-2xl"
>
<div className="h-96 relative">
<LoaderCore value={currentState} loadingStates={loadingStates} />
</div>

<div className="bg-gradient-to-t inset-x-0 z-20 bottom-0 bg-white dark:bg-black h-full absolute [mask-image:radial-gradient(900px_at_center,transparent_30%,white)]" />
</motion.div>
)}
</AnimatePresence>
);
};
Loading

0 comments on commit 1e60d0b

Please sign in to comment.