Skip to content

Commit

Permalink
torch cards implementaion, some modification, code encapsulation, use…
Browse files Browse the repository at this point in the history
… client
  • Loading branch information
me-imfhd committed Nov 11, 2023
1 parent 553a131 commit 7486afe
Show file tree
Hide file tree
Showing 5 changed files with 227 additions and 77 deletions.
39 changes: 39 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"clsx": "^2.0.0",
"eslint": "8.49.0",
"eslint-config-next": "13.4.19",
"framer-motion": "^10.12.22",
"lucide-react": "^0.277.0",
"next": "13.5.4",
"next-themes": "^0.2.1",
Expand Down
169 changes: 169 additions & 0 deletions src/components/FeaturesCards.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
"use client";
import Image, { StaticImageData } from "next/image";

import Link from "next/link";
import {
MotionStyle,
MotionValue,
motion,
useMotionTemplate,
useMotionValue,
} from "framer-motion";
import React, {
CSSProperties,
PropsWithChildren,
useState,
MouseEvent,
useEffect,
} from "react";
import discussion from "@/public/images/discussions.png";
import pullRequests from "@/public/images/pull-requests.png";
import laptop from "@/public/images/FlitchPayLaptop.webp";
import mobile from "@/public/images/FlitchPayMobile.webp";
import { useMediaQuery } from "@mantine/hooks";
import clsx from "clsx";

type WrapperStyle = MotionStyle & {
"--x": MotionValue<string>;
"--y": MotionValue<string>;
};
interface CardProps {
bgClass?: string;
cardWidth: string;
}

function FeatureCard({
bgClass,
cardWidth,
children,
}: CardProps & {
children: React.ReactNode;
}) {
const [mounted, setMounted] = useState(false);
const mouseX = useMotionValue(0);
const mouseY = useMotionValue(0);
const isMobile = useMediaQuery("768px");

function handleMouseMove({ currentTarget, clientX, clientY }: MouseEvent) {
if (isMobile) return;
const { left, top } = currentTarget.getBoundingClientRect();
mouseX.set(clientX - left);
mouseY.set(clientY - top);
}

useEffect(() => {
setMounted(true);
}, []);

return (
<motion.div
className={clsx(
cardWidth,
"animated-feature-cards relative drop-shadow-[0_0_15px_rgba(49,49,49,0.2)] dark:drop-shadow-[0_0_15px_rgba(49,49,49,0.2)]",
)}
onMouseMove={handleMouseMove}
style={
{
"--x": useMotionTemplate`${mouseX}px`,
"--y": useMotionTemplate`${mouseY}px`,
} as WrapperStyle
}
>
<div
className={clsx(
"group relative w-full overflow-hidden rounded-3xl border bg-gradient-to-b from-neutral-50/90 to-neutral-100/90 transition duration-300 dark:from-neutral-950/90 dark:to-neutral-800/90",
"md:hover:border-transparent",
bgClass,
)}
>
<div className="w-full ">{mounted ? children : null}</div>
</div>
</motion.div>
);
}

export function Card1() {
return (
<FeatureCard cardWidth="md:w-1/2" bgClass="md:bg-gradient-to-br">
<div className="flex flex-col gap-12">
<div className="ml-10 mt-10 flex w-5/6 flex-col gap-8 sm:w-4/6 md:w-4/5 xl:w-4/6">
<h2 className="text-xl font-bold tracking-tight md:text-xl">
Sophisticated Checkoutsl{" "}
<span className="font-normal text-zinc-400">
create space to ask questions and have open-ended conversations.
</span>
</h2>
<Link href={""}>
<div className="flex text-base font-bold transition-colors hover:text-muted-foreground">
Enable GitHub Discussion {"->"}
{/* Right Arrow */}
<span className="sr-only">Enable GitHub Discussion</span>
</div>
</Link>
</div>
<div>
<Image src={discussion} alt="App" className="" />
</div>
</div>
</FeatureCard>
);
}

