Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

fix(web): prevent mobile content overflow (#5140)

Gabe Kangasa3dd54b62c5e
diff --git a/.github/workflows/browser-testing.yml b/.github/workflows/browser-testing.yml
index df3b3b9c4e..4f61cf55d5 100644
--- a/.github/workflows/browser-testing.yml
+++ b/.github/workflows/browser-testing.yml
@@ -243,14 +243,26 @@ jobs:
mv "${f%.mp4}.fast.mp4" "$f"
fi
key="$PREFIX/${f#videos/}"
+ url="$S3_ENDPOINT/$S3_BUCKET/$key"
aws s3 cp "$f" "s3://$S3_BUCKET/$key" --endpoint-url "$S3_ENDPOINT" \
--acl public-read --content-type video/mp4 --no-progress >&2
+ poster_url=""
+ if [ -n "$FFMPEG" ] && "$FFMPEG" -v error -ss 1 -i "$f" -frames:v 1 "${f%.mp4}.png"; then
+ poster="${f%.mp4}.png"
+ poster_url="$S3_ENDPOINT/$S3_BUCKET/${key%.mp4}.png"
+ aws s3 cp "$poster" "s3://$S3_BUCKET/${key%.mp4}.png" --endpoint-url "$S3_ENDPOINT" \
+ --acl public-read --content-type image/png --no-progress >&2
+ fi
dir="${f#videos/}"; dir="${dir%%/*}"
if [ "$dir" != "$group" ]; then
group="$dir"
printf '\n**%s**\n\n' "$group"
fi
- printf -- '- [%s](%s/%s/%s)\n' "$(basename "$f" .mp4)" "$S3_ENDPOINT" "$S3_BUCKET" "$key"
+ if [ -n "$poster_url" ]; then
+ printf -- '- [%s](%s) [![%s preview](%s)](%s)\n' "$(basename "$f" .mp4)" "$url" "$(basename "$f" .mp4)" "$poster_url" "$url"
+ else
+ printf -- '- [%s](%s)\n' "$(basename "$f" .mp4)" "$url"
+ fi
done > results/video-links.md
echo "Published $(grep -c '^- ' results/video-links.md) videos."
@@ -276,7 +288,7 @@ jobs:
echo "## E2E UI test videos"
echo
if [ -s "$LINKS_FILE" ]; then
- echo "Click a recording to watch it in your browser (commit $HEAD_SHA):"
+ echo "Preview a recording below, then click it to watch it in your browser (commit $HEAD_SHA):"
cat "$LINKS_FILE"
echo
fi
diff --git a/web/.storybook/tools/screenshot-changed-stories.mjs b/web/.storybook/tools/screenshot-changed-stories.mjs
index 14d5183f20..7dee661289 100755
--- a/web/.storybook/tools/screenshot-changed-stories.mjs
+++ b/web/.storybook/tools/screenshot-changed-stories.mjs
@@ -49,8 +49,11 @@ const CHROME = chromeEnv.includes('/')
// Keep the comment reviewable on sweeping changes; Chromatic covers the rest.
const MAX_STORIES = 12;
-const WIDTH = 1000;
-const HEIGHT = 800;
+
+// Storybook tags mobile stories explicitly so PR screenshots show the
+// rendered phone viewport, not a desktop canvas containing phone-width CSS.
+const DESKTOP_VIEWPORT = { width: 1000, height: 800 };
+const MOBILE_VIEWPORT = { width: 390, height: 844 };
const changed = (process.env.CHANGED_FILES || '').split(/\s+/).filter(Boolean);
@@ -87,11 +90,23 @@ const browser = await puppeteer.launch({
args: ['--no-sandbox', '--disable-gpu', '--hide-scrollbars', '--force-device-scale-factor=1'],
});
-async function capture(base, id, file) {
+const viewportFor = story =>
+ story.tags?.includes('screenshot-mobile') ? MOBILE_VIEWPORT : DESKTOP_VIEWPORT;
+
+async function capture(base, story, file) {
+ const { id } = story;
const url = `${base}/iframe.html?id=${id}&viewMode=story`;
const page = await browser.newPage();
+ await page.setRequestInterception(true);
+ page.on('request', request => {
+ if (new URL(request.url()).pathname === '/logo') {
+ request.continue({ url: `${base}/project/logo-semisimple-white.svg` });
+ return;
+ }
+ request.continue();
+ });
try {
- await page.setViewport({ width: WIDTH, height: HEIGHT });
+ await page.setViewport(viewportFor(story));
for (let attempt = 1; ; attempt += 1) {
await page.goto(url, { waitUntil: 'networkidle0', timeout: 60_000 });
try {
@@ -102,7 +117,7 @@ async function capture(base, id, file) {
() =>
document.body.classList.contains('sb-show-main') &&
document.getElementById('storybook-root')?.childElementCount > 0,
- { timeout: 30_000 }
+ { timeout: 30_000 },
);
break;
} catch {
@@ -134,10 +149,11 @@ for (const story of shown) {
const beforeName = `${story.id}-before.png`;
const afterName = `${story.id}-after.png`;
const hasBefore =
- !isNew && (await capture(BASELINE_URL, story.id, path.join(OUT_DIR, 'img', beforeName)));
- const hasAfter = await capture(STATIC_URL, story.id, path.join(OUT_DIR, 'img', afterName));
+ !isNew && (await capture(BASELINE_URL, story, path.join(OUT_DIR, 'img', beforeName)));
+ const hasAfter = await capture(STATIC_URL, story, path.join(OUT_DIR, 'img', afterName));
- const img = (name, alt) => `<img src="${PUBLIC_BASE_URL}/${name}" alt="${alt}" width="420">`;
+ const img = (name, alt) =>
+ `<img src="${PUBLIC_BASE_URL}/${name}" alt="${alt}" width="${viewportFor(story).width}">`;
const beforeCell = isNew
? '_new story_'
: hasBefore
@@ -153,11 +169,14 @@ for (const story of shown) {
'| develop | this PR |',
'| --- | --- |',
`| ${beforeCell} | ${afterCell} |`,
- ''
+ '',
);
}
if (omitted.length) {
- lines.push(`_+${omitted.length} more affected ${omitted.length === 1 ? 'story' : 'stories'} not shown._`, '');
+ lines.push(
+ `_+${omitted.length} more affected ${omitted.length === 1 ? 'story' : 'stories'} not shown._`,
+ '',
+ );
}
fs.writeFileSync(path.join(OUT_DIR, 'comment-body.md'), lines.join('\n'));
await browser.close();
diff --git a/web/components/ui/Content/MobileContent.stories.tsx b/web/components/ui/Content/MobileContent.stories.tsx
index 888c3122c6..39f21be306 100644
--- a/web/components/ui/Content/MobileContent.stories.tsx
+++ b/web/components/ui/Content/MobileContent.stories.tsx
@@ -14,6 +14,7 @@ const makePluginTabs = (count: number): PluginTab[] =>
const meta = {
title: 'owncast/Components/Mobile content',
component: MobileContent,
+ tags: ['screenshot-mobile'],
globals: {
viewport: { value: 'iphone12Portrait', isRotated: false },
},
@@ -46,10 +47,16 @@ const Template: StoryFn<MobileContentProps> = args => (
const defaultArgs: MobileContentProps = {
name: 'Demo stream',
- summary: 'A stream for exercising the mobile tab bar.',
- tags: ['demo', 'tabs'],
+ summary: 'A live community stream with conversation, music, and the occasional guest.',
+ tags: ['live music', 'community', 'weekly show'],
socialHandles: [],
- extraPageContent: '<p>This is the About tab content.</p>',
+ extraPageContent: `
+ <h2>Tonight’s broadcast</h2>
+ <p>Join us for a relaxed live set, followed by a chat with local artists. New listeners are always welcome.</p>
+ <p>Schedule, guest details, and community links are available at <a href="https://demo.example.org/schedule-and-special-guest-announcements">demo.example.org/schedule-and-special-guest-announcements</a>.</p>
+ <h3>What to expect</h3>
+ <p>Music, conversation, and a place to meet people who care about the same things.</p>
+ `,
pluginTabs: [],
setShowFollowModal: () => {},
showFollowersTab: false,
diff --git a/web/components/ui/Content/MobileContent.tsx b/web/components/ui/Content/MobileContent.tsx
index dabd6bee7f..e4804355b4 100644
--- a/web/components/ui/Content/MobileContent.tsx
+++ b/web/components/ui/Content/MobileContent.tsx
@@ -171,7 +171,7 @@ export const MobileContent: FC<MobileContentProps> = ({
/>
</div>
) : (
- <div>{aboutTabContent}</div>
+ <div style={{ width: '100%' }}>{aboutTabContent}</div>
)}
</ErrorBoundary>
);