Skip to content

Commit fb547cf

Browse files
authored
Merge pull request #8445 from TylerAPfledderer/refactor/youtube-aspect-ratio
Refactor: Use `AspectRatio` in `Youtube` component
2 parents 28385b1 + 6e04cad commit fb547cf

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
@@ -62,12 +62,6 @@ const styles = {
6262
"li > p": {
6363
"margin-bottom": "calc(1.45rem / 2)",
6464
},
65-
// YouTube embeds
66-
iframe: {
67-
display: "block",
68-
maxWidth: "560px",
69-
margin: "32px 0",
70-
},
7165
// should be replace by the usage of https://chakra-ui.com/docs/components/heading
7266
// also, the media queries defined on each of these heading tags are bearly used
7367
"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)