export function Card2() {
return (
<FeatureCard cardWidth="md:w-1/2" bgClass="md:bg-gradient-to-bl">
<div className="flex flex-col gap-6">
<div className="ml-10 mt-10 flex w-5/6 flex-col gap-8 sm:w-4/6 md:w-4/5 xl:w-4/6">
<h2 className="text-xl font-bold tracking-tight md:text-xl">
On Make products & Sell{" "}
<span className="font-normal text-zinc-400">
allow communication and collaboration about code changes.
</span>
</h2>
<Link href={""}>
<div className="flex text-base font-bold transition-colors hover:text-muted-foreground">
Check out pull requests {"->"}
{/* Right Arrow */}
<span className="sr-only">Check out pull requests</span>
</div>
</Link>
</div>
<div>
<Image src={pullRequests} alt="App" className="" />
</div>
</div>
</FeatureCard>
);
}
export function Card3() {
return (
<FeatureCard cardWidth="md:w-full" bgClass="md:bg-gradient-to-b ">
<div className="flex w-full flex-wrap md:flex-nowrap">
<div className="ml-10 mt-10 flex flex-col gap-8 md:w-5/12">
<h2 className="text-xl font-bold tracking-tight md:text-xl">
On premise Messaging & Real-time Payments{" "}
<span className="font-normal text-zinc-400">
lets you support your favorite open source maintainers and
projects.
</span>
</h2>
<Link href={""}>
<div className="flex text-base font-bold transition-colors hover:text-muted-foreground">
Invest with GitHub Sponsors {"->"}
{/* Right Arrow */}
<span className="sr-only">Invest with GitHub Sponsors</span>
</div>
</Link>
</div>
<div className="mt-8 flex overflow-hidden md:mt-0">
<div className="-me-20 md:-me-52">
<Image src={laptop} alt="laptop"></Image>
</div>
<div className="md:-me-14 ">
<Image src={mobile} alt="mobile"></Image>
</div>
</div>
</div>
</FeatureCard>
);
}
81 changes: 4 additions & 77 deletions src/components/WhatsFlitchPay.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
"use client";
import { FeaturesStar } from "@/public/svgs/FeaturesStar";
import { InView, useInView } from "react-intersection-observer";
import Link from "next/link";
import discussion from "@/public/images/discussions.png";
import pullRequests from "@/public/images/pull-requests.png";
import laptop from "@/public/images/FlitchPayLaptop.webp";
import mobile from "@/public/images/FlitchPayMobile.webp";
import React, { CSSProperties } from "react";
import Image from "next/image";
import { Card1, Card2, Card3 } from "./FeaturesCards";
import clsx from "clsx";
import { useActivePage } from "../app/_context";

Expand All @@ -25,79 +19,12 @@ export function WhatsFlitchPay() {
<HeadComponent />
<div className="mt-14 flex flex-wrap gap-4 md:flex-nowrap md:text-lg">
{/* card1 */}
<div className="flex flex-col justify-between gap-8 rounded-md bg-secondary font-semibold md:w-1/2 ">
<div className="flex flex-col justify-between gap-6 px-6 pt-6 md:px-14 md:pt-14">
<div>
Sophisticated Checkouts
<span className="font-normal text-muted-foreground">
{" "}
create space to ask questions and have open-ended
conversations.
</span>
</div>
<Link href={""}>
<div className="flex text-base transition-colors hover:text-muted-foreground">
Enable GitHub Discussion {"->"}
{/* Right Arrow */}
<span className="sr-only">Enable Github Discussions</span>
</div>
</Link>
</div>
<div>
<Image src={discussion} alt="App" className="" />
</div>
</div>
<Card1 />
{/* card2 */}
<div className="flex flex-col gap-12 rounded-md bg-secondary font-semibold md:w-1/2 md:gap-16 ">
<div className="flex flex-col justify-between gap-8 px-6 pt-6 md:px-14 md:pt-14">
<div>
On Make products & Sell
<span className="font-normal text-muted-foreground">
{" "}
allow communication and collaboration about code changes.
</span>
</div>
<Link href={""}>
<div className="flex text-base transition-colors hover:text-muted-foreground">
Check out pull requests {"->"}
{/* Right Arrow */}
<span className="sr-only">Check out pull requests</span>
</div>
</Link>
</div>
<div>
<Image src={pullRequests} alt="App" className="" />
</div>
</div>
<Card2 />
</div>
{/* card3 */}
<div className="flex w-full gap-12 rounded-md bg-secondary font-semibold md:gap-16 md:text-lg ">
<div className="flex w-full flex-wrap md:flex-nowrap">
<div className="pl-6 pt-6 md:w-5/12 md:pl-14 md:pt-14">
On premise Messaging & Real-time Payments
<span className="font-normal text-muted-foreground">
{" "}
lets you support your favorite open source maintainers and
projects.
</span>
<Link href={""}>
<div className="mt-6 flex text-base transition-colors hover:text-muted-foreground">
Invest with GitHub Sponsors {"->"}
{/* Right Arrow */}
<span className="sr-only">Invest with GitHub Sponsors</span>
</div>
</Link>
</div>
<div className="mt-8 flex overflow-hidden md:mt-0">
<div className="-me-20 md:-me-52">
<Image src={laptop} alt="laptop"></Image>
</div>
<div className="md:-me-14 ">
<Image src={mobile} alt="mobile"></Image>
</div>
</div>
</div>
</div>
<Card3 />
</div>
</section>
<div className="lampcontainer -z-10 flex rotate-180 opacity-50 dark:opacity-100">
Expand Down
14 changes: 14 additions & 0 deletions src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,20 @@
--gradient-color-4: #000000;
z-index: 0;
}
.animated-feature-cards::before {
@apply pointer-events-none absolute select-none rounded-3xl opacity-0 transition-opacity duration-300 hover:opacity-100;
background: radial-gradient(
1000px circle at var(--x) var(--y),
#3aecf8 0,
#5295dc 25%,
rgba(255, 255, 255, 0) 50%,
transparent 80%
);
z-index: -1;
content: '';
inset: -1px;
}


.lampcontainer {
position: relative;
Expand Down

0 comments on commit 7486afe

Please sign in to comment.