Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support iframes in container media content #1487

Merged
merged 6 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pages/container/media-side-permutations.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const permutations = createPermutations<ContainerProps.Media>([
<img key={'image43'} src={image43} alt="placeholder" />,
<img key={'image916'} src={image916} alt="placeholder" />,
<img key={'imageVideo'} src={imageVideo} alt="placeholder" />,
<iframe key="iframe" srcDoc="<h1>This is an iframe</h1>"></iframe>,
],
width: ['', '33%', '50%'],
},
Expand Down
1 change: 1 addition & 0 deletions pages/container/media-top-permutations.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const permutations = createPermutations<ContainerProps.Media>([
<img key={'image43'} src={image43} alt="placeholder" />,
<img key={'image916'} src={image916} alt="placeholder" />,
<img key={'imageVideo'} src={imageVideo} alt="placeholder" />,
<iframe key="iframe" srcDoc="<h1>This is an iframe</h1>"></iframe>,
],
height: ['', 100, 200, 300],
},
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/__snapshots__/documenter.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5007,7 +5007,7 @@ all containers to the height of the longest one, to avoid extra vertical scroll
Object {
"description": "Use this slot to render a media element. Supported element types are 'img', 'video', and 'picture'.
You can define different positions and sizes for the media element within the container.
* \`content\` - Use this slot to render your media element. We support \`img\`, \`video\` and \`picture\` elements.
* \`content\` - Use this slot to render your media element. We support \`img\`, \`video\`, \`picture\`, and \`iframe\` elements.

* \`position\` - Defines the media slot's position within the container. Defaults to \`top\`.

Expand Down
6 changes: 2 additions & 4 deletions src/container/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface ContainerProps extends BaseComponentProps {
* Use this slot to render a media element. Supported element types are 'img', 'video', and 'picture'.
* You can define different positions and sizes for the media element within the container.
*
* * `content` - Use this slot to render your media element. We support `img`, `video` and `picture` elements.
* * `content` - Use this slot to render your media element. We support `img`, `video`, `picture`, and `iframe` elements.
*
* * `position` - Defines the media slot's position within the container. Defaults to `top`.
*
Expand Down Expand Up @@ -72,9 +72,7 @@ export interface ContainerProps extends BaseComponentProps {
export namespace ContainerProps {
export interface Media {
/**
*
* Use this slot to render your media element. We support `img`, `video` and `picture` elements.
*
* Use this slot to render your media element. We support `img`, `video`, `picture`, and `iframe` elements.
*/
content: React.ReactNode;

Expand Down
7 changes: 7 additions & 0 deletions src/container/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@
object-position: center;
}

// stylelint-disable-next-line @cloudscape-design/no-implicit-descendant, selector-max-type
iframe {
width: 100%;
height: 100%;
border: 0;
}

&-top {
max-height: 66%;
border-top-left-radius: awsui.$border-radius-container;
Expand Down
Loading