ReplyIndicator: convert to TSX
This commit is contained in:
parent
6e2cc63b7d
commit
b02c80341b
|
@ -9,6 +9,7 @@ type TrackingSizes = 'normal' | 'wide'
|
||||||
type TransformProperties = 'uppercase' | 'normal'
|
type TransformProperties = 'uppercase' | 'normal'
|
||||||
type Families = 'sans' | 'mono'
|
type Families = 'sans' | 'mono'
|
||||||
type Tags = 'abbr' | 'p' | 'span' | 'pre' | 'time' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'label'
|
type Tags = 'abbr' | 'p' | 'span' | 'pre' | 'time' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'label'
|
||||||
|
type Directions = 'ltr' | 'rtl'
|
||||||
|
|
||||||
const themes = {
|
const themes = {
|
||||||
default: 'text-gray-900 dark:text-gray-100',
|
default: 'text-gray-900 dark:text-gray-100',
|
||||||
|
@ -64,6 +65,8 @@ interface IText extends Pick<React.HTMLAttributes<HTMLParagraphElement>, 'danger
|
||||||
align?: Alignments,
|
align?: Alignments,
|
||||||
/** Extra class names for the outer element. */
|
/** Extra class names for the outer element. */
|
||||||
className?: string,
|
className?: string,
|
||||||
|
/** Text direction. */
|
||||||
|
direction?: Directions,
|
||||||
/** Typeface of the text. */
|
/** Typeface of the text. */
|
||||||
family?: Families,
|
family?: Families,
|
||||||
/** The "for" attribute specifies which form element a label is bound to. */
|
/** The "for" attribute specifies which form element a label is bound to. */
|
||||||
|
@ -90,6 +93,7 @@ const Text: React.FC<IText> = React.forwardRef(
|
||||||
const {
|
const {
|
||||||
align,
|
align,
|
||||||
className,
|
className,
|
||||||
|
direction,
|
||||||
family = 'sans',
|
family = 'sans',
|
||||||
size = 'md',
|
size = 'md',
|
||||||
tag = 'p',
|
tag = 'p',
|
||||||
|
@ -109,7 +113,10 @@ const Text: React.FC<IText> = React.forwardRef(
|
||||||
<Comp
|
<Comp
|
||||||
{...filteredProps}
|
{...filteredProps}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
style={tag === 'abbr' ? { textDecoration: 'underline dotted' } : undefined}
|
style={{
|
||||||
|
textDecoration: tag === 'abbr' ? 'underline dotted' : undefined,
|
||||||
|
direction,
|
||||||
|
}}
|
||||||
className={classNames({
|
className={classNames({
|
||||||
'cursor-default': tag === 'abbr',
|
'cursor-default': tag === 'abbr',
|
||||||
truncate: truncate,
|
truncate: truncate,
|
||||||
|
|
|
@ -1,70 +0,0 @@
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import React from 'react';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
||||||
|
|
||||||
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';
|
|
||||||
|
|
||||||
export default class ReplyIndicator extends ImmutablePureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
status: ImmutablePropTypes.record,
|
|
||||||
onCancel: PropTypes.func.isRequired,
|
|
||||||
hideActions: PropTypes.bool,
|
|
||||||
};
|
|
||||||
|
|
||||||
handleClick = () => {
|
|
||||||
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 (
|
|
||||||
<Stack space={2} className='p-4 rounded-lg bg-gray-100 dark:bg-slate-700'>
|
|
||||||
<AccountContainer
|
|
||||||
{...actions}
|
|
||||||
id={status.getIn(['account', 'id'])}
|
|
||||||
timestamp={status.get('created_at')}
|
|
||||||
showProfileHoverCard={false}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Text
|
|
||||||
size='sm'
|
|
||||||
dangerouslySetInnerHTML={{ __html: status.get('contentHtml') }}
|
|
||||||
style={style}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{status.get('media_attachments').size > 0 && (
|
|
||||||
<AttachmentThumbs
|
|
||||||
media={status.get('media_attachments')}
|
|
||||||
sensitive={status.get('sensitive')}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -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<IReplyIndicator> = ({ 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 (
|
||||||
|
<Stack space={2} className='p-4 rounded-lg bg-gray-100 dark:bg-slate-700'>
|
||||||
|
<AccountContainer
|
||||||
|
{...actions}
|
||||||
|
id={status.getIn(['account', 'id']) as string}
|
||||||
|
timestamp={status.created_at}
|
||||||
|
showProfileHoverCard={false}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Text
|
||||||
|
size='sm'
|
||||||
|
dangerouslySetInnerHTML={{ __html: status.contentHtml }}
|
||||||
|
direction={isRtl(status.search_index) ? 'rtl' : 'ltr'}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{status.media_attachments.size > 0 && (
|
||||||
|
<AttachmentThumbs
|
||||||
|
media={status.media_attachments}
|
||||||
|
sensitive={status.sensitive}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ReplyIndicator;
|
Loading…
Reference in New Issue