Skip to content

Commit

Permalink
Implement provider-specific sizing for embeds (#178)
Browse files Browse the repository at this point in the history
* Implement provider-specific sizing for embeds

* Refactor embed styles to be more readable
  • Loading branch information
tituomin authored Oct 3, 2023
1 parent 7141325 commit 271321f
Showing 1 changed file with 40 additions and 11 deletions.
51 changes: 40 additions & 11 deletions components/common/StreamField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ const STREAM_FIELD_FRAGMENT = gql`
${CategoryListBlock.fragments.category}
`;

enum EmbedProvider {
YOUTUBE = 'YouTube',
PLOTLY = 'Plotly Chart Studio',
}

const ResponsiveStyles = styled.div`
.responsive-object {
width: 100%;
Expand All @@ -289,19 +294,43 @@ const ResponsiveStyles = styled.div`
height: 100%;
}
.responsive-object-small iframe {
aspect-ratio: 16 / 9;
max-width: 300px;
}
.responsive-object-medium iframe {
aspect-ratio: 16 / 9;
max-width: 480px;
.responsive-object[data-embed-provider='${EmbedProvider.YOUTUBE}'] {
&.responsive-object-small {
iframe {
aspect-ratio: 16 / 9;
max-width: 300px;
}
}
&.responsive-object-medium {
iframe {
aspect-ratio: 16 / 9;
max-width: 480px;
}
}
&.responsive-object-large {
iframe {
aspect-ratio: 16 / 9;
max-width: 960px;
}
}
}
.responsive-object-large iframe {
aspect-ratio: 16 / 9;
max-width: 960px;
.responsive-object[data-embed-provider='${EmbedProvider.PLOTLY}'] {
&.responsive-object-small {
iframe {
height: 400px;
}
}
&.responsive-object-medium {
iframe {
height: 600px;
}
}
&.responsive-object-large {
iframe {
height: 800px;
}
}
}
`;

Expand Down

0 comments on commit 271321f

Please sign in to comment.