Skip to content

Commit

Permalink
Introducing Framer motion and hero5 with animated H1
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyjepsen committed Sep 16, 2024
1 parent 30c07cd commit 4708b0e
Show file tree
Hide file tree
Showing 9 changed files with 317 additions and 31 deletions.
61 changes: 31 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,34 @@ Here is a list of available blocks:

---

| Type | Version Light | Version Dark |
|-----------|--------------------------------------------|--------------------------------------------|
| **Headers** | ![Header1](https://github.com/tommyjepsen/twblocks/blob/main/public/header1.png?raw=true) | ![Header1](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-header1.png?raw=true) |
| **Heroes** | ![Hero1](https://github.com/tommyjepsen/twblocks/blob/main/public/hero1.png?raw=true) | ![Hero1](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-hero1.png?raw=true) |
| **Heroes** | ![Hero2](https://github.com/tommyjepsen/twblocks/blob/main/public/hero2.png?raw=true) | ![Hero2](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-hero2.png?raw=true) |
| **Heroes** | ![Hero3](https://github.com/tommyjepsen/twblocks/blob/main/public/hero3.png?raw=true) | ![Hero3](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-hero3.png?raw=true) |
| **Heroes** | ![Hero4](https://github.com/tommyjepsen/twblocks/blob/main/public/hero4.png?raw=true) | ![Hero4](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-hero4.png?raw=true) |
| **Cases** | ![Case1](https://github.com/tommyjepsen/twblocks/blob/main/public/case1.png?raw=true) | ![Case1](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-case1.png?raw=true) |
| **Cases** | ![Case2](https://github.com/tommyjepsen/twblocks/blob/main/public/case2.png?raw=true) | ![Case2](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-case2.png?raw=true) |
| **Features** | ![Feature1](https://github.com/tommyjepsen/twblocks/blob/main/public/feature1.png?raw=true) | ![Feature1](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-feature1.png?raw=true) |
| **Features** | ![Feature2](https://github.com/tommyjepsen/twblocks/blob/main/public/feature2.png?raw=true) | ![Feature2](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-feature2.png?raw=true) |
| **Features** | ![Feature3](https://github.com/tommyjepsen/twblocks/blob/main/public/feature3.png?raw=true) | ![Feature3](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-feature3.png?raw=true) |
| **Features** | ![Feature4](https://github.com/tommyjepsen/twblocks/blob/main/public/feature4.png?raw=true) | ![Feature4](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-feature4.png?raw=true) |
| **Features** | ![Feature5](https://github.com/tommyjepsen/twblocks/blob/main/public/feature5.png?raw=true) | ![Feature5](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-feature5.png?raw=true) |
| **Features** | ![Feature6](https://github.com/tommyjepsen/twblocks/blob/main/public/feature6.png?raw=true) | ![Feature6](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-feature6.png?raw=true) |
| **Features** | ![Feature7](https://github.com/tommyjepsen/twblocks/blob/main/public/feature7.png?raw=true) | ![Feature7](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-feature7.png?raw=true) |
| **Features** | ![Feature8](https://github.com/tommyjepsen/twblocks/blob/main/public/feature8.png?raw=true) | ![Feature8](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-feature8.png?raw=true) |
| **Features** | ![Feature9](https://github.com/tommyjepsen/twblocks/blob/main/public/feature9.png?raw=true) | ![Feature8](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-feature9.png?raw=true) |
| **CTAs** | ![CTA1](https://github.com/tommyjepsen/twblocks/blob/main/public/cta1.png?raw=true) | ![CTA1](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-cta1.png?raw=true) |
| **CTAs** | ![CTA2](https://github.com/tommyjepsen/twblocks/blob/main/public/cta2.png?raw=true) | ![CTA2](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-cta2.png?raw=true) |
| **Stats** | ![Stats1](https://github.com/tommyjepsen/twblocks/blob/main/public/stats1.png?raw=true) | ![Stats1](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-stats1.png?raw=true) |
| **Stats** | ![Stats2](https://github.com/tommyjepsen/twblocks/blob/main/public/stats2.png?raw=true) | ![Stats2](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-stats2.png?raw=true) |
| **Pricing** | ![Pricing1](https://github.com/tommyjepsen/twblocks/blob/main/public/pricing1.png?raw=true) | ![Pricing1](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-pricing1.png?raw=true) |
| **Pricing** | ![Pricing2](https://github.com/tommyjepsen/twblocks/blob/main/public/pricing2.png?raw=true) | ![Pricing2](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-pricing2.png?raw=true) |
| **FAQs** | ![FAQ1](https://github.com/tommyjepsen/twblocks/blob/main/public/faq1.png?raw=true) | ![FAQ1](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-faq1.png?raw=true) |
| **FAQs** | ![FAQ2](https://github.com/tommyjepsen/twblocks/blob/main/public/faq2.png?raw=true) | ![FAQ2](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-faq2.png?raw=true) |
| **Blogs** | ![Blog1](https://github.com/tommyjepsen/twblocks/blob/main/public/blog1.png?raw=true) | ![Blog1](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-blog1.png?raw=true) |
| **Blogs** | ![Blog2](https://github.com/tommyjepsen/twblocks/blob/main/public/blog2.png?raw=true) | ![Blog2](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-blog2.png?raw=true) |
| **Contacts** | ![Contact1](https://github.com/tommyjepsen/twblocks/blob/main/public/contact1.png?raw=true) | ![Contact1](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-contact1.png?raw=true) |
| **Footers** | ![Footer1](https://github.com/tommyjepsen/twblocks/blob/main/public/footer1.png?raw=true) | ![Footer1](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-footer1.png?raw=true) |
| Type | Version Light | Version Dark |
| ------------ | ------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| **Headers** | ![Header1](https://github.com/tommyjepsen/twblocks/blob/main/public/header1.png?raw=true) | ![Header1](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-header1.png?raw=true) |
| **Heroes** | ![Hero1](https://github.com/tommyjepsen/twblocks/blob/main/public/hero1.png?raw=true) | ![Hero1](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-hero1.png?raw=true) |
| **Heroes** | ![Hero2](https://github.com/tommyjepsen/twblocks/blob/main/public/hero2.png?raw=true) | ![Hero2](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-hero2.png?raw=true) |
| **Heroes** | ![Hero3](https://github.com/tommyjepsen/twblocks/blob/main/public/hero3.png?raw=true) | ![Hero3](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-hero3.png?raw=true) |
| **Heroes** | ![Hero4](https://github.com/tommyjepsen/twblocks/blob/main/public/hero4.png?raw=true) | ![Hero4](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-hero4.png?raw=true) |
| **Heroes** | ![Hero5](https://github.com/tommyjepsen/twblocks/blob/main/public/hero5.png?raw=true) | ![Hero4](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-hero5.png?raw=true) |
| **Cases** | ![Case1](https://github.com/tommyjepsen/twblocks/blob/main/public/case1.png?raw=true) | ![Case1](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-case1.png?raw=true) |
| **Cases** | ![Case2](https://github.com/tommyjepsen/twblocks/blob/main/public/case2.png?raw=true) | ![Case2](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-case2.png?raw=true) |
| **Features** | ![Feature1](https://github.com/tommyjepsen/twblocks/blob/main/public/feature1.png?raw=true) | ![Feature1](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-feature1.png?raw=true) |
| **Features** | ![Feature2](https://github.com/tommyjepsen/twblocks/blob/main/public/feature2.png?raw=true) | ![Feature2](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-feature2.png?raw=true) |
| **Features** | ![Feature3](https://github.com/tommyjepsen/twblocks/blob/main/public/feature3.png?raw=true) | ![Feature3](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-feature3.png?raw=true) |
| **Features** | ![Feature4](https://github.com/tommyjepsen/twblocks/blob/main/public/feature4.png?raw=true) | ![Feature4](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-feature4.png?raw=true) |
| **Features** | ![Feature5](https://github.com/tommyjepsen/twblocks/blob/main/public/feature5.png?raw=true) | ![Feature5](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-feature5.png?raw=true) |
| **Features** | ![Feature6](https://github.com/tommyjepsen/twblocks/blob/main/public/feature6.png?raw=true) | ![Feature6](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-feature6.png?raw=true) |
| **Features** | ![Feature7](https://github.com/tommyjepsen/twblocks/blob/main/public/feature7.png?raw=true) | ![Feature7](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-feature7.png?raw=true) |
| **Features** | ![Feature8](https://github.com/tommyjepsen/twblocks/blob/main/public/feature8.png?raw=true) | ![Feature8](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-feature8.png?raw=true) |
| **Features** | ![Feature9](https://github.com/tommyjepsen/twblocks/blob/main/public/feature9.png?raw=true) | ![Feature8](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-feature9.png?raw=true) |
| **CTAs** | ![CTA1](https://github.com/tommyjepsen/twblocks/blob/main/public/cta1.png?raw=true) | ![CTA1](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-cta1.png?raw=true) |
| **CTAs** | ![CTA2](https://github.com/tommyjepsen/twblocks/blob/main/public/cta2.png?raw=true) | ![CTA2](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-cta2.png?raw=true) |
| **Stats** | ![Stats1](https://github.com/tommyjepsen/twblocks/blob/main/public/stats1.png?raw=true) | ![Stats1](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-stats1.png?raw=true) |
| **Stats** | ![Stats2](https://github.com/tommyjepsen/twblocks/blob/main/public/stats2.png?raw=true) | ![Stats2](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-stats2.png?raw=true) |
| **Pricing** | ![Pricing1](https://github.com/tommyjepsen/twblocks/blob/main/public/pricing1.png?raw=true) | ![Pricing1](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-pricing1.png?raw=true) |
| **Pricing** | ![Pricing2](https://github.com/tommyjepsen/twblocks/blob/main/public/pricing2.png?raw=true) | ![Pricing2](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-pricing2.png?raw=true) |
| **FAQs** | ![FAQ1](https://github.com/tommyjepsen/twblocks/blob/main/public/faq1.png?raw=true) | ![FAQ1](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-faq1.png?raw=true) |
| **FAQs** | ![FAQ2](https://github.com/tommyjepsen/twblocks/blob/main/public/faq2.png?raw=true) | ![FAQ2](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-faq2.png?raw=true) |
| **Blogs** | ![Blog1](https://github.com/tommyjepsen/twblocks/blob/main/public/blog1.png?raw=true) | ![Blog1](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-blog1.png?raw=true) |
| **Blogs** | ![Blog2](https://github.com/tommyjepsen/twblocks/blob/main/public/blog2.png?raw=true) | ![Blog2](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-blog2.png?raw=true) |
| **Contacts** | ![Contact1](https://github.com/tommyjepsen/twblocks/blob/main/public/contact1.png?raw=true) | ![Contact1](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-contact1.png?raw=true) |
| **Footers** | ![Footer1](https://github.com/tommyjepsen/twblocks/blob/main/public/footer1.png?raw=true) | ![Footer1](https://github.com/tommyjepsen/twblocks/blob/main/public/darkmode-footer1.png?raw=true) |
161 changes: 161 additions & 0 deletions app/blocks/heroes/hero5/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
"use client";

import { Hero4 } from "@/blocks/hero/hero4";
import { Hero5 } from "@/blocks/hero/hero5";
import { CopyCodeButton } from "@/components/copy-code-button";
import {
Breadcrumb,
BreadcrumbItem,
BreadcrumbLink,
BreadcrumbList,
BreadcrumbPage,
BreadcrumbSeparator,
} from "@/components/ui/breadcrumb";
import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";
import { Terminal } from "lucide-react";
import Link from "next/link";
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
import { vscDarkPlus } from "react-syntax-highlighter/dist/esm/styles/prism";

export default function Block() {
const code = `import { useEffect, useMemo, useState } from "react";
import { motion } from "framer-motion";
import { MoveRight, PhoneCall } from "lucide-react";
import { Button } from "@/components/ui/button";
export const Hero5 = () => {
const [titleNumber, setTitleNumber] = useState(0);
const titles = useMemo(
() => ["amazing", "new", "wonderful", "beautiful", "smart"],
[]
);
useEffect(() => {
const timeoutId = setTimeout(() => {
if (titleNumber === titles.length - 1) {
setTitleNumber(0);
} else {
setTitleNumber(titleNumber + 1);
}
}, 2000);
return () => clearTimeout(timeoutId);
}, [titleNumber, titles]);
return (
<div className="w-full">
<div className="container mx-auto">
<div className="flex gap-8 py-20 lg:py-40 items-center justify-center flex-col">
<div>
<Button variant="secondary" size="sm" className="gap-4">
Read our launch article <MoveRight className="w-4 h-4" />
</Button>
</div>
<div className="flex gap-4 flex-col">
<h1 className="text-5xl md:text-7xl max-w-2xl tracking-tighter text-center font-regular">
<span className="text-spektr-cyan-50">This is something</span>
<span className="relative flex w-full justify-center overflow-hidden text-center md:pb-4 md:pt-1">
&nbsp;
{titles.map((title, index) => (
<motion.span
key={index}
className="absolute font-semibold"
initial={{ opacity: 0, y: "-100" }}
transition={{ type: "spring", stiffness: 50 }}
animate={
titleNumber === index
? {
y: 0,
opacity: 1,
}
: {
y: titleNumber > index ? -150 : 150,
opacity: 0,
}
}
>
{title}
</motion.span>
))}
</span>
</h1>
<p className="text-lg md:text-xl leading-relaxed tracking-tight text-muted-foreground max-w-2xl text-center">
Managing a small business today is already tough. Avoid further
complications by ditching outdated, tedious trade methods. Our
goal is to streamline SMB trade, making it easier and faster than
ever.
</p>
</div>
<div className="flex flex-row gap-3">
<Button size="lg" className="gap-4" variant="outline">
Jump on a call <PhoneCall className="w-4 h-4" />
</Button>
<Button size="lg" className="gap-4">
Sign up here <MoveRight className="w-4 h-4" />
</Button>
</div>
</div>
</div>
</div>
);
};
`;

return (
<div className="min-h-screen w-full flex flex-col">
<div className="bg-secondary mt-20 w-full">
<div className="container items-center text-secondary-foreground text-sm text-center py-4 flex flex-row justify-between">
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink asChild>
<Link href="/">Blocks</Link>
</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbLink asChild>
<Link href="/#heroes">Heroes</Link>
</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbPage>Hero5</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
</div>
</div>
<div className="flex bg-background justify-center items-start flex-1">
<div className="w-full max-w-8xl relative">
<div className="absolute top-8 left-1/2 transform -translate-x-1/2 -translate-y-1/2 flex flex-row gap-2">
<CopyCodeButton code={code} />
<Dialog>
<DialogTrigger asChild>
<Button variant="outline" className="gap-2">
<Terminal className="w-4 h-4" />
Show code
</Button>
</DialogTrigger>
<DialogContent className="max-w-[800px]">
<SyntaxHighlighter
language="javascript"
className="rounded-md max-h-[70vh]"
style={vscDarkPlus}
>
{code}
</SyntaxHighlighter>
</DialogContent>
</Dialog>
</div>
<div className="rounded-md bg-background">
<Hero5 />
</div>
</div>
</div>
</div>
);
}
2 changes: 1 addition & 1 deletion blocks/feature/feature9.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const Feature9 = () => {
} else if ("clientX" in e) {
x = e.clientX - rect.left;
}

const percentage = (x / rect.width) * 100;
setInset(percentage);
};
Expand Down
Loading

0 comments on commit 4708b0e

Please sign in to comment.