diff --git a/src/components/Badge/MediaBadge.tsx b/src/components/Badge/MediaBadge.tsx new file mode 100644 index 0000000000..52368cc127 --- /dev/null +++ b/src/components/Badge/MediaBadge.tsx @@ -0,0 +1,30 @@ +import { IconMicrophoneSolid, IconVideoFill } from '../Icons'; +import React, { type ComponentType } from 'react'; +import type { LocalAttachment } from 'stream-chat'; +import clsx from 'clsx'; + +export type MediaBadgeVariant = 'video' | 'voice-recording' | string; + +export type MediaBadgeProps = { + attachment: LocalAttachment; + variant: 'video' | 'voice-recording' | string; +}; + +const MediaBadgeVariantToIcon: Record = { + video: IconVideoFill, + voiceRecording: IconMicrophoneSolid, +}; + +export const MediaBadge = ({ attachment, variant }: MediaBadgeProps) => { + const Icon = MediaBadgeVariantToIcon[variant]; + return ( +
+ {Icon && } + {attachment.duration &&
{attachment.duration}
} +
+ ); +}; diff --git a/src/components/Badge/styling/MediaBadge.scss b/src/components/Badge/styling/MediaBadge.scss new file mode 100644 index 0000000000..2829040485 --- /dev/null +++ b/src/components/Badge/styling/MediaBadge.scss @@ -0,0 +1,21 @@ +.str-chat__media-badge { + display: flex; + align-items: center; + gap: var(--spacing-xxs); + position: absolute; + bottom: var(--spacing-xs); + inset-inline-start: var(--spacing-xs); + padding: var(--spacing-xxs) var(--spacing-xs); + border-radius: var(--radius-max); + background: var(--badge-bg-inverse); + color: var(--badge-text-on-inverse); + font: var(--str-chat__numeric-md-text); + overflow: hidden; + text-overflow: ellipsis; + + .str-chat__icon { + width: var(--icon-size-xs); + height: var(--icon-size-xs); + fill: currentColor; + } +} diff --git a/src/components/Badge/styling/index.scss b/src/components/Badge/styling/index.scss index 529a29758b..115e164434 100644 --- a/src/components/Badge/styling/index.scss +++ b/src/components/Badge/styling/index.scss @@ -1 +1,2 @@ @use 'Badge'; +@use 'MediaBadge'; diff --git a/src/components/Icons/icons.tsx b/src/components/Icons/icons.tsx index e77d0d4c3b..1722cd4061 100644 --- a/src/components/Icons/icons.tsx +++ b/src/components/Icons/icons.tsx @@ -633,6 +633,14 @@ export const IconVoice = createIcon( />, ); +export const IconMicrophoneSolid = createIcon( + 'IconMicrophoneSolid', + , +); + export const IconMute = createIcon( 'IconMute', > = UploadAttachmentPreviewProps< @@ -99,10 +100,7 @@ export const MediaAttachmentPreview = ({ {isVideoAttachment(attachment) && !hasUploadError && uploadState !== 'uploading' && ( -
- - {attachment.duration &&
{attachment.duration}
} -
+ )} {hasFatalError && } diff --git a/src/components/MessageComposer/styling/AttachmentPreview.scss b/src/components/MessageComposer/styling/AttachmentPreview.scss index 5336cd7814..217f60addd 100644 --- a/src/components/MessageComposer/styling/AttachmentPreview.scss +++ b/src/components/MessageComposer/styling/AttachmentPreview.scss @@ -160,28 +160,6 @@ object-fit: cover; } } - - .str-chat__attachment-preview-media__video-indicator { - display: flex; - align-items: center; - gap: var(--spacing-xxs); - position: absolute; - bottom: var(--spacing-xs); - inset-inline-start: var(--spacing-xs); - padding: var(--spacing-xxs) var(--spacing-xs); - border-radius: var(--radius-max); - background: var(--badge-bg-inverse); - color: var(--badge-text-on-inverse); - font: var(--str-chat__numeric-md-text); - overflow: hidden; - text-overflow: ellipsis; - - .str-chat__icon { - width: var(--icon-size-xs); - height: var(--icon-size-xs); - fill: currentColor; - } - } } .str-chat__attachment-preview-media__overlay { diff --git a/src/components/VideoPlayer/styling/VideoThumbnail.scss b/src/components/VideoPlayer/styling/VideoThumbnail.scss index 3efd17a6e4..c3594ab1f5 100644 --- a/src/components/VideoPlayer/styling/VideoThumbnail.scss +++ b/src/components/VideoPlayer/styling/VideoThumbnail.scss @@ -20,7 +20,7 @@ height: $size; width: $size; border-radius: var(--radius-max); - background-color: var(--control-play-control-bg); + background-color: var(--control-play-button-bg); left: calc(50% - calc($size / 2)); top: calc(50% - calc($size / 2)); @@ -29,7 +29,7 @@ width: calc($size / 2); path { - fill: var(--control-play-control-icon); + fill: var(--control-play-button-icon); } } } diff --git a/src/styling/variables-tokens.css b/src/styling/variables-tokens.css index 21b2481e69..aa29e52710 100644 --- a/src/styling/variables-tokens.css +++ b/src/styling/variables-tokens.css @@ -568,6 +568,8 @@ --badge-text: var(--text-primary); --badge-bg-default: #ffffff; --badge-text-on-accent: #ffffff; + --badge-text-on-inverse: #ffffff; + --badge-bg-inverse: var(--chrome-1000); /* ─── Control (remove, progress bar, toggle, playback, checkbox, play button, thumb, radio) ─── */ --control-remove-control-bg: #1a1b25;