This repository has been archived by the owner on Apr 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix TweetHeader to use simple img tag
- Loading branch information
Showing
4 changed files
with
79 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
packages/react-static-tweets/src/twitter-layout/components/tweet/tweet-header.next.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React from 'react' | ||
import Image from 'next/image' | ||
|
||
export default function TweetHeader({ tweet }) { | ||
const authorUrl = `https://twitter.com/${tweet.username}` | ||
const tweetUrl = `https://twitter.com/${tweet.username}/status/${tweet.id}` | ||
const avatar = tweet.avatar.normal | ||
|
||
return ( | ||
<div className='static-tweet-header'> | ||
<a | ||
href={authorUrl} | ||
className='static-tweet-header-avatar' | ||
target='_blank' | ||
rel='noopener noreferrer' | ||
> | ||
<Image | ||
className='static-tweet-header-rounded' | ||
src={avatar} | ||
alt={tweet.name} | ||
height={36} | ||
width={36} | ||
/> | ||
</a> | ||
|
||
<a | ||
href={authorUrl} | ||
className='static-tweet-header-author' | ||
target='_blank' | ||
rel='noopener noreferrer' | ||
> | ||
<span className='static-tweet-header-name' title={tweet.name}> | ||
{tweet.name} | ||
</span> | ||
|
||
<span | ||
className='static-tweet-header-username' | ||
title={`@${tweet.username}`} | ||
> | ||
@{tweet.username} | ||
</span> | ||
</a> | ||
|
||
<a | ||
href={tweetUrl} | ||
className='static-tweet-header-brand' | ||
target='_blank' | ||
rel='noopener noreferrer' | ||
> | ||
<div | ||
className='static-tweet-header-icon-twitter' | ||
title='View on Twitter' | ||
role='img' | ||
/> | ||
</a> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/react-static-tweets/src/twitter-layout/components/tweet/tweet.next.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react' | ||
import TweetHeader from './tweet-header' | ||
import TweetInfo from './tweet-info' | ||
|
||
const TweetContext = React.createContext<any>({}) | ||
|
||
export const useTweet = () => React.useContext(TweetContext) | ||
|
||
export default function Tweet({ children, data }) { | ||
return ( | ||
<div className='static-tweet-body'> | ||
<blockquote className='static-tweet-body-blockquote'> | ||
<TweetHeader tweet={data} /> | ||
<TweetContext.Provider value={data}>{children}</TweetContext.Provider> | ||
<TweetInfo tweet={data} /> | ||
</blockquote> | ||
</div> | ||
) | ||
} |