Skip to content

Commit 6e04cad

Browse files
refactor(youtube): use AspectRatio as wrapper
1 parent 896675b commit 6e04cad

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/@chakra-ui/gatsby-plugin/styles.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ const styles = {
5858
"li > p": {
5959
"margin-bottom": "calc(1.45rem / 2)",
6060
},
61-
// YouTube embeds
62-
iframe: {
63-
display: "block",
64-
maxWidth: "560px",
65-
margin: "32px 0",
66-
},
6761
// should be replace by the usage of https://chakra-ui.com/docs/components/heading
6862
// also, the media queries defined on each of these heading tags are bearly used
6963
"h1,h2,h3,h4,h5,h6": {

src/components/YouTube.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react"
2-
import { Box } from "@chakra-ui/react"
2+
import { AspectRatio } from "@chakra-ui/react"
33

44
/**
55
* @param {id} ID of the YouTube video
@@ -22,10 +22,8 @@ const YouTube: React.FC<IProps> = ({ id, start = "0", title = "YouTube" }) => {
2222
const baseUrl = "https://www.youtube.com/embed/"
2323
const src = baseUrl + id + startQuery
2424
return (
25-
<Box as="figure" display="block" my={4}>
25+
<AspectRatio as="figure" maxW="560px" ratio={16 / 9} my={8}>
2626
<iframe
27-
width="100%"
28-
height="315"
2927
src={src}
3028
frameBorder="0"
3129
title={title}
@@ -37,8 +35,8 @@ const YouTube: React.FC<IProps> = ({ id, start = "0", title = "YouTube" }) => {
3735
gyroscope;
3836
picture-in-picture"
3937
allowFullScreen
40-
></iframe>
41-
</Box>
38+
/>
39+
</AspectRatio>
4240
)
4341
}
4442

0 commit comments

Comments
 (0)