Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

fix: update testimonials (#565)

Dillion Verma1a1ada86140e
diff --git a/app/(marketing)/page.tsx b/app/(marketing)/page.tsx
index b36a9ff9..5e94be95 100644
--- a/app/(marketing)/page.tsx
+++ b/app/(marketing)/page.tsx
@@ -2,6 +2,7 @@ import ComponentDemos from "@/components/sections/component-demos";
import Hero from "@/components/sections/hero";
import Showcase from "@/components/sections/showcase";
import Testimonials from "@/components/sections/testimonials";
+import VideoTestimonials from "@/components/sections/video-testimonials";
export default function Home() {
return (
@@ -10,6 +11,7 @@ export default function Home() {
<Showcase />
<ComponentDemos />
<Testimonials />
+ <VideoTestimonials />
</>
);
}
diff --git a/components/sections/expandable-masonary-section.tsx b/components/sections/expandable-masonary-section.tsx
new file mode 100644
index 00000000..5d652feb
--- /dev/null
+++ b/components/sections/expandable-masonary-section.tsx
@@ -0,0 +1,58 @@
+"use client";
+
+import { Button } from "@/components/ui/button";
+import { Masonry } from "masonic";
+import { AnimatePresence, motion } from "motion/react";
+import { useRef, useState } from "react";
+
+interface ExpandableMasonarySectionProps {
+ children: React.ReactNode[];
+}
+
+export function ExpandableMasonarySection({
+ children,
+}: ExpandableMasonarySectionProps) {
+ const [expanded, setExpanded] = useState(false);
+ const sectionRef = useRef<HTMLDivElement>(null);
+
+ const handleToggle = () => {
+ setExpanded(!expanded);
+ };
+
+ return (
+ <>
+ <motion.div
+ ref={sectionRef}
+ className="relative overflow-hidden"
+ initial={{ maxHeight: "800px" }}
+ animate={{ maxHeight: expanded ? "4000px" : "800px" }}
+ transition={{ duration: 1.6, ease: [0.25, 0.1, 0.25, 1] }}
+ exit={{ maxHeight: "800px" }}
+ >
+ <Masonry
+ items={children}
+ columnGutter={16}
+ columnWidth={300}
+ render={({ data }) => data}
+ />
+ <AnimatePresence>
+ {!expanded && (
+ <motion.div
+ initial={{ opacity: 0 }}
+ animate={{ opacity: 1 }}
+ exit={{ opacity: 0 }}
+ className="pointer-events-none absolute inset-x-0 bottom-0 h-32 bg-gradient-to-t from-background"
+ />
+ )}
+ </AnimatePresence>
+ </motion.div>
+ <Button
+ onClick={handleToggle}
+ className="mx-auto mt-4 block"
+ variant="outline"
+ >
+ {expanded ? "Show Less" : "Show More"}
+ </Button>
+ </>
+ );
+}
diff --git a/components/sections/testimonials.tsx b/components/sections/testimonials.tsx
index 618d8c9d..1073ac68 100644
--- a/components/sections/testimonials.tsx
+++ b/components/sections/testimonials.tsx
@@ -1,63 +1,85 @@
-import { Marquee } from "@/registry/magicui/marquee";
+import { ExpandableMasonarySection } from "@/components/sections/expandable-masonary-section";
import { TweetCard } from "@/registry/magicui/tweet-card";
+import { ArrowUpRight } from "lucide-react";
+import Link from "next/link";
-const tweets = [
+const allTweets = [
+ "https://x.com/steventey/status/1722659583464968612",
+ "https://x.com/rauchg/status/1867249854613008822",
+ "https://x.com/mckaywrigley/status/1831098800351719924",
"https://x.com/chronark_/status/1754781648262967323",
- "https://x.com/pkp_io/status/1684561895481802753",
- "https://x.com/devcagatay/status/1684573935466328065",
- "https://x.com/KanishkKhurana_/status/1684613797984800768",
+ "https://x.com/aidenybai/status/1793403298843869672",
+ "https://x.com/phuctm97/status/1793443202592288914",
+ "https://x.com/RayFernando1337/status/1821208623638573211",
+ "https://x.com/SullyOmarr/status/1668506160620769280",
+ "https://x.com/vahaah/status/1878800566144708650",
+ "https://x.com/DmytroKrasun/status/1793642777873633543",
+ "https://x.com/MarcKlingen/status/1793422145399455746",
+ "https://x.com/jordanphughes/status/1794287517430415390",
+ "https://x.com/jordienr/status/1681389309037772820",
+ "https://x.com/mckaywrigley/status/1831185841051590857",
+ "https://x.com/karmpat72748262/status/1889758543840002457",
"https://x.com/WhopIO/status/1722690049374830639",
- "https://x.com/steventey/status/1722659583464968612",
- "https://x.com/AwesomAmri/status/1668432554842619906",
+ "https://x.com/hailsxr/status/1853552782076477578",
"https://x.com/taishik_/status/1668510585926066176",
- "https://x.com/SullyOmarr/status/1668506160620769280",
"https://x.com/sup_nim/status/1668525144409624578",
+ "https://x.com/saporito_eth/status/1801445101786304799",
"https://x.com/JakeDuth/status/1668442365625790465",
"https://x.com/0xRaduan/status/1668557577985179648",
"https://x.com/yazinsai/status/1668617800934641672",
-
"https://x.com/wes_walke/status/1668612106696941570",
+ "https://x.com/beneverman/status/1681477151042797568",
"https://x.com/DevAlien/status/1668618017528479745",
"https://x.com/fredmaiaarantes/status/1684676668445622272",
"https://x.com/DesignSumu/status/1668559314272022528",
"https://x.com/commandodev/status/1668640878225764354",
"https://x.com/SandBoxSo/status/1668570645741948930",
"https://x.com/sxndrao/status/1668634137547399168",
- "https://x.com/jordienr/status/1681389309037772820",
- "https://x.com/beneverman/status/1681477151042797568",
+ "https://x.com/sameerposwal03/status/1862084069833797788",
+ "https://x.com/eersnington/status/1854657826011967597",
+ "https://x.com/fardeen14693425/status/1857782464673923476",
+ "https://x.com/Md_Sadiq_Md/status/1858221399959359566",
+ "https://x.com/sphinxsaas/status/1879233539109216723",
+ "https://x.com/AwesomAmri/status/1668432554842619906",
+ "https://x.com/avansteenweghen/status/1783271768138146086",
+ "https://x.com/lizhagearty/status/1835827024981541193",
+ "https://x.com/namyakhann/status/1793412434121949344",
+ // "https://x.com/chronark_/status/1779077288329433146",
+ // "https://x.com/_raoufai/status/1850950163051024470",
+ // "https://x.com/taishik_/status/1875316979831337058",
+ // "https://x.com/rauchg/status/1803626308720796147",
+ // "https://x.com/dillionverma/status/1879324180598165702",
+ // "https://x.com/Star_Knight12/status/1861814034363981989",
+ // "https://x.com/mohamedzamakhan/status/1859810055924895904",
+ // "https://x.com/DutchEngIishman/status/1795888864202043645",
].map((t) => t.split("/").slice(-1)[0]);
-export default async function Testimonials() {
- const firstRow = tweets.slice(0, tweets.length / 2);
- const secondRow = tweets.slice(tweets.length / 2);
-
+export default function Testimonials() {
return (
- <section id="testimonials" className="container py-14">
- <h2 className="mb-4 text-center text-5xl font-bold leading-[1.2] tracking-tighter text-foreground">
- What People Are Saying
+ <section id="testimonials" className="container max-w-screen-xl py-14">
+ <h2 className="mb-8 text-center text-5xl font-bold leading-[1.2] tracking-tighter text-foreground">
+ What People Are Saying on Twitter
</h2>
- <h3 className="mx-auto mb-8 max-w-lg text-balance text-center text-lg font-medium tracking-tight text-foreground/80">
- Don&apos;t just take our word for it. Here&apos;s what{" "}
- <strong>real people</strong> are saying about Magic UI on Twitter.
- </h3>
- <div className="relative flex flex-col">
- <Marquee className="max-w-screen [--duration:120s]" pauseOnHover>
- {firstRow.map((id, idx) => (
- <TweetCard id={id} className="max-h-32 w-72 min-w-72" key={idx} />
- ))}
- </Marquee>
- <Marquee
- className="max-w-screen [--duration:120s]"
- reverse
- pauseOnHover
- >
- {secondRow.map((id, idx) => (
- <TweetCard id={id} className="max-h-32 w-72 min-w-72" key={idx} />
- ))}
- </Marquee>
- <div className="pointer-events-none absolute inset-y-0 left-0 h-full w-1/3 bg-gradient-to-r from-background"></div>
- <div className="pointer-events-none absolute inset-y-0 right-0 h-full w-1/3 bg-gradient-to-l from-background"></div>
- </div>
+ <ExpandableMasonarySection>
+ {allTweets.map((id) => (
+ <Link
+ href={`https://x.com/i/status/${id}`}
+ key={id}
+ className="group relative"
+ >
+ <TweetCard
+ id={id}
+ className="break-inside-avoid overflow-hidden rounded-lg bg-secondary shadow-sm"
+ />
+ <span className="absolute inset-0 flex items-center justify-center rounded-lg bg-black/20 p-4 text-lg font-bold text-white opacity-0 transition-opacity duration-300 ease-in-out group-hover:opacity-100">
+ <span className="flex translate-y-[14px] items-center gap-2 transition-transform duration-300 ease-in-out group-hover:translate-y-0">
+ View Tweet
+ <ArrowUpRight className="h-6 w-6" />
+ </span>
+ </span>
+ </Link>
+ ))}
+ </ExpandableMasonarySection>
</section>
);
}
diff --git a/components/sections/video-testimonials.tsx b/components/sections/video-testimonials.tsx
new file mode 100644
index 00000000..1ebfbd89
--- /dev/null
+++ b/components/sections/video-testimonials.tsx
@@ -0,0 +1,46 @@
+"use client";
+
+import { motion } from "motion/react";
+
+export default function VideoTestimonials() {
+ const videoUrls = [
+ "https://www.youtube.com/embed/UGm8djxwC5s?t=2s",
+ "https://www.youtube.com/embed/qh3NGpYRG3I?t=97s",
+ "https://www.youtube.com/embed/AkN6xJcnVYs",
+ "https://www.youtube.com/embed/hlSu_ldrbQw?t=1131s",
+ "https://www.youtube.com/embed/ZYvvTehpA5I",
+ ];
+
+ return (
+ <section
+ id="video-testimonials"
+ className="container max-w-screen-xl py-14"
+ >
+ <h2 className="mb-8 text-center text-5xl font-bold leading-[1.2] tracking-tighter text-foreground">
+ Featured on YouTube
+ </h2>
+ <div className="grid auto-rows-[420px] grid-cols-1 gap-4 md:auto-rows-[400px] md:grid-cols-3 md:grid-rows-3">
+ {videoUrls.map((url, index) => (
+ <motion.div
+ key={index}
+ className={`relative h-full overflow-hidden rounded-xl border bg-secondary shadow-sm ${
+ index === 0 ? "h-[600px] md:col-span-2 md:row-span-2" : ""
+ } ${index === 3 ? "md:col-span-2" : ""}`}
+ initial={{ opacity: 0, y: 20 }}
+ animate={{ opacity: 1, y: 0 }}
+ transition={{ duration: 0.5, delay: index * 0.2 }}
+ >
+ <iframe
+ src={url}
+ title={`YouTube video player ${index + 1}`}
+ frameBorder="0"
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
+ allowFullScreen
+ className="h-full w-full object-cover"
+ ></iframe>
+ </motion.div>
+ ))}
+ </div>
+ </section>
+ );
+}
diff --git a/content/pages/home.mdx b/content/pages/home.mdx
index 625c1881..7f3885da 100644
--- a/content/pages/home.mdx
+++ b/content/pages/home.mdx
@@ -3,20 +3,20 @@ title: Components
description: A collection of components that are used to build the landing page of a website.
---
+<ComponentPreview name="bento-demo" preview />
<ComponentPreview name="marquee-demo" preview />
<ComponentPreview name="marquee-demo-vertical" preview />
-<ComponentPreview name="bento-demo" preview />
<ComponentPreview name="animated-list-demo" preview />
<ComponentPreview name="animated-beam-demo" preview />
<ComponentPreview name="animated-beam-multiple-inputs" preview />
<ComponentPreview name="animated-beam-multiple-outputs" preview />
-<ComponentPreview name="magic-card-demo" preview />
<ComponentPreview name="border-beam-demo" preview />
<ComponentPreview name="border-beam-demo-2" preview />
<ComponentPreview name="border-beam-demo-3" preview />
<ComponentPreview name="border-beam-demo-4" preview />
<ComponentPreview name="shine-border-demo" preview />
<ComponentPreview name="dock-demo" preview />
+<ComponentPreview name="magic-card-demo" preview />
<ComponentPreview name="particles-demo" preview />
<ComponentPreview name="blur-fade-demo" preview />
<ComponentPreview name="blur-fade-text-demo" preview />
diff --git a/package.json b/package.json
index eaa6188f..9989a028 100644
--- a/package.json
+++ b/package.json
@@ -61,6 +61,7 @@
"jotai": "^2.11.3",
"lodash.template": "^4.5.0",
"lucide-react": "^0.401.0",
+ "masonic": "^4.0.1",
"motion": "^11.15.0",
"next": "^14",
"next-themes": "^0.4.4",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 51c1d359..8656541e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -119,6 +119,9 @@ importers:
lucide-react:
specifier: ^0.401.0
version: 0.401.0([email protected])
+ masonic:
+ specifier: ^4.0.1
+ version: 4.0.1([email protected])
motion:
specifier: ^11.15.0
@@ -920,6 +923,18 @@ packages:
resolution: {integrity: sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
+ '@essentials/[email protected]':
+ resolution: {integrity: sha512-HMkuIkKNe0EWSUpZhlaq9+5Yp47YhrMhxLMnXTRnEyE5N4xKLspAvMGjUFdi794VnEF1EcOZFS8rdROeujrgag==}
+
+ '@essentials/[email protected]':
+ resolution: {integrity: sha512-C2H7zHVcsoipDv4VKY5uUcv5ilsK+uEgEj+WeOdN5oz/Qj1/OZIzCdle90gDzj0xnGQrmZ9qDujwD7AkBb5k9A==}
+
+ '@essentials/[email protected]':
+ resolution: {integrity: sha512-AWJvpprE2o7ATMb7HBYMVUVmPJBCt2wZp2rY7d+rAcNSMvzLbDepy9KFeqqrPZh+s9aIpbw1LgmuAW7kuRFgrQ==}
+
+ '@essentials/[email protected]':
+ resolution: {integrity: sha512-lKZPhKScNFnR1MBnk4+sxshk46fpvdN+Uh1LlKWFO5g1ocuz4EcknNIL7tm/rsCAs/+xMWiBTwbDUvm+pDNlXw==}
+
'@fal-works/[email protected]':
resolution: {integrity: sha512-cEee/Z+I12mZcFJshKcCqC8tuX5hG3s+d+9nZ3LabqKF1vKdF41B92pJVCBggjAGORAeOzyyDDKrZwIkLffeOQ==}
@@ -2192,6 +2207,41 @@ packages:
'@radix-ui/[email protected]':
resolution: {integrity: sha512-A9+lCBZoaMJlVKcRBz2YByCG+Cp2t6nAnMnNba+XiWxnj6r4JUFqfsgwocMBZU9LPtdxC6wB56ySYpc7LQIoJg==}
+ '@react-hook/[email protected]':
+ resolution: {integrity: sha512-ir/kPrSfAzY12Gre0sOHkZ2rkEmM4fS5M5zFxCi4BnCeXh2nvx9Ujd+U4IGpKCuPA+EQD0pg1eK2NGLvfWejag==}
+ peerDependencies:
+ react: '>=16.8'
+
+ '@react-hook/[email protected]':
+ resolution: {integrity: sha512-JUL5IluaOdn5w5Afpe/puPa1rj8X6udMlQ9dt4hvMuKmTrBS1Ya6sb4sVgvfe2eU4yDuOfAhik8xhbcCekbg9Q==}
+ peerDependencies:
+ react: '>=16.8'
+
+ '@react-hook/[email protected]':
+ resolution: {integrity: sha512-dy6duzl+JnAZcDbNTfmaP3xHiKtbXYOaz3G51MGVljh548Y8MWzTr+PHLOfvpypEVW9zwvl+VyKjbWKEVbV1Rg==}
+ peerDependencies:
+ react: '>=16.8'
+
+ '@react-hook/[email protected]':
+ resolution: {integrity: sha512-IwEphTD75liO8g+6taS+4oqz+nnroocNfWVHWz7j+N+ZO2vYrc6PV1q7GQhuahL0IOR7JccFTsFKQ/mb6iZWAg==}
+ peerDependencies:
+ react: '>=16.8'
+
+ '@react-hook/[email protected]':
+ resolution: {integrity: sha512-LJ5eg+yMV8lXtqK3lR+OtOZ2WH/EfWvuiEEu0M3bhR7dZRfTyEJKxH1oK9uyBxiXPtWXiQggWbZirMCXam51tg==}
+ peerDependencies:
+ react: '>=16.8'
+
+ '@react-hook/[email protected]':
+ resolution: {integrity: sha512-LdYnCL22pFI+LTs85Fi2OQHSKWkzIuHFgv8lA+wwuaPxLOEhWR5bzJ21iygUH9X4meeLVRZKEbfpYi3OWWD4GQ==}
+ peerDependencies:
+ react: '>=16.8'
+
+ '@react-hook/[email protected]':
+ resolution: {integrity: sha512-yWnVS5LKnOUIrEsI44oz3bIIUYqflamPL27n+k/PC//PsX/YeWBky09oPeAoc9As6jSH16Wgo8plI+ECZaHk3g==}
+ peerDependencies:
+ react: '>=16.8'
+
resolution: {integrity: sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g==}
@@ -4161,6 +4211,11 @@ packages:
resolution: {integrity: sha512-Z1NL3Tb1M9wH4XESsCDEksWoKTdlUafKc4pt0GRwjUyXaCFZ+dc3g2erqB6zm3szA2IUSi7VnPI+o/9jnxh9hw==}
+ resolution: {integrity: sha512-gOj1B61NtrELoGigCy+E9SZpWSRGmAONMXrzYboBNbI0uvy7otinzGVGKDXLIZBYdNdcFySyON8qtu6IsFp6Sw==}
+ peerDependencies:
+ react: '>=16.8'
+
resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==}
engines: {node: '>= 0.4'}
@@ -5038,6 +5093,9 @@ packages:
resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
+ resolution: {integrity: sha512-tQkJl2GRWh83ui2DiPTJz9wEiMN20syf+5oKfB03yYP7ioZcJwsIK8FjrtLwH1m7C7e+Tt2yYBlrOpdT+dyeIQ==}
+
resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==}
@@ -5693,6 +5751,9 @@ packages:
resolution: {integrity: sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==}
hasBin: true
+ resolution: {integrity: sha512-hEDLVEP1FCgaRtt0oZDJdz2lK9uK7WlB7ASswt9U9cqruSNueVigtRGxI97hevKlViqhAcRgNgzuY/m8FCCMcg==}
+
resolution: {integrity: sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==}
@@ -6701,6 +6762,16 @@ snapshots:
'@eslint/[email protected]': {}
+ '@essentials/[email protected]': {}
+
+ '@essentials/[email protected]': {}
+
+ '@essentials/[email protected]': {}
+
+ '@essentials/[email protected]':
+ dependencies:
+ '@essentials/raf': 1.2.0
+
'@fal-works/[email protected]': {}
'@floating-ui/[email protected]':
@@ -8016,6 +8087,41 @@ snapshots:
'@radix-ui/[email protected]': {}
+ dependencies:
+ '@react-hook/latest': 1.0.3([email protected])
+ react: 18.3.1
+
+ dependencies:
+ react: 18.3.1
+
+ dependencies:
+ react: 18.3.1
+
+ dependencies:
+ react: 18.3.1
+
+ dependencies:
+ '@react-hook/latest': 1.0.3([email protected])
+ react: 18.3.1
+
+ dependencies:
+ '@react-hook/event': 1.2.6([email protected])
+ '@react-hook/throttle': 2.2.0([email protected])
+ react: 18.3.1
+
+ dependencies:
+ '@react-hook/debounce': 3.0.0([email protected])
+ '@react-hook/event': 1.2.6([email protected])
+ '@react-hook/throttle': 2.2.0([email protected])
+ react: 18.3.1
+
'@rtsao/[email protected]': {}
'@rushstack/[email protected]': {}
@@ -9190,7 +9296,7 @@ snapshots:
eslint: 8.57.1
eslint-import-resolver-node: 0.3.9
eslint-plugin-jsx-a11y: 6.10.2([email protected])
eslint-plugin-react: 7.37.4([email protected])
eslint-plugin-react-hooks: 4.6.2([email protected])
@@ -9217,8 +9323,8 @@ snapshots:
debug: 4.3.4
enhanced-resolve: 5.15.1
eslint: 8.57.1
fast-glob: 3.3.2
get-tsconfig: 4.7.5
is-core-module: 2.16.1
@@ -9229,7 +9335,7 @@ snapshots:
- eslint-import-resolver-webpack
- supports-color
dependencies:
debug: 3.2.7
optionalDependencies:
@@ -9240,7 +9346,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
'@rtsao/scc': 1.1.0
array-includes: 3.1.8
@@ -9251,7 +9357,7 @@ snapshots:
doctrine: 2.1.0
eslint: 8.57.1
eslint-import-resolver-node: 0.3.9
hasown: 2.0.2
is-core-module: 2.16.1
is-glob: 4.0.3
@@ -10373,6 +10479,21 @@ snapshots:
+ dependencies:
+ '@essentials/memoize-one': 1.1.0
+ '@essentials/one-key-map': 1.2.0
+ '@essentials/request-timeout': 1.3.0
+ '@react-hook/event': 1.2.6([email protected])
+ '@react-hook/latest': 1.0.3([email protected])
+ '@react-hook/passive-layout-effect': 1.2.1([email protected])
+ '@react-hook/throttle': 2.2.0([email protected])
+ '@react-hook/window-scroll': 1.3.0([email protected])
+ '@react-hook/window-size': 3.1.1([email protected])
+ raf-schd: 4.0.3
+ react: 18.3.1
+ trie-memoize: 1.2.0
+
@@ -11620,6 +11741,8 @@ snapshots:
+
dependencies:
safe-buffer: 5.2.1
@@ -12475,6 +12598,8 @@ snapshots:
+
diff --git a/public/r/tweet-card.json b/public/r/tweet-card.json
index 33b9e762..dfa9dd72 100644
--- a/public/r/tweet-card.json
+++ b/public/r/tweet-card.json
@@ -10,7 +10,7 @@
"files": [
{
"path": "registry/magicui/tweet-card.tsx",
- "content": "/* eslint-disable @next/next/no-img-element */\nimport { Suspense } from \"react\";\nimport {\n enrichTweet,\n type EnrichedTweet,\n type TweetProps,\n type TwitterComponents,\n} from \"react-tweet\";\nimport { getTweet, type Tweet } from \"react-tweet/api\";\n\nimport { cn } from \"@/lib/utils\";\n\ninterface TwitterIconProps {\n className?: string;\n [key: string]: unknown;\n}\nconst Twitter = ({ className, ...props }: TwitterIconProps) => (\n <svg\n stroke=\"currentColor\"\n fill=\"currentColor\"\n strokeWidth=\"0\"\n viewBox=\"0 0 24 24\"\n height=\"1em\"\n width=\"1em\"\n xmlns=\"http://www.w3.org/2000/svg\"\n className={className}\n {...props}\n >\n <g>\n <path fill=\"none\" d=\"M0 0h24v24H0z\"></path>\n <path d=\"M22.162 5.656a8.384 8.384 0 0 1-2.402.658A4.196 4.196 0 0 0 21.6 4c-.82.488-1.719.83-2.656 1.015a4.182 4.182 0 0 0-7.126 3.814 11.874 11.874 0 0 1-8.62-4.37 4.168 4.168 0 0 0-.566 2.103c0 1.45.738 2.731 1.86 3.481a4.168 4.168 0 0 1-1.894-.523v.052a4.185 4.185 0 0 0 3.355 4.101 4.21 4.21 0 0 1-1.89.072A4.185 4.185 0 0 0 7.97 16.65a8.394 8.394 0 0 1-6.191 1.732 11.83 11.83 0 0 0 6.41 1.88c7.693 0 11.9-6.373 11.9-11.9 0-.18-.005-.362-.013-.54a8.496 8.496 0 0 0 2.087-2.165z\"></path>\n </g>\n </svg>\n);\n\nconst Verified = ({ className, ...props }: TwitterIconProps) => (\n <svg\n aria-label=\"Verified Account\"\n viewBox=\"0 0 24 24\"\n className={className}\n {...props}\n >\n <g fill=\"currentColor\">\n <path d=\"M22.5 12.5c0-1.58-.875-2.95-2.148-3.6.154-.435.238-.905.238-1.4 0-2.21-1.71-3.998-3.818-3.998-.47 0-.92.084-1.336.25C14.818 2.415 13.51 1.5 12 1.5s-2.816.917-3.437 2.25c-.415-.165-.866-.25-1.336-.25-2.11 0-3.818 1.79-3.818 4 0 .494.083.964.237 1.4-1.272.65-2.147 2.018-2.147 3.6 0 1.495.782 2.798 1.942 3.486-.02.17-.032.34-.032.514 0 2.21 1.708 4 3.818 4 .47 0 .92-.086 1.335-.25.62 1.334 1.926 2.25 3.437 2.25 1.512 0 2.818-.916 3.437-2.25.415.163.865.248 1.336.248 2.11 0 3.818-1.79 3.818-4 0-.174-.012-.344-.033-.513 1.158-.687 1.943-1.99 1.943-3.484zm-6.616-3.334l-4.334 6.5c-.145.217-.382.334-.625.334-.143 0-.288-.04-.416-.126l-.115-.094-2.415-2.415c-.293-.293-.293-.768 0-1.06s.768-.294 1.06 0l1.77 1.767 3.825-5.74c.23-.345.696-.436 1.04-.207.346.23.44.696.21 1.04z\" />\n </g>\n </svg>\n);\n\nexport const truncate = (str: string | null, length: number) => {\n if (!str || str.length <= length) return str;\n return `${str.slice(0, length - 3)}...`;\n};\n\nconst Skeleton = ({\n className,\n ...props\n}: React.HTMLAttributes<HTMLDivElement>) => {\n return (\n <div className={cn(\"rounded-md bg-primary/10\", className)} {...props} />\n );\n};\n\nexport const TweetSkeleton = ({\n className,\n ...props\n}: {\n className?: string;\n [key: string]: unknown;\n}) => (\n <div\n className={cn(\n \"flex size-full max-h-max min-w-72 flex-col gap-2 rounded-lg border p-4\",\n className,\n )}\n {...props}\n >\n <div className=\"flex flex-row gap-2\">\n <Skeleton className=\"size-10 shrink-0 rounded-full\" />\n <Skeleton className=\"h-10 w-full\" />\n </div>\n <Skeleton className=\"h-20 w-full\" />\n </div>\n);\n\nexport const TweetNotFound = ({\n className,\n ...props\n}: {\n className?: string;\n [key: string]: unknown;\n}) => (\n <div\n className={cn(\n \"flex size-full flex-col items-center justify-center gap-2 rounded-lg border p-4\",\n className,\n )}\n {...props}\n >\n <h3>Tweet not found</h3>\n </div>\n);\n\nexport const TweetHeader = ({ tweet }: { tweet: EnrichedTweet }) => (\n <div className=\"flex flex-row justify-between tracking-tight\">\n <div className=\"flex items-center space-x-2\">\n <a href={tweet.user.url} target=\"_blank\" rel=\"noreferrer\">\n <img\n title={`Profile picture of ${tweet.user.name}`}\n alt={tweet.user.screen_name}\n height={48}\n width={48}\n src={tweet.user.profile_image_url_https}\n className=\"overflow-hidden rounded-full border border-transparent\"\n />\n </a>\n <div>\n <a\n href={tweet.user.url}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"flex items-center whitespace-nowrap font-semibold\"\n >\n {truncate(tweet.user.name, 20)}\n {tweet.user.verified ||\n (tweet.user.is_blue_verified && (\n <Verified className=\"ml-1 inline size-4 text-blue-500\" />\n ))}\n </a>\n <div className=\"flex items-center space-x-1\">\n <a\n href={tweet.user.url}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"text-sm text-gray-500 transition-all duration-75\"\n >\n @{truncate(tweet.user.screen_name, 16)}\n </a>\n </div>\n </div>\n </div>\n <a href={tweet.url} target=\"_blank\" rel=\"noreferrer\">\n <span className=\"sr-only\">Link to tweet</span>\n <Twitter className=\"size-5 items-start text-[#3BA9EE] transition-all ease-in-out hover:scale-105\" />\n </a>\n </div>\n);\n\nexport const TweetBody = ({ tweet }: { tweet: EnrichedTweet }) => (\n <div className=\"break-words leading-normal tracking-tighter\">\n {tweet.entities.map((entity, idx) => {\n switch (entity.type) {\n case \"url\":\n case \"symbol\":\n case \"hashtag\":\n case \"mention\":\n return (\n <a\n key={idx}\n href={entity.href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"text-sm font-normal text-gray-500\"\n >\n <span>{entity.text}</span>\n </a>\n );\n case \"text\":\n return (\n <span\n key={idx}\n className=\"text-sm font-normal\"\n dangerouslySetInnerHTML={{ __html: entity.text }}\n />\n );\n }\n })}\n </div>\n);\n\nexport const TweetMedia = ({ tweet }: { tweet: EnrichedTweet }) => (\n <div className=\"flex flex-1 items-center justify-center\">\n {tweet.video && (\n <video\n poster={tweet.video.poster}\n autoPlay\n loop\n muted\n playsInline\n className=\"rounded-xl border shadow-sm\"\n >\n <source src={tweet.video.variants[0].src} type=\"video/mp4\" />\n Your browser does not support the video tag.\n </video>\n )}\n {tweet.photos && (\n <div className=\"relative flex transform-gpu snap-x snap-mandatory gap-4 overflow-x-auto\">\n <div className=\"shrink-0 snap-center sm:w-2\" />\n {tweet.photos.map((photo) => (\n <img\n key={photo.url}\n src={photo.url}\n title={\"Photo by \" + tweet.user.name}\n alt={tweet.text}\n className=\"h-64 w-5/6 shrink-0 snap-center snap-always rounded-xl border object-cover shadow-sm\"\n />\n ))}\n <div className=\"shrink-0 snap-center sm:w-2\" />\n </div>\n )}\n {!tweet.video &&\n !tweet.photos &&\n // @ts-ignore\n tweet?.card?.binding_values?.thumbnail_image_large?.image_value.url && (\n <img\n // @ts-ignore\n src={tweet.card.binding_values.thumbnail_image_large.image_value.url}\n className=\"h-64 rounded-xl border object-cover shadow-sm\"\n alt={tweet.text}\n />\n )}\n </div>\n);\n\nexport const MagicTweet = ({\n tweet,\n components,\n className,\n ...props\n}: {\n tweet: Tweet;\n components?: TwitterComponents;\n className?: string;\n}) => {\n const enrichedTweet = enrichTweet(tweet);\n return (\n <div\n className={cn(\n \"relative flex size-full max-w-lg flex-col gap-2 overflow-hidden rounded-lg border p-4 backdrop-blur-md\",\n className,\n )}\n {...props}\n >\n <TweetHeader tweet={enrichedTweet} />\n <TweetBody tweet={enrichedTweet} />\n <TweetMedia tweet={enrichedTweet} />\n </div>\n );\n};\n\n/**\n * TweetCard (Server Side Only)\n */\nexport const TweetCard = async ({\n id,\n components,\n fallback = <TweetSkeleton />,\n onError,\n ...props\n}: TweetProps & {\n className?: string;\n}) => {\n const tweet = id\n ? await getTweet(id).catch((err) => {\n if (onError) {\n onError(err);\n } else {\n console.error(err);\n }\n })\n : undefined;\n\n if (!tweet) {\n const NotFound = components?.TweetNotFound || TweetNotFound;\n return <NotFound {...props} />;\n }\n\n return (\n <Suspense fallback={fallback}>\n <MagicTweet tweet={tweet} {...props} />\n </Suspense>\n );\n};\n",
+ "content": "/* eslint-disable @next/next/no-img-element */\nimport { Suspense } from \"react\";\nimport {\n enrichTweet,\n type EnrichedTweet,\n type TweetProps,\n type TwitterComponents,\n} from \"react-tweet\";\nimport { getTweet, type Tweet } from \"react-tweet/api\";\n\nimport { cn } from \"@/lib/utils\";\n\ninterface TwitterIconProps {\n className?: string;\n [key: string]: unknown;\n}\nconst Twitter = ({ className, ...props }: TwitterIconProps) => (\n <svg\n stroke=\"currentColor\"\n fill=\"currentColor\"\n strokeWidth=\"0\"\n viewBox=\"0 0 24 24\"\n height=\"1em\"\n width=\"1em\"\n xmlns=\"http://www.w3.org/2000/svg\"\n className={className}\n {...props}\n >\n <g>\n <path fill=\"none\" d=\"M0 0h24v24H0z\"></path>\n <path d=\"M22.162 5.656a8.384 8.384 0 0 1-2.402.658A4.196 4.196 0 0 0 21.6 4c-.82.488-1.719.83-2.656 1.015a4.182 4.182 0 0 0-7.126 3.814 11.874 11.874 0 0 1-8.62-4.37 4.168 4.168 0 0 0-.566 2.103c0 1.45.738 2.731 1.86 3.481a4.168 4.168 0 0 1-1.894-.523v.052a4.185 4.185 0 0 0 3.355 4.101 4.21 4.21 0 0 1-1.89.072A4.185 4.185 0 0 0 7.97 16.65a8.394 8.394 0 0 1-6.191 1.732 11.83 11.83 0 0 0 6.41 1.88c7.693 0 11.9-6.373 11.9-11.9 0-.18-.005-.362-.013-.54a8.496 8.496 0 0 0 2.087-2.165z\"></path>\n </g>\n </svg>\n);\n\nconst Verified = ({ className, ...props }: TwitterIconProps) => (\n <svg\n aria-label=\"Verified Account\"\n viewBox=\"0 0 24 24\"\n className={className}\n {...props}\n >\n <g fill=\"currentColor\">\n <path d=\"M22.5 12.5c0-1.58-.875-2.95-2.148-3.6.154-.435.238-.905.238-1.4 0-2.21-1.71-3.998-3.818-3.998-.47 0-.92.084-1.336.25C14.818 2.415 13.51 1.5 12 1.5s-2.816.917-3.437 2.25c-.415-.165-.866-.25-1.336-.25-2.11 0-3.818 1.79-3.818 4 0 .494.083.964.237 1.4-1.272.65-2.147 2.018-2.147 3.6 0 1.495.782 2.798 1.942 3.486-.02.17-.032.34-.032.514 0 2.21 1.708 4 3.818 4 .47 0 .92-.086 1.335-.25.62 1.334 1.926 2.25 3.437 2.25 1.512 0 2.818-.916 3.437-2.25.415.163.865.248 1.336.248 2.11 0 3.818-1.79 3.818-4 0-.174-.012-.344-.033-.513 1.158-.687 1.943-1.99 1.943-3.484zm-6.616-3.334l-4.334 6.5c-.145.217-.382.334-.625.334-.143 0-.288-.04-.416-.126l-.115-.094-2.415-2.415c-.293-.293-.293-.768 0-1.06s.768-.294 1.06 0l1.77 1.767 3.825-5.74c.23-.345.696-.436 1.04-.207.346.23.44.696.21 1.04z\" />\n </g>\n </svg>\n);\n\nexport const truncate = (str: string | null, length: number) => {\n if (!str || str.length <= length) return str;\n return `${str.slice(0, length - 3)}...`;\n};\n\nconst Skeleton = ({\n className,\n ...props\n}: React.HTMLAttributes<HTMLDivElement>) => {\n return (\n <div className={cn(\"rounded-md bg-primary/10\", className)} {...props} />\n );\n};\n\nexport const TweetSkeleton = ({\n className,\n ...props\n}: {\n className?: string;\n [key: string]: unknown;\n}) => (\n <div\n className={cn(\n \"flex size-full max-h-max min-w-72 flex-col gap-2 rounded-lg border p-4\",\n className,\n )}\n {...props}\n >\n <div className=\"flex flex-row gap-2\">\n <Skeleton className=\"size-10 shrink-0 rounded-full\" />\n <Skeleton className=\"h-10 w-full\" />\n </div>\n <Skeleton className=\"h-20 w-full\" />\n </div>\n);\n\nexport const TweetNotFound = ({\n className,\n ...props\n}: {\n className?: string;\n [key: string]: unknown;\n}) => (\n <div\n className={cn(\n \"flex size-full flex-col items-center justify-center gap-2 rounded-lg border p-4\",\n className,\n )}\n {...props}\n >\n <h3>Tweet not found</h3>\n </div>\n);\n\nexport const TweetHeader = ({ tweet }: { tweet: EnrichedTweet }) => (\n <div className=\"flex flex-row justify-between tracking-tight\">\n <div className=\"flex items-center space-x-2\">\n <a href={tweet.user.url} target=\"_blank\" rel=\"noreferrer\">\n <img\n title={`Profile picture of ${tweet.user.name}`}\n alt={tweet.user.screen_name}\n height={48}\n width={48}\n src={tweet.user.profile_image_url_https}\n className=\"overflow-hidden rounded-full border border-transparent\"\n />\n </a>\n <div>\n <a\n href={tweet.user.url}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"flex items-center whitespace-nowrap font-semibold\"\n >\n {truncate(tweet.user.name, 20)}\n {tweet.user.verified ||\n (tweet.user.is_blue_verified && (\n <Verified className=\"ml-1 inline size-4 text-blue-500\" />\n ))}\n </a>\n <div className=\"flex items-center space-x-1\">\n <a\n href={tweet.user.url}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"text-sm text-gray-500 transition-all duration-75\"\n >\n @{truncate(tweet.user.screen_name, 16)}\n </a>\n </div>\n </div>\n </div>\n <a href={tweet.url} target=\"_blank\" rel=\"noreferrer\">\n <span className=\"sr-only\">Link to tweet</span>\n <Twitter className=\"size-5 items-start text-[#3BA9EE] transition-all ease-in-out hover:scale-105\" />\n </a>\n </div>\n);\n\nexport const TweetBody = ({ tweet }: { tweet: EnrichedTweet }) => (\n <div className=\"break-words leading-normal tracking-tighter\">\n {tweet.entities.map((entity, idx) => {\n switch (entity.type) {\n case \"url\":\n case \"symbol\":\n case \"hashtag\":\n case \"mention\":\n return (\n <a\n key={idx}\n href={entity.href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"text-sm font-normal text-gray-500\"\n >\n <span>{entity.text}</span>\n </a>\n );\n case \"text\":\n return (\n <span\n key={idx}\n className=\"text-sm font-normal\"\n dangerouslySetInnerHTML={{ __html: entity.text }}\n />\n );\n }\n })}\n </div>\n);\n\nexport const TweetMedia = ({ tweet }: { tweet: EnrichedTweet }) => {\n if (!tweet.video && !tweet.photos) return null;\n return (\n <div className=\"flex flex-1 items-center justify-center\">\n {tweet.video && (\n <video\n poster={tweet.video.poster}\n autoPlay\n loop\n muted\n playsInline\n className=\"rounded-xl border shadow-sm\"\n >\n <source src={tweet.video.variants[0].src} type=\"video/mp4\" />\n Your browser does not support the video tag.\n </video>\n )}\n {tweet.photos && (\n <div className=\"relative flex transform-gpu snap-x snap-mandatory gap-4 overflow-x-auto\">\n <div className=\"shrink-0 snap-center sm:w-2\" />\n {tweet.photos.map((photo) => (\n <img\n key={photo.url}\n src={photo.url}\n title={\"Photo by \" + tweet.user.name}\n alt={tweet.text}\n className=\"h-64 w-5/6 shrink-0 snap-center snap-always rounded-xl border object-cover shadow-sm\"\n />\n ))}\n <div className=\"shrink-0 snap-center sm:w-2\" />\n </div>\n )}\n {!tweet.video &&\n !tweet.photos &&\n // @ts-ignore\n tweet?.card?.binding_values?.thumbnail_image_large?.image_value.url && (\n <img\n src={\n // @ts-ignore\n tweet.card.binding_values.thumbnail_image_large.image_value.url\n }\n className=\"h-64 rounded-xl border object-cover shadow-sm\"\n alt={tweet.text}\n />\n )}\n </div>\n );\n};\n\nexport const MagicTweet = ({\n tweet,\n components,\n className,\n ...props\n}: {\n tweet: Tweet;\n components?: TwitterComponents;\n className?: string;\n}) => {\n const enrichedTweet = enrichTweet(tweet);\n return (\n <div\n className={cn(\n \"relative flex size-full max-w-lg flex-col gap-2 overflow-hidden rounded-lg border p-4 backdrop-blur-md\",\n className,\n )}\n {...props}\n >\n <TweetHeader tweet={enrichedTweet} />\n <TweetBody tweet={enrichedTweet} />\n <TweetMedia tweet={enrichedTweet} />\n </div>\n );\n};\n\n/**\n * TweetCard (Server Side Only)\n */\nexport const TweetCard = async ({\n id,\n components,\n fallback = <TweetSkeleton />,\n onError,\n ...props\n}: TweetProps & {\n className?: string;\n}) => {\n const tweet = id\n ? await getTweet(id).catch((err) => {\n if (onError) {\n onError(err);\n } else {\n console.error(err);\n }\n })\n : undefined;\n\n if (!tweet) {\n const NotFound = components?.TweetNotFound || TweetNotFound;\n return <NotFound {...props} />;\n }\n\n return (\n <Suspense fallback={fallback}>\n <MagicTweet tweet={tweet} {...props} />\n </Suspense>\n );\n};\n",
"type": "registry:ui",
"target": "components/magicui/tweet-card.tsx"
}
diff --git a/registry/magicui/tweet-card.tsx b/registry/magicui/tweet-card.tsx
index 0f720db1..1caf7709 100644
--- a/registry/magicui/tweet-card.tsx
+++ b/registry/magicui/tweet-card.tsx
@@ -177,49 +177,54 @@ export const TweetBody = ({ tweet }: { tweet: EnrichedTweet }) => (
</div>
);
-export const TweetMedia = ({ tweet }: { tweet: EnrichedTweet }) => (
- <div className="flex flex-1 items-center justify-center">
- {tweet.video && (
- <video
- poster={tweet.video.poster}
- autoPlay
- loop
- muted
- playsInline
- className="rounded-xl border shadow-sm"
- >
- <source src={tweet.video.variants[0].src} type="video/mp4" />
- Your browser does not support the video tag.
- </video>
- )}
- {tweet.photos && (
- <div className="relative flex transform-gpu snap-x snap-mandatory gap-4 overflow-x-auto">
- <div className="shrink-0 snap-center sm:w-2" />
- {tweet.photos.map((photo) => (
+export const TweetMedia = ({ tweet }: { tweet: EnrichedTweet }) => {
+ if (!tweet.video && !tweet.photos) return null;
+ return (
+ <div className="flex flex-1 items-center justify-center">
+ {tweet.video && (
+ <video
+ poster={tweet.video.poster}
+ autoPlay
+ loop
+ muted
+ playsInline
+ className="rounded-xl border shadow-sm"
+ >
+ <source src={tweet.video.variants[0].src} type="video/mp4" />
+ Your browser does not support the video tag.
+ </video>
+ )}
+ {tweet.photos && (
+ <div className="relative flex transform-gpu snap-x snap-mandatory gap-4 overflow-x-auto">
+ <div className="shrink-0 snap-center sm:w-2" />
+ {tweet.photos.map((photo) => (
+ <img
+ key={photo.url}
+ src={photo.url}
+ title={"Photo by " + tweet.user.name}
+ alt={tweet.text}
+ className="h-64 w-5/6 shrink-0 snap-center snap-always rounded-xl border object-cover shadow-sm"
+ />
+ ))}
+ <div className="shrink-0 snap-center sm:w-2" />
+ </div>
+ )}
+ {!tweet.video &&
+ !tweet.photos &&
+ // @ts-ignore
+ tweet?.card?.binding_values?.thumbnail_image_large?.image_value.url && (
<img
- key={photo.url}
- src={photo.url}
- title={"Photo by " + tweet.user.name}
+ src={
+ // @ts-ignore
+ tweet.card.binding_values.thumbnail_image_large.image_value.url
+ }
+ className="h-64 rounded-xl border object-cover shadow-sm"
alt={tweet.text}
- className="h-64 w-5/6 shrink-0 snap-center snap-always rounded-xl border object-cover shadow-sm"
/>
- ))}
- <div className="shrink-0 snap-center sm:w-2" />
- </div>
- )}
- {!tweet.video &&
- !tweet.photos &&
- // @ts-ignore
- tweet?.card?.binding_values?.thumbnail_image_large?.image_value.url && (
- <img
- // @ts-ignore
- src={tweet.card.binding_values.thumbnail_image_large.image_value.url}
- className="h-64 rounded-xl border object-cover shadow-sm"
- alt={tweet.text}
- />
- )}
- </div>
-);
+ )}
+ </div>
+ );
+};
export const MagicTweet = ({
tweet,