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

Improve captions appearance when there is also a CTA #13477

Merged
merged 8 commits into from
Oct 27, 2023
3 changes: 2 additions & 1 deletion includes/KSES.php
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,8 @@ public function filter_kses_allowed_html( $allowed_tags ) {
'title' => true,
],
'amp-story-captions' => [
'height' => true,
'height' => true,
'style-preset' => true,
],
'amp-story-shopping-attachment' => [
'cta-text' => true,
Expand Down
6 changes: 3 additions & 3 deletions packages/output/src/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ function OutputPage({
<div className="captions-area">
{videoCaptions.map((captionId) => (
<amp-story-captions
key={captionId}
id={captionId}
layout="fixed-height"
height="100"
key={captionId}
layout="container" // "container" layout will only occupy required height.
style-preset="default"
/>
))}
</div>
Expand Down
4 changes: 2 additions & 2 deletions packages/output/src/test/__snapshots__/page.js.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/output/src/test/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -1621,9 +1621,9 @@ describe('Page output', () => {
await expect(captions).toBeInTheDocument();
expect(captions).toMatchInlineSnapshot(`
<amp-story-captions
height="100"
id="el-baz-captions"
layout="fixed-height"
layout="container"
style-preset="default"
/>
`);
});
Expand Down
23 changes: 7 additions & 16 deletions packages/output/src/utils/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ function CustomStyles() {
amp-story-grid-layer.align-bottom {
align-content: end;
padding: 0;
/*
AMP CTA Layer will exactly occupy 74px regardless of any device.
To space out captions 74px from the BOTTOM (AMP CTA Layer),
74px from the TOP should also be spaced out and thus: 2 * 74px
will be the desired max-height.
*/
max-height: calc(100vh - (2 * 74px));
}

.captions-area {
Expand All @@ -145,22 +152,6 @@ function CustomStyles() {
margin-bottom: 16px;
text-align: center;
}

amp-story-captions span {
display: inline-block;
margin: 0;
padding: 6px 12px;
vertical-align: middle;
border-radius: 15px;
background: rgba(11, 11, 11, 0.6);
color: rgba(255, 255, 255, 1);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;;
font-size: calc(4 * var(--story-page-vw));
line-height: 1.4;
word-break: break-word;
word-wrap: break-word;
overflow-wrap: break-word;
}
`,
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

// To mimic the responsive `amp-story-captions span` styling on the frontend.
const fontSize = pageWidth * 0.04;
const height = pageHeight * 0.2;
const height = pageHeight * 0.3;

Check warning on line 58 in packages/story-editor/src/components/canvas/mediaCaptions/trackRenderer.js

View check run for this annotation

Codecov / codecov/patch

packages/story-editor/src/components/canvas/mediaCaptions/trackRenderer.js#L58

Added line #L58 was not covered by tests

const [track, setTrack] = useState(null);
const [videoTime, setVideoTime] = useState(0);
Expand Down
Loading