|
| 1 | +import { type EnrichedTweet } from 'react-tweet' |
| 2 | +import { nFormatter } from './utils' |
| 3 | +import { Heart, Message } from './icons' |
| 4 | +import { Tilt } from './tilt' |
| 5 | +import { TweetHeader } from './tweet-header' |
| 6 | +import { TweetText } from './tweet-text' |
| 7 | +import { TweetMedia } from './tweet-media' |
| 8 | + |
| 9 | +export const DubTweet = ({ |
| 10 | + tweet, |
| 11 | + noTilt, |
| 12 | +}: { |
| 13 | + tweet: EnrichedTweet |
| 14 | + noTilt?: boolean |
| 15 | +}) => { |
| 16 | + const TweetBody = ( |
| 17 | + <div className="break-inside-avoid rounded-lg border border-gray-300 bg-white/20 bg-clip-padding p-6 pb-4 backdrop-blur-lg backdrop-filter"> |
| 18 | + {/* User info, verified badge, twitter logo, text, etc. */} |
| 19 | + <div> |
| 20 | + <TweetHeader tweet={tweet} /> |
| 21 | + {tweet.in_reply_to_status_id_str && tweet.in_reply_to_screen_name && ( |
| 22 | + <div className="mt-5 text-base text-gray-500"> |
| 23 | + Replying to{' '} |
| 24 | + <a |
| 25 | + className="text-[#1da1f2] no-underline" |
| 26 | + href={tweet.in_reply_to_url} |
| 27 | + target="_blank" |
| 28 | + > |
| 29 | + @{tweet.in_reply_to_screen_name} |
| 30 | + </a> |
| 31 | + </div> |
| 32 | + )} |
| 33 | + <TweetText tweet={tweet} /> |
| 34 | + </div> |
| 35 | + {/* Images, Preview images, videos, polls, etc. */} |
| 36 | + <div className="-mb-2 mt-3"> |
| 37 | + {tweet.mediaDetails?.length ? ( |
| 38 | + <div |
| 39 | + className={ |
| 40 | + tweet.mediaDetails.length === 1 |
| 41 | + ? '' |
| 42 | + : 'inline-grid grid-cols-2 gap-x-2 gap-y-2' |
| 43 | + } |
| 44 | + > |
| 45 | + {tweet.mediaDetails?.map((media) => ( |
| 46 | + <a key={media.media_url_https} href={tweet.url} target="_blank"> |
| 47 | + <TweetMedia tweet={tweet} media={media} /> |
| 48 | + </a> |
| 49 | + ))} |
| 50 | + </div> |
| 51 | + ) : null} |
| 52 | + </div> |
| 53 | + <div className="flex justify-center space-x-8 text-sm text-gray-500 mt-5"> |
| 54 | + <a |
| 55 | + className="group flex items-center space-x-3 hover:text-red-600" |
| 56 | + href={tweet.like_url} |
| 57 | + target="_blank" |
| 58 | + rel="noreferrer" |
| 59 | + > |
| 60 | + <Heart className="h-4 w-4 group-hover:fill-red-600" /> |
| 61 | + <p>{nFormatter(tweet.favorite_count)}</p> |
| 62 | + </a> |
| 63 | + <a |
| 64 | + className="group flex items-center space-x-3 hover:text-blue-600" |
| 65 | + href={tweet.reply_url} |
| 66 | + target="_blank" |
| 67 | + rel="noreferrer" |
| 68 | + > |
| 69 | + <Message className="h-4 w-4 group-hover:fill-blue-600" /> |
| 70 | + <p>{nFormatter(tweet.conversation_count)}</p> |
| 71 | + </a> |
| 72 | + </div> |
| 73 | + </div> |
| 74 | + ) |
| 75 | + |
| 76 | + return noTilt ? ( |
| 77 | + TweetBody |
| 78 | + ) : ( |
| 79 | + <Tilt |
| 80 | + glareEnable={true} |
| 81 | + glareMaxOpacity={0.3} |
| 82 | + glareColor="#ffffff" |
| 83 | + glarePosition="all" |
| 84 | + glareBorderRadius="8px" |
| 85 | + tiltMaxAngleX={10} |
| 86 | + tiltMaxAngleY={10} |
| 87 | + > |
| 88 | + {TweetBody} |
| 89 | + </Tilt> |
| 90 | + ) |
| 91 | +} |
0 commit comments