Skip to content

Commit

Permalink
hgfd
Browse files Browse the repository at this point in the history
  • Loading branch information
neerajrekwar committed Sep 5, 2024
1 parent dca3e10 commit 5b3d466
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 8 deletions.
35 changes: 35 additions & 0 deletions app/components/AnimatedToolstips.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"use client";
import React from "react";
import { AnimatedTooltip } from "./ui/animated-tooltip";
const people = [
{
id: 1,
name: "Neeraj Rekwar",
designation: "Passionate programmer",
image:
"/me.webp",
},
{
id: 2,
name: "Robert Johnson",
designation: "Product Manager",
image:
"",
},
{
id: 3,
name: "Jane Smith",
designation: "Data Scientist",
image:
"",
}

];

export function AnimatedTooltipPreview() {
return (
<div className="flex flex-row items-center justify-center mb-10 w-full">
<AnimatedTooltip items={people} />
</div>
);
}
2 changes: 1 addition & 1 deletion app/components/VisionSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ export const VisionSection: React.FC = () => {
</div>
</div>
<div className="border-third">
<div className=" my-6 border-yellow-500 bg-secondary p-2">
<div className=" py-6 border-yellow-500 bg-secondary p-2">
<h1 className="md:text-2xl text-xl text-primary py-6 text-center m-auto max-w-3xl">
Maximized efficiency with fully automated best practices and
fully supported advanced tricks.
Expand Down
2 changes: 1 addition & 1 deletion app/components/WobbleCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function WobbleCardDemo() {
>
<div className="max-w-xs">
<h2 className="text-left text-balance text-base md:text-xl lg:text-3xl font-semibold tracking-[-0.015em] text-white">
A photo-holistic person involves considering the entirety of the universe in photography
A photo-holistic person involves considering the entirety of the universe in photograph
</h2>
<p className="mt-4 text-left z-50 text-base/6 text-neutral-200">
It can be a great way to express yourself capture moments, and make beautiful memories. you can create stunning images that can last a lifetime.
Expand Down
94 changes: 94 additions & 0 deletions app/components/ui/animated-tooltip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
"use client";
import Image from "next/image";
import React, { useState } from "react";
import {
motion,
useTransform,
AnimatePresence,
useMotionValue,
useSpring,
} from "framer-motion";

export const AnimatedTooltip = ({
items,
}: {
items: {
id: number;
name: string;
designation: string;
image: string;
}[];
}) => {
const [hoveredIndex, setHoveredIndex] = useState<number | null>(null);
const springConfig = { stiffness: 100, damping: 5 };
const x = useMotionValue(0); // going to set this value on mouse move
// rotate the tooltip
const rotate = useSpring(
useTransform(x, [-100, 100], [-45, 45]),
springConfig
);
// translate the tooltip
const translateX = useSpring(
useTransform(x, [-100, 100], [-50, 50]),
springConfig
);
const handleMouseMove = (event: any) => {
const halfWidth = event.target.offsetWidth / 2;
x.set(event.nativeEvent.offsetX - halfWidth); // set the x value, which is then used in transform and rotate
};

return (
<>
{items.map((item, idx) => (
<div
className="-mr-4 relative group"
key={item.name}
onMouseEnter={() => setHoveredIndex(item.id)}
onMouseLeave={() => setHoveredIndex(null)}
>
<AnimatePresence mode="popLayout">
{hoveredIndex === item.id && (
<motion.div
initial={{ opacity: 0, y: 20, scale: 0.6 }}
animate={{
opacity: 1,
y: 0,
scale: 1,
transition: {
type: "spring",
stiffness: 260,
damping: 10,
},
}}
exit={{ opacity: 0, y: 20, scale: 0.6 }}
style={{
translateX: translateX,
rotate: rotate,
whiteSpace: "nowrap",
}}
className="absolute -top-16 -left-1/2 translate-x-1/2 flex text-xs flex-col items-center justify-center rounded-md bg-black z-50 shadow-xl px-4 py-2"
>
<div className="absolute inset-x-10 z-30 w-[20%] -bottom-px bg-gradient-to-r from-transparent via-emerald-500 to-transparent h-px " />
<div className="absolute left-10 w-[40%] z-30 -bottom-px bg-gradient-to-r from-transparent via-sky-500 to-transparent h-px " />
<div className="font-bold text-white relative z-30 text-base">
{item.name}
</div>
<div className="text-white text-xs">{item.designation}</div>
</motion.div>
)}
</AnimatePresence>
{item.image ? (<Image
onMouseMove={handleMouseMove}
height={100}
width={100}
src={item.image}
alt={item.name}
className="object-cover !m-0 !p-0 object-top rounded-full h-14 w-14 border-2 group-hover:scale-105 group-hover:z-30 border-white relative transition duration-500"
/>) : (
<div className="h-44 w-44"></div>
)}
</div>
))}
</>
);
};
1 change: 1 addition & 0 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default function Home() {
<section className="text-five">

<AccordionDemo/>

</section>
</main>

Expand Down
15 changes: 12 additions & 3 deletions components/Accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { AnimatedTooltipPreview } from "@/app/components/AnimatedToolstips";
import { AnimatedTooltip, } from "@/app/components/ui/animated-tooltip";
import {
Accordion,
AccordionContent,
Expand All @@ -8,9 +10,11 @@ import {
export function AccordionDemo() {
return (
<>
<div className="text-five min-h-screen pt-20 text-left">
<div className="max-w-6xl p-2 m-auto">
<div className="text-center text-2xl">FAQ</div>
<div className="text-four min-h-screen flex flex-col justify-start items-start pt-20 bg-custom-radial-lg ">
<div className="max-w-6xl text-center md:text-xl p-2 m-auto">

<div className="text-center text-2xl font-semibold">Frequently Asked Questions</div>
<p className="text-center text-base py-2 mb-8">Feel free to ask me anything. I'm here to help!</p>
<Accordion type="single" collapsible className="w-full text-left">
<AccordionItem value="item-1">
<AccordionTrigger>What web solutions do you offer?</AccordionTrigger>
Expand Down Expand Up @@ -44,6 +48,11 @@ export function AccordionDemo() {
</AccordionContent>
</AccordionItem>
</Accordion>
<div className="py-12 my-2">
<h6 className="py-3 text-xl md:text-4xl">Didn&apos;t find an answer?</h6>
<p className="py-2 mb-16">My team is just an email away and ready to answer your questions</p>
<AnimatedTooltipPreview />
</div>
</div>
</div>
</>
Expand Down
6 changes: 3 additions & 3 deletions components/ui/accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ const AccordionTrigger = React.forwardRef<
React.ElementRef<typeof AccordionPrimitive.Trigger>,
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>
>(({ className, children, ...props }, ref) => (
<AccordionPrimitive.Header className="flex">
<AccordionPrimitive.Header className="flex ">
<AccordionPrimitive.Trigger
ref={ref}
className={cn(
"flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",
"flex flex-1 text-left items-start justify-between gap-3 py-4 font-medium transition-all [&[data-state=open]>svg]:rotate-180",
className
)}
{...props}
Expand All @@ -46,7 +46,7 @@ const AccordionContent = React.forwardRef<
>(({ className, children, ...props }, ref) => (
<AccordionPrimitive.Content
ref={ref}
className="overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
className="overflow-hidden text-sm md:text-base transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
{...props}
>
<div className={cn("pb-4 pt-0", className)}>{children}</div>
Expand Down

0 comments on commit 5b3d466

Please sign in to comment.