diff --git a/stylesheets/components/StoryImage.scss b/stylesheets/components/StoryImage.scss index 391d96302ca5..a0a43b75d703 100644 --- a/stylesheets/components/StoryImage.scss +++ b/stylesheets/components/StoryImage.scss @@ -3,7 +3,6 @@ .StoryImage { align-items: center; - border-radius: 8px; display: flex; height: 100%; justify-content: center; diff --git a/stylesheets/components/StoryViewer.scss b/stylesheets/components/StoryViewer.scss index 781e2165b368..ae419de44c28 100644 --- a/stylesheets/components/StoryViewer.scss +++ b/stylesheets/components/StoryViewer.scss @@ -3,8 +3,7 @@ .StoryViewer { &__overlay { - background: $color-gray-95; - filter: blur(160px); + background-size: contain; height: 100vh; left: 0; position: absolute; @@ -15,6 +14,8 @@ &__content { align-items: center; + backdrop-filter: blur(90px); + background: $color-black-alpha-20; display: flex; flex-direction: column; height: 100vh; @@ -29,16 +30,19 @@ &__close-button { @include button-reset; @include modal-close-button; + right: 28px; top: var(--title-bar-drag-area-height); + z-index: $z-index-above-base; } &__more { @include button-reset; height: 24px; position: absolute; - right: 48px; + right: 80px; top: var(--title-bar-drag-area-height); width: 24px; + z-index: $z-index-above-base; @include color-svg('../images/icons/v2/more-horiz-24.svg', $color-white); @@ -51,14 +55,12 @@ &__container { flex-grow: 1; - margin-top: 36px; overflow: hidden; position: relative; z-index: $z-index-base; } &__story { - border-radius: 12px; max-height: 100%; outline: none; width: auto; @@ -67,7 +69,7 @@ &__meta { bottom: 0; left: 50%; - padding: 16px; + padding: 0 16px; position: absolute; transform: translateX(-50%); width: 284px; @@ -94,8 +96,10 @@ @include font-body-1-bold; color: $color-gray-05; padding: 4px 0; + margin-bottom: 24px; &__overlay { + @include button-reset; background: $color-black-alpha-60; height: 100%; left: 0; @@ -107,11 +111,9 @@ } &__actions { - align-items: center; display: flex; justify-content: center; - margin-bottom: 32px; - min-height: 52px; + min-height: 60px; } &__reply { diff --git a/ts/components/StoryViewer.stories.tsx b/ts/components/StoryViewer.stories.tsx index 0983ae0481de..ec30ba46dfba 100644 --- a/ts/components/StoryViewer.stories.tsx +++ b/ts/components/StoryViewer.stories.tsx @@ -122,3 +122,38 @@ story.add('So many stories', () => { /> ); }); + +story.add('Caption', () => ( + +)); + +story.add('Long Caption', () => ( + +)); diff --git a/ts/components/StoryViewer.tsx b/ts/components/StoryViewer.tsx index ee9805f0a9dc..5dc369ad423c 100644 --- a/ts/components/StoryViewer.tsx +++ b/ts/components/StoryViewer.tsx @@ -17,6 +17,7 @@ import { MessageTimestamp } from './conversation/MessageTimestamp'; import { StoryImage } from './StoryImage'; import { StoryViewsNRepliesModal } from './StoryViewsNRepliesModal'; import { getAvatarColor } from '../types/Colors'; +import { getStoryBackground } from '../util/getStoryBackground'; import { getStoryDuration } from '../util/getStoryDuration'; import { graphemeAwareSlice } from '../util/graphemeAwareSlice'; import { isDownloaded, isDownloading } from '../types/Attachment'; @@ -209,12 +210,12 @@ export const StoryViewer = ({ }, [currentStoryIndex, spring, storyDuration]); useEffect(() => { - if (hasReplyModal) { + if (hasReplyModal || hasExpandedCaption) { spring.pause(); } else { spring.resume(); } - }, [hasReplyModal, spring]); + }, [hasExpandedCaption, hasReplyModal, spring]); useEffect(() => { markStoryRead(messageId); @@ -273,21 +274,11 @@ export const StoryViewer = ({ return (
-
+
-
+
+ {isMe ? ( + <> + {viewCount && + (viewCount === 1 ? ( + {viewCount}]} + /> + ) : ( + {viewCount}]} + /> + ))} + {viewCount && replyCount && ' '} + {replyCount && + (replyCount === 1 ? ( + {replyCount}]} + /> + ) : ( + {replyCount}]} + /> + ))} + + ) : ( + canReply && ( + + ) + )} +
-
- {isMe ? ( - <> - {viewCount && - (viewCount === 1 ? ( - {viewCount}]} - /> - ) : ( - {viewCount}]} - /> - ))} - {viewCount && replyCount && ' '} - {replyCount && - (replyCount === 1 ? ( - {replyCount}]} - /> - ) : ( - {replyCount}]} - /> - ))} - - ) : ( - canReply && ( - - ) - )} -
+
{hasReplyModal && canReply && ( diff --git a/ts/util/getStoryBackground.ts b/ts/util/getStoryBackground.ts new file mode 100644 index 000000000000..1e5601f5b3c6 --- /dev/null +++ b/ts/util/getStoryBackground.ts @@ -0,0 +1,40 @@ +// Copyright 2022 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only + +import type { AttachmentType, TextAttachmentType } from '../types/Attachment'; + +const COLOR_BLACK_ALPHA_90 = 'rgba(0, 0, 0, 0.9)'; +const COLOR_WHITE_INT = 4294704123; + +export function getHexFromNumber(color: number): string { + return `#${color.toString(16).slice(2)}`; +} + +export function getBackgroundColor({ + color, + gradient, +}: TextAttachmentType): string { + if (gradient) { + return `linear-gradient(${gradient.angle}deg, ${getHexFromNumber( + gradient.startColor || COLOR_WHITE_INT + )}, ${getHexFromNumber(gradient.endColor || COLOR_WHITE_INT)})`; + } + + return getHexFromNumber(color || COLOR_WHITE_INT); +} + +export function getStoryBackground(attachment?: AttachmentType): string { + if (!attachment) { + return COLOR_BLACK_ALPHA_90; + } + + if (attachment.textAttachment) { + return getBackgroundColor(attachment.textAttachment); + } + + if (attachment.url) { + return `url("${attachment.url}")`; + } + + return COLOR_BLACK_ALPHA_90; +}