Skip to content

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

🐛 fix: add image carousel to tweet card

Dillion Vermaa964061d6b46
diff --git a/components/landing/hero.tsx b/components/landing/hero.tsx
index 358b9492..6d350e51 100644
--- a/components/landing/hero.tsx
+++ b/components/landing/hero.tsx
@@ -12,7 +12,7 @@ export default function Hero() {
<div className="container flex max-w-[64rem] flex-col items-center gap-4 text-center">
<FadeIn className="z-10 flex h-full w-full flex-col items-center justify-center">
<Link
- href="/components/bento-grid"
+ href="/components/retro-grid"
className={cn(
"relative flex flex-row items-center justify-center",
"rounded-2xl px-4 py-1.5 text-sm font-medium shadow-[inset_0_-8px_10px_#8fdfff1f]",
diff --git a/content/components/tweet-card.mdx b/content/components/tweet-card.mdx
index 42deeac0..47a5024c 100644
--- a/content/components/tweet-card.mdx
+++ b/content/components/tweet-card.mdx
@@ -82,6 +82,12 @@ export default function App() {
}
```
+## Examples
+
+### Image Carousel
+
+<ComponentPreview name="tweet-card-images" />
+
## Props
### ClientTweetCard
diff --git a/registry/components/example/tweet-card-images.tsx b/registry/components/example/tweet-card-images.tsx
new file mode 100644
index 00000000..6d370a7a
--- /dev/null
+++ b/registry/components/example/tweet-card-images.tsx
@@ -0,0 +1,11 @@
+import TweetCard from "@/registry/components/magicui/tweet-card";
+
+export default async function TweetImages() {
+ return <TweetCard id="1678577280489234432" className="shadow-2xl" />;
+ // return <TweetCard id="1668408059125702661" className="shadow-2xl" />;
+ // return <TweetCard id="1675849118445436929" className="shadow-2xl" />;
+}
+// https://twitter.com/dillionverma/status/
+// https://x.com/ParkerRex/status/1694751634377568414?s=20
+// https://twitter.com/dillionverma/status/1678577280489234432
+// https://x.com/dillionverma/status/1675849118445436929?s=20
diff --git a/registry/components/magicui/tweet-card.tsx b/registry/components/magicui/tweet-card.tsx
index f07a0b23..0c4d68c8 100644
--- a/registry/components/magicui/tweet-card.tsx
+++ b/registry/components/magicui/tweet-card.tsx
@@ -159,7 +159,7 @@ export const TweetBody = ({ tweet }: { tweet: EnrichedTweet }) => (
href={entity.href}
target="_blank"
rel="noopener noreferrer"
- className="text-gray-500"
+ className="text-sm font-normal text-gray-500"
>
<span>{entity.text}</span>
</a>
@@ -168,7 +168,7 @@ export const TweetBody = ({ tweet }: { tweet: EnrichedTweet }) => (
return (
<span
key={idx}
- className="text-sm"
+ className="text-sm font-normal"
dangerouslySetInnerHTML={{ __html: entity.text }}
/>
);
@@ -193,16 +193,26 @@ export const TweetMedia = ({ tweet }: { tweet: EnrichedTweet }) => (
</video>
)}
{tweet.photos && (
- <div className="flex flex-row gap-2">
+ <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}
- className="rounded-xl border shadow-sm"
+ 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 && (
+ <img
+ // @ts-ignore
+ src={tweet.card.binding_values.thumbnail_image_large.image_value.url}
+ className="h-64 rounded-xl border object-cover shadow-sm"
+ />
+ )}
</div>
);
diff --git a/registry/index.tsx b/registry/index.tsx
index fac47346..ffc8fd25 100644
--- a/registry/index.tsx
+++ b/registry/index.tsx
@@ -203,6 +203,14 @@ const example: Registry = {
() => import("@/registry/components/example/tweet-card-demo"),
),
},
+ "tweet-card-images": {
+ name: "tweet-card-images",
+ type: "components:example",
+ files: ["registry/components/example/tweet-card-images.tsx"],
+ component: React.lazy(
+ () => import("@/registry/components/example/tweet-card-images"),
+ ),
+ },
"shimmer-button-demo": {
name: "shimmer-button-demo",
type: "components:example",