From 06b606cec359fc61920f350af1bdf7dd7ea8d997 Mon Sep 17 00:00:00 2001 From: Josh Perez <60019601+josh-signal@users.noreply.github.com> Date: Fri, 8 Jul 2022 17:14:01 -0400 Subject: [PATCH] Story creator improvements --- stylesheets/components/TextAttachment.scss | 30 +++++++++++++++-- ts/components/StoryCreator.tsx | 11 ++++++- ts/components/TextAttachment.tsx | 33 +++++++++++++++---- .../conversation/StagedLinkPreview.tsx | 6 ++-- 4 files changed, 69 insertions(+), 11 deletions(-) diff --git a/stylesheets/components/TextAttachment.scss b/stylesheets/components/TextAttachment.scss index 8555411682cf..7cc4023793d6 100644 --- a/stylesheets/components/TextAttachment.scss +++ b/stylesheets/components/TextAttachment.scss @@ -58,6 +58,12 @@ } } + &__preview-container { + position: relative; + margin-left: 72px; + margin-right: 72px; + } + &__preview { align-items: center; background: $color-black-alpha-40; @@ -66,10 +72,30 @@ flex-direction: row; height: 122px; justify-content: center; - margin-left: 72px; - margin-right: 72px; padding: 34px; + &__remove { + backdrop-filter: blur(26px); + background: $color-black-alpha-40; + border-radius: 100%; + height: 48px; + position: absolute; + right: -16px; + top: -16px; + width: 48px; + z-index: $z-index-base; + + button { + @include button-reset; + height: 24px; + position: absolute; + right: 12px; + top: 12px; + width: 24px; + @include color-svg('../images/icons/v2/x-24.svg', $color-gray-15); + } + } + .TextAttachment__preview-container--large & { height: 192px; } diff --git a/ts/components/StoryCreator.tsx b/ts/components/StoryCreator.tsx index af7913c7f889..64b404b28f33 100644 --- a/ts/components/StoryCreator.tsx +++ b/ts/components/StoryCreator.tsx @@ -104,7 +104,7 @@ export const StoryCreator = ({ const [textBackground, setTextBackground] = useState( TextBackground.None ); - const [sliderValue, setSliderValue] = useState(0); + const [sliderValue, setSliderValue] = useState(100); const [text, setText] = useState(''); const textEditorRef = useRef(null); @@ -234,9 +234,18 @@ export const StoryCreator = ({
{ + if (!isEditingText) { + setIsEditingText(true); + } + }} + onRemoveLinkPreview={() => { + setHasLinkPreviewApplied(false); + }} textAttachment={{ ...getBackground(selectedBackground), text, diff --git a/ts/components/TextAttachment.tsx b/ts/components/TextAttachment.tsx index e1780218d29d..2def7c509e45 100644 --- a/ts/components/TextAttachment.tsx +++ b/ts/components/TextAttachment.tsx @@ -41,10 +41,13 @@ enum TextSize { } export type PropsType = { + disableLinkPreviewPopup?: boolean; i18n: LocalizerType; isEditingText?: boolean; isThumbnail?: boolean; onChange?: (text: string) => unknown; + onClick?: () => unknown; + onRemoveLinkPreview?: () => unknown; textAttachment: TextAttachmentType; }; @@ -102,10 +105,13 @@ function getTextStyles( } export const TextAttachment = ({ + disableLinkPreviewPopup, i18n, isEditingText, isThumbnail, onChange, + onClick, + onRemoveLinkPreview, textAttachment, }: PropsType): JSX.Element | null => { const linkPreview = useRef(null); @@ -137,6 +143,7 @@ export const TextAttachment = ({ if (linkPreviewOffsetTop) { setLinkPreviewOffsetTop(undefined); } + onClick?.(); }} onKeyUp={ev => { if (ev.key === 'Escape' && linkPreviewOffsetTop) { @@ -222,17 +229,31 @@ export const TextAttachment = ({ ), })} ref={linkPreview} - onFocus={() => - setLinkPreviewOffsetTop(linkPreview?.current?.offsetTop) - } - onMouseOver={() => - setLinkPreviewOffsetTop(linkPreview?.current?.offsetTop) - } + onFocus={() => { + if (!disableLinkPreviewPopup) { + setLinkPreviewOffsetTop(linkPreview?.current?.offsetTop); + } + }} + onMouseOver={() => { + if (!disableLinkPreviewPopup) { + setLinkPreviewOffsetTop(linkPreview?.current?.offsetTop); + } + }} > + {onRemoveLinkPreview && ( +
+
+ )} void; }; @@ -25,6 +26,7 @@ export const StagedLinkPreview: React.FC = ({ domain, i18n, image, + imageSize, moduleClassName, onClose, title, @@ -58,10 +60,10 @@ export const StagedLinkPreview: React.FC = ({ curveBottomRight={CurveType.Tiny} curveTopLeft={CurveType.Tiny} curveTopRight={CurveType.Tiny} - height={72} + height={imageSize || 72} i18n={i18n} url={image.url} - width={72} + width={imageSize || 72} />
) : null}