Skip to content

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

feat(web): offline featured-stream recommendation

Gabe Kangasab8950ad0a97
diff --git a/web/components/ui/Content/Content.module.scss b/web/components/ui/Content/Content.module.scss
index ccbada6045..665c3613ab 100644
--- a/web/components/ui/Content/Content.module.scss
+++ b/web/components/ui/Content/Content.module.scss
@@ -94,6 +94,28 @@
color: var(--theme-color-palette-4);
}
+.offlineSection {
+ width: 100%;
+ background-color: var(--theme-color-components-video-background);
+}
+
+.offlineRecommendationLayout {
+ width: min(100%, 1160px);
+ display: grid;
+ grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
+ gap: clamp(1.25rem, 3vw, 2.75rem);
+ align-items: stretch;
+ margin: 0 auto;
+ padding: clamp(1rem, 4vw, 3.5rem);
+
+ @include screen(tablet) {
+ display: flex;
+ flex-direction: column;
+ gap: 0;
+ padding: 0;
+ }
+}
+
.actionButtonsContainer {
display: flex;
height: 100%;
diff --git a/web/components/ui/Content/Content.tsx b/web/components/ui/Content/Content.tsx
index 18ec5dc095..103b55d7f1 100644
--- a/web/components/ui/Content/Content.tsx
+++ b/web/components/ui/Content/Content.tsx
@@ -28,6 +28,7 @@ import {
import styles from './Content.module.scss';
import desktopStyles from './DesktopContent.module.scss';
import { OfflineBanner } from '../OfflineBanner/OfflineBanner';
+import { OfflineRecommendation } from '../OfflineRecommendation/OfflineRecommendation';
import { Statusbar } from '../Statusbar/Statusbar';
import { ExternalAction } from '../../../interfaces/external-action';
import { Modal } from '../Modal/Modal';
@@ -152,6 +153,7 @@ export const Content: FC = () => {
// engagement) but the public followers list is not shown.
const showFollowersTab = fediverseEnabled && !hideFollowersTab;
const { servers: federatedServers } = useFederatedServers();
+ const recommendedServer = federatedServers.find(server => server.isOnline);
const [showChatModal, setShowChatModal] = useState(false);
@@ -277,18 +279,34 @@ export const Content: FC = () => {
/>
)}
{!online && !appState.appLoading && (
- <div id="offline-message" style={{ width: '100%' }}>
- <OfflineBanner
- showsHeader={false}
- streamName={name}
- customText={offlineMessage}
- notificationsEnabled={supportsBrowserNotifications}
- fediverseAccount={fediverseAccount}
- lastLive={lastDisconnectTime}
- onNotifyClick={() => setShowNotifyModal(true)}
- onFollowClick={() => setShowFollowModal(true)}
- className={classnames([styles.topSectionElement, styles.offlineBanner])}
- />
+ <div
+ id="offline-message"
+ className={classnames(styles.offlineSection, {
+ [styles.topSectionElement]: !!recommendedServer,
+ })}
+ >
+ <div
+ className={classnames({
+ [styles.offlineRecommendationLayout]: !!recommendedServer,
+ })}
+ >
+ <OfflineBanner
+ showsHeader={false}
+ streamName={name}
+ customText={offlineMessage}
+ notificationsEnabled={supportsBrowserNotifications}
+ fediverseAccount={fediverseAccount}
+ lastLive={lastDisconnectTime}
+ onNotifyClick={() => setShowNotifyModal(true)}
+ onFollowClick={() => setShowFollowModal(true)}
+ className={classnames(styles.offlineBanner, {
+ [styles.topSectionElement]: !recommendedServer,
+ })}
+ />
+ {recommendedServer && (
+ <OfflineRecommendation localStreamName={name} server={recommendedServer} />
+ )}
+ </div>
</div>
)}
</Row>
diff --git a/web/components/ui/CrossfadeImage/CrossfadeImage.tsx b/web/components/ui/CrossfadeImage/CrossfadeImage.tsx
index 7e3baddb8e..71e85117ae 100644
--- a/web/components/ui/CrossfadeImage/CrossfadeImage.tsx
+++ b/web/components/ui/CrossfadeImage/CrossfadeImage.tsx
@@ -9,6 +9,8 @@ export type CrossfadeImageProps = {
objectFit?: ObjectFit;
duration?: string;
className?: string;
+ referrerPolicy?: React.ImgHTMLAttributes<HTMLImageElement>['referrerPolicy'];
+ onError?: React.ImgHTMLAttributes<HTMLImageElement>['onError'];
};
const imgStyle: React.CSSProperties = {
@@ -24,6 +26,8 @@ export const CrossfadeImage: FC<CrossfadeImageProps> = ({
objectFit = 'fill', // default value for objectFit
duration = '3s', // default value for duration
className,
+ referrerPolicy,
+ onError,
}) => {
const spanStyle: React.CSSProperties = useMemo(
() => ({
@@ -64,6 +68,8 @@ export const CrossfadeImage: FC<CrossfadeImageProps> = ({
alt=""
style={imgStyles[index]}
onLoad={index === 2 ? onLoadImg : undefined}
+ referrerPolicy={referrerPolicy}
+ onError={onError}
/>
),
)}
diff --git a/web/components/ui/OfflineRecommendation/OfflineRecommendation.module.scss b/web/components/ui/OfflineRecommendation/OfflineRecommendation.module.scss
new file mode 100644
index 0000000000..fba1ff56ec
--- /dev/null
+++ b/web/components/ui/OfflineRecommendation/OfflineRecommendation.module.scss
@@ -0,0 +1,275 @@
+.panel {
+ display: flex;
+ flex-direction: column;
+ isolation: isolate;
+ justify-content: flex-start;
+ padding: 1.5rem;
+ border: 1px solid rgb(255 255 255 / 12%);
+ border-radius: 10px;
+ background: var(--theme-color-background-main);
+ box-shadow: 0 18px 44px rgb(0 0 0 / 16%);
+}
+
+.introduction {
+ margin: 0.35rem 0 0;
+ color: var(--theme-color-components-text-on-light);
+ font-family: var(--theme-text-display-font-family);
+ font-size: 1.05rem;
+ font-weight: 400;
+ line-height: 1.45;
+}
+
+.recommendation {
+ position: relative;
+ display: flex;
+ flex-direction: column;
+ margin-top: 1.25rem;
+ padding: 0;
+ overflow: hidden;
+ border: 1px solid rgb(255 255 255 / 16%);
+ border-radius: 10px;
+ background: var(--theme-color-background-main);
+ color: inherit;
+ text-decoration: none;
+
+ &:focus-visible {
+ outline: 3px solid var(--theme-color-action);
+ outline-offset: 4px;
+ }
+}
+
+.image {
+ position: relative;
+ width: 100%;
+ min-height: 0;
+ overflow: hidden;
+ background: var(--theme-color-background-header);
+ aspect-ratio: 16 / 9;
+
+ img {
+ filter: saturate(1.15) contrast(1.4);
+ transition: filter 320ms ease;
+ }
+
+ img {
+ position: relative;
+ z-index: 1;
+ width: 100%;
+ height: 100%;
+ display: block;
+ object-fit: cover;
+
+ &[hidden] {
+ display: none;
+ }
+ }
+}
+
+.details {
+ position: absolute;
+ z-index: 2;
+ inset: 0;
+ min-width: 0;
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ justify-content: flex-end;
+ padding: 1rem;
+ isolation: isolate;
+
+ &::before {
+ position: absolute;
+ z-index: 0;
+ inset: 0;
+ background: linear-gradient(
+ 180deg,
+ rgb(0 0 0 / 18%) 0%,
+ rgb(0 0 0 / 72%) 48%,
+ rgb(0 0 0 / 94%) 100%
+ );
+ content: '';
+ transition: opacity 320ms ease;
+ }
+
+ > * {
+ position: relative;
+ z-index: 1;
+ }
+}
+
+.identity {
+ width: 100%;
+ display: flex;
+ align-items: center;
+ gap: 0.75rem;
+ padding-right: 5rem;
+ box-sizing: border-box;
+}
+
+.logo {
+ position: static;
+ flex: 0 0 auto;
+ width: 36px;
+ height: 36px;
+ border: 1px solid rgb(255 255 255 / 35%);
+ border-radius: 50%;
+ background: rgb(0 0 0 / 45%);
+ box-shadow: 0 1px 4px rgb(0 0 0 / 45%);
+ object-fit: cover;
+}
+
+.name,
+.description,
+.streamTitle,
+.watchAction {
+ color: var(--theme-color-components-text-on-dark);
+}
+
+.name {
+ min-width: 0;
+ display: -webkit-box;
+ overflow: hidden;
+ font-family: var(--theme-text-display-font-family);
+ font-size: 1.05rem;
+ line-height: 1.35;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: 2;
+}
+
+.description {
+ display: -webkit-box;
+ margin-top: 0.25rem;
+ overflow: hidden;
+ font-size: 0.92rem;
+ line-height: 1.45;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: 2;
+}
+
+.streamTitle {
+ max-width: 100%;
+ margin-top: 0.5rem;
+ overflow: hidden;
+ font-size: 0.76rem;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ opacity: 0.8;
+}
+
+.watchAction {
+ display: inline-flex;
+ align-items: center;
+ gap: 0.45rem;
+ margin-top: 0.75rem;
+ padding-top: 0;
+ font-weight: 600;
+ text-decoration: underline;
+ filter: drop-shadow(0 1px 2px rgb(0 0 0 / 85%));
+}
+
+.liveLabel {
+ position: absolute;
+ z-index: 2;
+ top: 12px;
+ right: 12px;
+ margin-bottom: 0;
+}
+
+@media (width <= 768px) {
+ .panel {
+ width: 100%;
+ display: block;
+ margin: 0;
+ padding: 0;
+ border: 0;
+ border-radius: 0;
+ background: transparent;
+ box-shadow: none;
+ }
+
+ .introduction {
+ display: none;
+ }
+
+ .recommendation {
+ display: block;
+ min-height: 132px;
+ margin-top: 0;
+ border: 0;
+ border-radius: 0;
+ }
+
+ .image {
+ position: absolute;
+ inset: 0;
+ width: 100%;
+ height: 100%;
+ aspect-ratio: auto;
+
+ img {
+ filter: brightness(1.1) saturate(1.5) contrast(1.2);
+ transition: none;
+ }
+ }
+
+ .details {
+ position: relative;
+ inset: auto;
+ min-height: 132px;
+ justify-content: flex-end;
+ padding: 0.5rem 1rem 1rem;
+
+ &::before {
+ background: linear-gradient(
+ 90deg,
+ rgb(0 0 0 / 96%) 0%,
+ rgb(0 0 0 / 84%) 58%,
+ rgb(0 0 0 / 62%) 100%
+ );
+ transition: none;
+ }
+ }
+
+ .streamTitle {
+ display: none;
+ }
+
+ .watchAction {
+ margin-top: 0.35rem;
+ }
+}
+
+@media (width > 768px) and (hover: hover) and (pointer: fine) {
+ .logo,
+ .name,
+ .description,
+ .streamTitle {
+ transition: opacity 320ms ease;
+ }
+
+ .recommendation:hover .details::before {
+ opacity: 0.25;
+ }
+
+ .recommendation:hover .image img {
+ filter: brightness(1) saturate(1) contrast(1);
+ }
+
+ .recommendation:hover .logo,
+ .recommendation:hover .name,
+ .recommendation:hover .description,
+ .recommendation:hover .streamTitle {
+ opacity: 0.18;
+ }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .details::before,
+ .image img,
+ .logo,
+ .name,
+ .description,
+ .streamTitle {
+ transition: none;
+ }
+}
diff --git a/web/components/ui/OfflineRecommendation/OfflineRecommendation.stories.module.scss b/web/components/ui/OfflineRecommendation/OfflineRecommendation.stories.module.scss
new file mode 100644
index 0000000000..cef439010c
--- /dev/null
+++ b/web/components/ui/OfflineRecommendation/OfflineRecommendation.stories.module.scss
@@ -0,0 +1,107 @@
+.viewerFrame {
+ min-height: 100dvh;
+ background: var(--theme-color-background-main);
+ color: var(--theme-color-components-text-on-light);
+ font-family: var(--theme-text-body-font-family);
+}
+
+.viewerHeader {
+ min-height: 70px;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 0 2rem;
+ background: var(--theme-color-background-header);
+ color: var(--theme-color-components-text-on-dark);
+
+ strong {
+ font-family: var(--theme-text-display-font-family);
+ font-size: 1.05rem;
+ }
+
+ span {
+ font-size: 0.8rem;
+ opacity: 0.75;
+ }
+}
+
+.offlineStage {
+ min-height: 0;
+ background: var(--theme-color-components-video-background);
+ color: var(--theme-color-palette-4);
+}
+
+.viewerContent {
+ width: min(100%, 980px);
+ margin: 0 auto;
+ padding: 0 1.5rem 3rem;
+}
+
+.viewerTabs {
+ display: flex;
+ gap: 1.5rem;
+ border-bottom: 1px solid rgb(0 0 0 / 12%);
+ color: var(--theme-color-components-text-on-light);
+ font-size: 0.9rem;
+
+ span {
+ padding: 1rem 0 0.75rem;
+ opacity: 0.68;
+ }
+
+ .activeTab {
+ margin-bottom: -1px;
+ border-bottom: 2px solid var(--theme-color-action);
+ color: var(--theme-color-action);
+ font-weight: 600;
+ opacity: 1;
+ }
+}
+
+.viewerSummary {
+ padding: 1.5rem 0;
+ color: var(--theme-color-components-text-on-light);
+
+ h2 {
+ margin: 0;
+ font-family: var(--theme-text-display-font-family);
+ font-size: 1.25rem;
+ }
+
+ p {
+ margin: 0.5rem 0 0;
+ opacity: 0.72;
+ }
+}
+
+.splitPanel {
+ width: min(100%, 1160px);
+ display: grid;
+ grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
+ gap: clamp(1.25rem, 3vw, 2.75rem);
+ align-items: stretch;
+ margin: 0 auto;
+ padding: clamp(1rem, 4vw, 3.5rem);
+}
+
+.offlineOnly {
+ width: 100%;
+}
+
+@media (width <= 768px) {
+ .viewerHeader {
+ min-height: 3.85rem;
+ padding: 0 1rem;
+ }
+
+ .viewerContent {
+ padding: 0 1.25rem 2rem;
+ }
+
+ .splitPanel {
+ display: flex;
+ flex-direction: column;
+ gap: 0;
+ padding: 0;
+ }
+}
diff --git a/web/components/ui/OfflineRecommendation/OfflineRecommendation.stories.tsx b/web/components/ui/OfflineRecommendation/OfflineRecommendation.stories.tsx
new file mode 100644
index 0000000000..61dcff7c63
--- /dev/null
+++ b/web/components/ui/OfflineRecommendation/OfflineRecommendation.stories.tsx
@@ -0,0 +1,127 @@
+import type { Meta, StoryObj } from '@storybook/nextjs';
+import type { FederatedServerResponse } from '../../../hooks/useFederatedServers';
+import { OfflineBanner } from '../OfflineBanner/OfflineBanner';
+import { OfflineRecommendation } from './OfflineRecommendation';
+import styles from './OfflineRecommendation.stories.module.scss';
+
+const featuredServer: FederatedServerResponse = {
+ id: 1,
+ iri: 'https://radio.gamethattune.com',
+ displayName: 'Game That Tune Radio',
+ streamDescription: 'Video game deep cuts and listener requests',
+ streamTitle: 'Always-on video game music radio',
+ logoUrl: 'https://watch.owncast.online/logo',
+ thumbnailUrl: 'https://watch.owncast.online/thumbnail.jpg',
+ isOnline: true,
+ addedAt: new Date().toISOString(),
+};
+
+const brightThumbnailServer: FederatedServerResponse = {
+ ...featuredServer,
+ displayName: 'Daylight Community TV',
+ streamDescription: 'A very bright outdoor broadcast',
+ iri: 'https://daylight.example',
+ thumbnailUrl: `data:image/svg+xml,${encodeURIComponent(`
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 540">
+ <rect width="960" height="540" fill="#fff9db"/>
+ <circle cx="760" cy="120" r="95" fill="#ffffff"/>
+ <path d="M0 430 240 180 420 350 620 150 960 440V540H0Z" fill="#dff5ff"/>
+ <path d="M0 470 260 300 480 440 700 260 960 470V540H0Z" fill="#f2f8df"/>
+ </svg>
+ `)}`,
+};
+
+const longMetadataServer: FederatedServerResponse = {
+ ...featuredServer,
+ displayName: 'The International Community Game Preservation and Independent Radio Collective',
+ streamDescription:
+ 'Restoring forgotten games live while taking listener requests and answering community questions',
+ streamTitle:
+ 'The complete international history of independent games, preserved live with community guests',
+ iri: 'https://live.broadcast.archive.community-media.gamethattune.example',
+};
+
+const failedThumbnailServer: FederatedServerResponse = {
+ ...featuredServer,
+ thumbnailUrl: '/missing-featured-thumbnail.jpg',
+};
+
+const lastLive = new Date(Date.now() - 3 * 24 * 60 * 60 * 1000);
+
+const OfflineRecommendationStory = ({
+ server = featuredServer,
+}: {
+ server?: FederatedServerResponse | null;
+}) => (
+ <div className={styles.viewerFrame}>
+ <header className={styles.viewerHeader}>
+ <strong>Gabek&apos;s Owncast</strong>
+ <span>gabek</span>
+ </header>
+ <main className={styles.offlineStage}>
+ <div className={server ? styles.splitPanel : styles.offlineOnly}>
+ <OfflineBanner
+ showsHeader={false}
+ streamName="Gabek's Owncast"
+ customText="No stream today. I'll be back Thursday for a live Q&amp;A and project update."
+ notificationsEnabled={false}
+ lastLive={lastLive}
+ />
+ {server && <OfflineRecommendation localStreamName="Gabek's Owncast" server={server} />}
+ </div>
+ </main>
+ <section className={styles.viewerContent}>
+ <nav className={styles.viewerTabs} aria-label="Viewer sections">
+ <span className={styles.activeTab}>About</span>
+ <span>Schedule</span>
+ <span>Featured</span>
+ </nav>
+ <div className={styles.viewerSummary}>
+ <h2>Gabek&apos;s Owncast</h2>
+ <p>Independent live video, community updates, and project streams.</p>
+ </div>
+ </section>
+ </div>
+);
+
+const meta = {
+ title: 'owncast/Layout/Offline Recommendation Concepts',
+ component: OfflineRecommendation,
+ args: {
+ localStreamName: "Gabek's Owncast",
+ server: featuredServer,
+ },
+ parameters: {
+ layout: 'fullscreen',
+ chromatic: { viewports: [375, 1280] },
+ docs: {
+ description: {
+ component:
+ 'The responsive offline viewer layout with one live featured-stream recommendation.',
+ },
+ },
+ },
+} satisfies Meta<typeof OfflineRecommendation>;
+
+export default meta;
+type Story = StoryObj<typeof meta>;
+
+export const SplitPanel: Story = {
+ render: () => <OfflineRecommendationStory />,
+};
+
+export const SplitPanelWithoutLiveFeaturedStream: Story = {
+ render: () => <OfflineRecommendationStory server={null} />,
+};
+
+export const SplitPanelBrightThumbnail: Story = {
+ render: () => <OfflineRecommendationStory server={brightThumbnailServer} />,
+};
+
+export const SplitPanelLongMetadata: Story = {
+ render: () => <OfflineRecommendationStory server={longMetadataServer} />,
+};
+
+export const SplitPanelFailedThumbnail: Story = {
+ render: () => <OfflineRecommendationStory server={failedThumbnailServer} />,
+};
diff --git a/web/components/ui/OfflineRecommendation/OfflineRecommendation.tsx b/web/components/ui/OfflineRecommendation/OfflineRecommendation.tsx
new file mode 100644
index 0000000000..eedb86a5e9
--- /dev/null
+++ b/web/components/ui/OfflineRecommendation/OfflineRecommendation.tsx
@@ -0,0 +1,99 @@
+import type { FC } from 'react';
+import { ArrowRightOutlined } from '@ant-design/icons';
+import { useTranslation } from 'next-export-i18n';
+import type { FederatedServerResponse } from '../../../hooks/useFederatedServers';
+import { Localization } from '../../../types/localization';
+import { VideoPoster } from '../../video/VideoPoster/VideoPoster';
+import { StreamStatusBadge } from '../StreamStatusBadge/StreamStatusBadge';
+import { Translation } from '../Translation/Translation';
+import styles from './OfflineRecommendation.module.scss';
+
+export type OfflineRecommendationProps = {
+ localStreamName: string;
+ server: FederatedServerResponse;
+};
+
+const getServerHost = (serverUrl: string) => {
+ try {
+ return new URL(serverUrl).hostname;
+ } catch {
+ return serverUrl;
+ }
+};
+
+export const OfflineRecommendation: FC<OfflineRecommendationProps> = ({
+ localStreamName,
+ server,
+}) => {
+ const { t } = useTranslation();
+ const serverHost = getServerHost(server.iri);
+ const serverName = server.displayName || server.name || serverHost;
+ const description = server.streamDescription || server.summary;
+ const thumbnail = server.thumbnailUrl;
+
+ return (
+ <aside className={styles.panel}>
+ <p className={styles.introduction}>
+ <Translation
+ translationKey={Localization.Frontend.OfflineRecommendation.introduction}
+ vars={{ name: localStreamName }}
+ defaultText="While this stream is offline, visit this recommended stream."
+ />
+ </p>
+ <a
+ className={styles.recommendation}
+ href={server.iri}
+ target="_blank"
+ rel="noopener noreferrer"
+ aria-label={t(Localization.Frontend.OfflineRecommendation.linkAria, {
+ name: serverName,
+ host: serverHost,
+ })}
+ >
+ <div className={styles.image}>
+ {thumbnail && (
+ <VideoPoster
+ online
+ initialSrc={thumbnail}
+ src={thumbnail}
+ refreshInterval={thumbnail.startsWith('data:') ? 0 : 15_000}
+ objectFit="cover"
+ width="100%"
+ height="100%"
+ referrerPolicy="no-referrer"
+ onError={event => {
+ event.currentTarget.hidden = true;
+ }}
+ />
+ )}
+ </div>
+ <div className={styles.details}>
+ <div className={styles.identity}>
+ {server.logoUrl && (
+ <img
+ className={styles.logo}
+ src={server.logoUrl}
+ alt=""
+ referrerPolicy="no-referrer"
+ onError={event => {
+ event.currentTarget.hidden = true;
+ }}
+ />
+ )}
+ <strong className={styles.name}>{serverName}</strong>
+ </div>
+ <StreamStatusBadge isOnline className={styles.liveLabel} />
+ {description && <span className={styles.description}>{description}</span>}
+ <span className={styles.streamTitle}>{server.streamTitle || serverHost}</span>
+ <span className={styles.watchAction}>
+ <Translation
+ translationKey={Localization.Frontend.OfflineRecommendation.watchLive}
+ defaultText="Watch live"
+ />
+ <ArrowRightOutlined aria-hidden="true" />
+ </span>
+ </div>
+ </a>
+ </aside>
+ );
+};
diff --git a/web/components/ui/StreamCard/StreamCard.module.scss b/web/components/ui/StreamCard/StreamCard.module.scss
index 6f84092273..a4f09c2b0f 100644
--- a/web/components/ui/StreamCard/StreamCard.module.scss
+++ b/web/components/ui/StreamCard/StreamCard.module.scss
@@ -28,15 +28,6 @@
border-color: var(--theme-text-link);
}
- &.online {
- .statusBadge {
- :global(.ant-badge-status-text) {
- color: var(--theme-color-palette-4);
- font-weight: 600;
- }
- }
- }
-
&.offline {
opacity: 0.8;
@@ -88,21 +79,6 @@
position: absolute;
top: 12px;
right: 12px;
- background: rgb(0 0 0 / 70%);
- padding: 4px 12px;
- border-radius: 10px;
-
- :global(.ant-badge-status-dot) {
- width: 8px;
- height: 8px;
- }
-
- :global(.ant-badge-status-text) {
- color: var(--theme-color-components-text-on-dark);
- font-size: 12px;
- font-weight: 500;
- letter-spacing: 0.5px;
- }
}
}
diff --git a/web/components/ui/StreamCard/StreamCard.tsx b/web/components/ui/StreamCard/StreamCard.tsx
index 9358b8308c..1a4542d459 100644
--- a/web/components/ui/StreamCard/StreamCard.tsx
+++ b/web/components/ui/StreamCard/StreamCard.tsx
@@ -1,7 +1,8 @@
import { FC } from 'react';
-import { Card, Tag, Typography, Badge } from 'antd';
+import { Card, Tag, Typography } from 'antd';
import classNames from 'classnames';
import styles from './StreamCard.module.scss';
+import { StreamStatusBadge } from '../StreamStatusBadge/StreamStatusBadge';
const { Text, Paragraph } = Typography;
@@ -53,11 +54,7 @@ export const StreamCard: FC<StreamCardProps> = ({
{serverLogo && <img src={serverLogo} alt={serverName} className={styles.logoOverlay} />}
</div>
)}
- <Badge
- status={isOnline ? 'success' : 'default'}
- text={isOnline ? 'LIVE' : 'OFFLINE'}
- className={styles.statusBadge}
- />
+ <StreamStatusBadge isOnline={isOnline} className={styles.statusBadge} />
</div>
);
@@ -110,7 +107,6 @@ export const StreamCard: FC<StreamCardProps> = ({
<Card
role="article"
className={classNames(styles.streamCard, {
- [styles.online]: isOnline,
[styles.offline]: !isOnline,
})}
cover={cardCover}
diff --git a/web/components/ui/StreamStatusBadge/StreamStatusBadge.module.scss b/web/components/ui/StreamStatusBadge/StreamStatusBadge.module.scss
new file mode 100644
index 0000000000..2f00c55590
--- /dev/null
+++ b/web/components/ui/StreamStatusBadge/StreamStatusBadge.module.scss
@@ -0,0 +1,51 @@
+.badge.badge {
+ width: max-content;
+ display: inline-flex;
+ align-items: center;
+ padding: 4px 12px;
+ border-radius: 10px;
+ background: rgb(0 0 0 / 70%);
+
+ :global(.ant-badge-status-dot) {
+ width: 8px;
+ height: 8px;
+ }
+
+ :global(.ant-badge-status-text) {
+ color: var(--theme-color-components-text-on-dark);
+ font-size: 12px;
+ font-weight: 500;
+ letter-spacing: 0.5px;
+ }
+}
+
+.online.online {
+ :global(.ant-badge-status-dot) {
+ transform-origin: center;
+ animation: live-dot-breathe 2.4s ease-in-out infinite;
+ }
+
+ :global(.ant-badge-status-text) {
+ color: var(--theme-color-palette-4);
+ font-weight: 600;
+ }
+}
+
+@keyframes live-dot-breathe {
+ 0%,
+ 100% {
+ transform: scale(1);
+ opacity: 0.82;
+ }
+
+ 50% {
+ transform: scale(1.12);
+ opacity: 1;
+ }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .online.online :global(.ant-badge-status-dot) {
+ animation: none;
+ }
+}
diff --git a/web/components/ui/StreamStatusBadge/StreamStatusBadge.tsx b/web/components/ui/StreamStatusBadge/StreamStatusBadge.tsx
new file mode 100644
index 0000000000..88e990b617
--- /dev/null
+++ b/web/components/ui/StreamStatusBadge/StreamStatusBadge.tsx
@@ -0,0 +1,17 @@
+import type { FC } from 'react';
+import { Badge } from 'antd';
+import classNames from 'classnames';
+import styles from './StreamStatusBadge.module.scss';
+
+export type StreamStatusBadgeProps = {
+ isOnline: boolean;
+ className?: string;
+};
+
+export const StreamStatusBadge: FC<StreamStatusBadgeProps> = ({ isOnline, className }) => (
+ <Badge
+ status={isOnline ? 'success' : 'default'}
+ text={isOnline ? 'LIVE' : 'OFFLINE'}
+ className={classNames(styles.badge, { [styles.online]: isOnline }, className)}
+ />
+);
diff --git a/web/components/video/VideoPoster/VideoPoster.tsx b/web/components/video/VideoPoster/VideoPoster.tsx
index 9653472f56..f906149c13 100644
--- a/web/components/video/VideoPoster/VideoPoster.tsx
+++ b/web/components/video/VideoPoster/VideoPoster.tsx
@@ -1,4 +1,4 @@
-import { FC, useEffect, useState } from 'react';
+import { useEffect, useState, type CSSProperties, type FC, type ImgHTMLAttributes } from 'react';
import { CrossfadeImage } from '../../ui/CrossfadeImage/CrossfadeImage';
import styles from './VideoPoster.module.scss';
@@ -8,22 +8,43 @@ export type VideoPosterProps = {
initialSrc: string;
src: string;
online: boolean;
+ refreshInterval?: number;
+ objectFit?: CSSProperties['objectFit'];
+ width?: string;
+ height?: string;
+ referrerPolicy?: ImgHTMLAttributes<HTMLImageElement>['referrerPolicy'];
+ onError?: ImgHTMLAttributes<HTMLImageElement>['onError'];
};
-export const VideoPoster: FC<VideoPosterProps> = ({ online, initialSrc, src: base }) => {
- let timer: ReturnType<typeof setInterval>;
+export const VideoPoster: FC<VideoPosterProps> = ({
+ online,
+ initialSrc,
+ src: base,
+ refreshInterval = REFRESH_INTERVAL,
+ objectFit = 'contain',
+ width = '100%',
+ height = 'auto',
+ referrerPolicy,
+ onError,
+}) => {
const [src, setSrc] = useState(initialSrc);
const [duration, setDuration] = useState('0s');
useEffect(() => {
- clearInterval(timer);
- timer = setInterval(() => {
- if (duration === '0s') {
- setDuration('3s');
- }
- setSrc(`${base}?${Date.now()}`);
- }, REFRESH_INTERVAL);
- }, []);
+ setSrc(initialSrc);
+ setDuration('0s');
+
+ if (!online || refreshInterval <= 0) {
+ return undefined;
+ }
+
+ const timer = setInterval(() => {
+ setDuration(current => (current === '0s' ? '3s' : current));
+ setSrc(`${base}${base.includes('?') ? '&' : '?'}cb=${Date.now()}`);
+ }, refreshInterval);
+
+ return () => clearInterval(timer);
+ }, [base, initialSrc, online, refreshInterval]);
return (
<div className={styles.poster}>
@@ -33,10 +54,12 @@ export const VideoPoster: FC<VideoPosterProps> = ({ online, initialSrc, src: bas
<CrossfadeImage
src={src}
duration={duration}
- objectFit="contain"
- height="auto"
- width="100%"
+ objectFit={objectFit}
+ height={height}
+ width={width}
className={styles.image}
+ referrerPolicy={referrerPolicy}
+ onError={onError}
/>
)}
</div>
diff --git a/web/i18n/en/translation.json b/web/i18n/en/translation.json
index fccf0b29ab..ed2a8edd73 100644
--- a/web/i18n/en/translation.json
+++ b/web/i18n/en/translation.json
@@ -64,16 +64,16 @@
"approveButton": "Approve",
"confirmNo": "No",
"confirmYes": "Yes",
- "directoryListingsDescription": "These directories follow your server so they can list your stream. Each one receives your live status. Remove one to stop sending it your status and drop your server from its listing.",
- "directoryListingsEmpty": "No directories are featuring your stream yet.",
- "directoryListingsTitle": "Directories listing you",
- "directoryRemoved": "Removed from the directory.",
+ "directoryListingsDescription": "These instances follow your server so they can list your stream. Each one receives your live status. Remove one to stop sending it your status and drop your server from its listing.",
+ "directoryListingsEmpty": "No instances are featuring your stream yet.",
+ "directoryListingsTitle": "Instances listing you",
+ "directoryRemoved": "Removed from this instance.",
"enterStreamUrl": "Please enter a stream URL",
"enterValidUrl": "Please enter a valid URL",
"failedToApprove": "Failed to approve the feature request",
"failedToFeature": "Failed to feature stream",
"failedToReject": "Failed to reject the feature request",
- "failedToRemoveDirectory": "Failed to remove from the directory.",
+ "failedToRemoveDirectory": "Failed to remove from this instance.",
"failedToResendApproval": "Failed to resend the approval.",
"failedToUnfeature": "Failed to unfeature the stream",
"featureRequestApproved": "Feature request approved",
@@ -508,6 +508,11 @@
"overLimit": "Over limit",
"placeholder": "Your chat display name"
},
+ "OfflineRecommendation": {
+ "introduction": "While {{name}} is offline, visit this recommended stream.",
+ "linkAria": "Watch {{name}} live at {{host}}",
+ "watchLive": "Watch live"
+ },
"StreamsTab": {
"errorLoadingStreams": "Error loading streams",
"loadingStreams": "Loading featured streams...",
diff --git a/web/types/localization.ts b/web/types/localization.ts
index c916d36b0b..6aa5877a41 100644
--- a/web/types/localization.ts
+++ b/web/types/localization.ts
@@ -29,6 +29,11 @@ export const Localization = {
unmute: 'Frontend.unmute',
// Navigation and accessibility
+ OfflineRecommendation: {
+ introduction: 'Frontend.OfflineRecommendation.introduction',
+ linkAria: 'Frontend.OfflineRecommendation.linkAria',
+ watchLive: 'Frontend.OfflineRecommendation.watchLive',
+ },
skipToPlayer: 'Skip to player',
skipToContent: 'Skip to page content',
skipToFooter: 'Skip to footer',