-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new post: RubyKaigi 2024 で LT 登壇した 兼 参加記 & add SpeakerDeck, Mastodon …
…components (#320)
- Loading branch information
Showing
5 changed files
with
275 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
'use client' | ||
|
||
import { Box } from '@chakra-ui/react' | ||
import { css } from '@emotion/react' | ||
import React, { useEffect, useRef } from 'react' | ||
|
||
type Props = { | ||
url: string | ||
} | ||
|
||
export const Mastodon: React.FC<Props> = ({ url }) => { | ||
const iframeRef = useRef<HTMLIFrameElement>(null) | ||
|
||
useEffect(() => { | ||
const iframe = iframeRef.current | ||
const src = `${url}/embed` | ||
if (iframe == null) return | ||
iframe.src = src | ||
|
||
const script = document.createElement('script') | ||
// e.g. https://social.fohte.net/@fohte/123456789 -> https://social.fohte.net/embed.js | ||
script.src = new URL('/embed.js', url).toString() | ||
script.async = true | ||
|
||
if (!document.head.contains(script)) { | ||
document.head.appendChild(script) | ||
} | ||
}, [url]) | ||
|
||
return ( | ||
<Box | ||
my={2} | ||
css={css` | ||
display: flex; | ||
justify-content: center; | ||
`} | ||
> | ||
<iframe | ||
ref={iframeRef} | ||
className="mastodon-embed" | ||
style={{ | ||
maxWidth: '100%', | ||
border: 0, | ||
}} | ||
width="500" | ||
allowFullScreen | ||
/> | ||
</Box> | ||
) | ||
} |
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,30 @@ | ||
'use client' | ||
|
||
import { Box } from '@chakra-ui/react' | ||
import * as React from 'react' | ||
|
||
type SpeakerDeckProps = { | ||
id: string | ||
} | ||
|
||
export const SpeakerDeck: React.FC<SpeakerDeckProps> = ({ id }) => ( | ||
<Box my={8}> | ||
<iframe | ||
className="speakerdeck-iframe" | ||
src={`https://speakerdeck.com/player/${id}`} | ||
allowFullScreen | ||
style={{ | ||
border: '0px', | ||
background: 'padding-box padding-box rgba(0, 0, 0, 0.1)', | ||
margin: '0px', | ||
padding: '0px', | ||
borderRadius: '6px', | ||
boxShadow: 'rgba(0, 0, 0, 0.2) 0px 5px 40px', | ||
width: '100%', | ||
height: 'auto', | ||
aspectRatio: '560 / 315', | ||
}} | ||
data-ratio="1.7777777777777777" | ||
/> | ||
</Box> | ||
) |
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.