-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/articles' into feature/#219-transform-valid-mar…
…kdown-to-nodes
- Loading branch information
Showing
49 changed files
with
983 additions
and
418 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
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
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
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
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
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
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
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
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
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
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
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
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,70 @@ | ||
import React, { memo, useState, useEffect } from 'react'; | ||
import { EmbedElementProps } from "./EmbedMedia"; | ||
import { getTweetIdFromUrl } from "../../../../utils/embed"; | ||
import style from "./Embed.module.scss"; | ||
import { Error } from "../../../Error/Error"; | ||
import useInit from "../../../../hooks/useInit"; | ||
import Skeleton from "../../../Skeleton"; | ||
import { LoaderBlock } from "../../../Layout/LoaderBlock"; | ||
|
||
const twitterWidgetJs = 'https://platform.twitter.com/widgets.js'; | ||
|
||
declare global { | ||
interface Window { | ||
twttr: any; | ||
} | ||
} | ||
|
||
const EmbedTwitter = memo<EmbedElementProps>(({ href}) => { | ||
const ref = React.useRef<HTMLDivElement | null>(null); | ||
const [isInit, setIsInit] = useState(false); | ||
const [isLoading, setIsLoading] = useState(true); | ||
const [hasTweetNotFound, setHasTweetNotFound] = useState(false); | ||
|
||
useInit(() => { | ||
const script = require('scriptjs'); | ||
script(twitterWidgetJs, 'twitter-embed', () => setIsInit(true)); | ||
}) | ||
|
||
useEffect(() => { | ||
const loadTweet = async () => { | ||
setIsLoading(true) | ||
if (ref.current) { | ||
ref.current?.replaceChildren(); | ||
} | ||
const tweetElement = await window.twttr.widgets.createTweet( | ||
tweetId, | ||
ref?.current, | ||
) | ||
setIsLoading(false); | ||
if (!tweetElement) { | ||
setHasTweetNotFound(true); | ||
} | ||
}; | ||
|
||
if (!isInit) return ; | ||
setHasTweetNotFound(false); | ||
const tweetId = getTweetIdFromUrl(href); | ||
if (!tweetId) return ; | ||
if (!window.twttr) { | ||
console.error('Failure to load window.twttr, aborting load'); | ||
return; | ||
} | ||
if (!window.twttr.widgets.createTweet) { | ||
console.error(`Method createTweet is not present anymore in twttr.widget api`); | ||
return; | ||
} | ||
loadTweet(); | ||
}, [href, isInit]); | ||
|
||
return ( | ||
<> | ||
{isLoading && <LoaderBlock className={style.twitter_loading} size="small" />} | ||
<div className={style.twitter} ref={ref}/> | ||
{hasTweetNotFound && <Error>No tweet found for this url</Error>} | ||
</> | ||
); | ||
}); | ||
|
||
EmbedTwitter.displayName = 'EmbedTwitter'; | ||
export default EmbedTwitter; |
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
Empty file.
25 changes: 25 additions & 0 deletions
25
src/components/NFTArticle/elements/Medias/NFTArticleImage.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,25 @@ | ||
import style from "./NFTArticleImage.module.scss" | ||
import cs from "classnames" | ||
import { ImagePolymorphic } from "../../../Medias/ImagePolymorphic" | ||
|
||
interface Props { | ||
src: string | ||
alt: string | ||
} | ||
export function NFTArticleImage({ | ||
src, | ||
alt, | ||
}: Props) { | ||
return ( | ||
<figure className="article_image"> | ||
<ImagePolymorphic | ||
uri={src} | ||
/> | ||
{alt && ( | ||
<figcaption> | ||
{alt} | ||
</figcaption> | ||
)} | ||
</figure> | ||
) | ||
} |
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
Oops, something went wrong.