From b02c80341b106a00f89a673d7d2d13dd8204dd64 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 30 May 2022 14:05:15 -0500 Subject: [PATCH] ReplyIndicator: convert to TSX --- app/soapbox/components/ui/text/text.tsx | 9 ++- .../compose/components/reply_indicator.js | 70 ------------------- .../compose/components/reply_indicator.tsx | 62 ++++++++++++++++ 3 files changed, 70 insertions(+), 71 deletions(-) delete mode 100644 app/soapbox/features/compose/components/reply_indicator.js create mode 100644 app/soapbox/features/compose/components/reply_indicator.tsx diff --git a/app/soapbox/components/ui/text/text.tsx b/app/soapbox/components/ui/text/text.tsx index 072491109..f7513595f 100644 --- a/app/soapbox/components/ui/text/text.tsx +++ b/app/soapbox/components/ui/text/text.tsx @@ -9,6 +9,7 @@ type TrackingSizes = 'normal' | 'wide' type TransformProperties = 'uppercase' | 'normal' type Families = 'sans' | 'mono' type Tags = 'abbr' | 'p' | 'span' | 'pre' | 'time' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'label' +type Directions = 'ltr' | 'rtl' const themes = { default: 'text-gray-900 dark:text-gray-100', @@ -64,6 +65,8 @@ interface IText extends Pick, 'danger align?: Alignments, /** Extra class names for the outer element. */ className?: string, + /** Text direction. */ + direction?: Directions, /** Typeface of the text. */ family?: Families, /** The "for" attribute specifies which form element a label is bound to. */ @@ -90,6 +93,7 @@ const Text: React.FC = React.forwardRef( const { align, className, + direction, family = 'sans', size = 'md', tag = 'p', @@ -109,7 +113,10 @@ const Text: React.FC = React.forwardRef( { - this.props.onCancel(); - } - - render() { - const { status, hideActions } = this.props; - - if (!status) { - return null; - } - - const style = { - direction: isRtl(status.get('search_index')) ? 'rtl' : 'ltr', - }; - - let actions = {}; - if (!hideActions) { - actions = { - onActionClick: this.handleClick, - actionIcon: require('@tabler/icons/icons/x.svg'), - actionAlignment: 'top', - actionTitle: 'Dismiss', - }; - } - - return ( - - - - - - {status.get('media_attachments').size > 0 && ( - - )} - - ); - } - -} diff --git a/app/soapbox/features/compose/components/reply_indicator.tsx b/app/soapbox/features/compose/components/reply_indicator.tsx new file mode 100644 index 000000000..ebe7c8637 --- /dev/null +++ b/app/soapbox/features/compose/components/reply_indicator.tsx @@ -0,0 +1,62 @@ +import React from 'react'; + +import AttachmentThumbs from 'soapbox/components/attachment-thumbs'; +import { Stack, Text } from 'soapbox/components/ui'; +import AccountContainer from 'soapbox/containers/account_container'; + +import { isRtl } from '../../../rtl'; + +import type { Status } from 'soapbox/types/entities'; + +interface IReplyIndicator { + status?: Status, + onCancel: () => void, + hideActions: boolean, +} + +const ReplyIndicator: React.FC = ({ status, hideActions, onCancel }) => { + const handleClick = () => { + onCancel(); + }; + + + if (!status) { + return null; + } + + let actions = {}; + if (!hideActions) { + actions = { + onActionClick: handleClick, + actionIcon: require('@tabler/icons/icons/x.svg'), + actionAlignment: 'top', + actionTitle: 'Dismiss', + }; + } + + return ( + + + + + + {status.media_attachments.size > 0 && ( + + )} + + ); +}; + +export default ReplyIndicator;