mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-25 21:21:36 +01:00
Use new CW class in more places
This commit is contained in:
parent
4d754935a9
commit
7c148ed1cb
2 changed files with 24 additions and 48 deletions
|
@ -6,7 +6,8 @@ export const ContentWarning: React.FC<{
|
||||||
text: string;
|
text: string;
|
||||||
expanded?: boolean;
|
expanded?: boolean;
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
}> = ({ text, expanded, onClick }) => (
|
icons?: React.ReactNode[];
|
||||||
|
}> = ({ text, expanded, onClick, icons }) => (
|
||||||
<p>
|
<p>
|
||||||
<span dangerouslySetInnerHTML={{ __html: text }} className='translate' />{' '}
|
<span dangerouslySetInnerHTML={{ __html: text }} className='translate' />{' '}
|
||||||
<button
|
<button
|
||||||
|
@ -20,6 +21,7 @@ export const ContentWarning: React.FC<{
|
||||||
) : (
|
) : (
|
||||||
<FormattedMessage id='status.show_more' defaultMessage='Show more' />
|
<FormattedMessage id='status.show_more' defaultMessage='Show more' />
|
||||||
)}
|
)}
|
||||||
|
{icons}
|
||||||
</button>
|
</button>
|
||||||
</p>
|
</p>
|
||||||
);
|
);
|
||||||
|
|
|
@ -14,6 +14,7 @@ import InsertChartIcon from '@/material-icons/400-24px/insert_chart.svg?react';
|
||||||
import LinkIcon from '@/material-icons/400-24px/link.svg?react';
|
import LinkIcon from '@/material-icons/400-24px/link.svg?react';
|
||||||
import MovieIcon from '@/material-icons/400-24px/movie.svg?react';
|
import MovieIcon from '@/material-icons/400-24px/movie.svg?react';
|
||||||
import MusicNoteIcon from '@/material-icons/400-24px/music_note.svg?react';
|
import MusicNoteIcon from '@/material-icons/400-24px/music_note.svg?react';
|
||||||
|
import { ContentWarning } from 'flavours/glitch/components/content_warning';
|
||||||
import { Icon } from 'flavours/glitch/components/icon';
|
import { Icon } from 'flavours/glitch/components/icon';
|
||||||
import { identityContextPropShape, withIdentity } from 'flavours/glitch/identity_context';
|
import { identityContextPropShape, withIdentity } from 'flavours/glitch/identity_context';
|
||||||
import { autoPlayGif, languages as preloadedLanguages } from 'flavours/glitch/initial_state';
|
import { autoPlayGif, languages as preloadedLanguages } from 'flavours/glitch/initial_state';
|
||||||
|
@ -350,7 +351,7 @@ class StatusContent extends PureComponent {
|
||||||
const renderTranslate = this.props.onTranslate && this.props.identity.signedIn && ['public', 'unlisted'].includes(status.get('visibility')) && status.get('search_index').trim().length > 0 && targetLanguages?.includes(contentLocale);
|
const renderTranslate = this.props.onTranslate && this.props.identity.signedIn && ['public', 'unlisted'].includes(status.get('visibility')) && status.get('search_index').trim().length > 0 && targetLanguages?.includes(contentLocale);
|
||||||
|
|
||||||
const content = { __html: statusContent ?? getStatusContent(status) };
|
const content = { __html: statusContent ?? getStatusContent(status) };
|
||||||
const spoilerContent = { __html: status.getIn(['translation', 'spoilerHtml']) || status.get('spoilerHtml') };
|
const spoilerHtml = status.getIn(['translation', 'spoilerHtml']) || status.get('spoilerHtml');
|
||||||
const language = status.getIn(['translation', 'language']) || status.get('language');
|
const language = status.getIn(['translation', 'language']) || status.get('language');
|
||||||
const classNames = classnames('status__content', {
|
const classNames = classnames('status__content', {
|
||||||
'status__content--with-action': parseClick && !disabled,
|
'status__content--with-action': parseClick && !disabled,
|
||||||
|
@ -375,45 +376,26 @@ class StatusContent extends PureComponent {
|
||||||
</Permalink>
|
</Permalink>
|
||||||
)).reduce((aggregate, item) => [...aggregate, item, ' '], []);
|
)).reduce((aggregate, item) => [...aggregate, item, ' '], []);
|
||||||
|
|
||||||
let toggleText = null;
|
let spoilerIcons = [];
|
||||||
if (hidden) {
|
if (hidden && mediaIcons) {
|
||||||
toggleText = [
|
const mediaComponents = {
|
||||||
<FormattedMessage
|
'link': LinkIcon,
|
||||||
id='status.show_more'
|
'picture-o': ImageIcon,
|
||||||
defaultMessage='Show more'
|
'tasks': InsertChartIcon,
|
||||||
key='0'
|
'video-camera': MovieIcon,
|
||||||
/>,
|
'music': MusicNoteIcon,
|
||||||
];
|
};
|
||||||
if (mediaIcons) {
|
|
||||||
const mediaComponents = {
|
|
||||||
'link': LinkIcon,
|
|
||||||
'picture-o': ImageIcon,
|
|
||||||
'tasks': InsertChartIcon,
|
|
||||||
'video-camera': MovieIcon,
|
|
||||||
'music': MusicNoteIcon,
|
|
||||||
};
|
|
||||||
|
|
||||||
mediaIcons.forEach((mediaIcon, idx) => {
|
spoilerIcons = mediaIcons.map((mediaIcon) => (
|
||||||
toggleText.push(
|
<Icon
|
||||||
<Icon
|
fixedWidth
|
||||||
fixedWidth
|
className='status__content__spoiler-icon'
|
||||||
className='status__content__spoiler-icon'
|
id={mediaIcon}
|
||||||
id={mediaIcon}
|
icon={mediaComponents[mediaIcon]}
|
||||||
icon={mediaComponents[mediaIcon]}
|
aria-hidden='true'
|
||||||
aria-hidden='true'
|
key={`icon-${mediaIcon}`}
|
||||||
key={`icon-${idx}`}
|
|
||||||
/>,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
toggleText = (
|
|
||||||
<FormattedMessage
|
|
||||||
id='status.show_less'
|
|
||||||
defaultMessage='Show less'
|
|
||||||
key='0'
|
|
||||||
/>
|
/>
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hidden) {
|
if (hidden) {
|
||||||
|
@ -422,15 +404,7 @@ class StatusContent extends PureComponent {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames} tabIndex={0} onMouseDown={this.handleMouseDown} onMouseUp={this.handleMouseUp}>
|
<div className={classNames} tabIndex={0} onMouseDown={this.handleMouseDown} onMouseUp={this.handleMouseUp}>
|
||||||
<p
|
<ContentWarning text={spoilerHtml} expanded={!hidden} onClick={this.handleSpoilerClick} icons={spoilerIcons} />
|
||||||
style={{ marginBottom: hidden && status.get('mentions').isEmpty() ? '0px' : null }}
|
|
||||||
>
|
|
||||||
<span dangerouslySetInnerHTML={spoilerContent} className='translate' lang={language} />
|
|
||||||
{' '}
|
|
||||||
<button type='button' className='status__content__spoiler-link' onClick={this.handleSpoilerClick} aria-expanded={!hidden}>
|
|
||||||
{toggleText}
|
|
||||||
</button>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
{mentionsPlaceholder}
|
{mentionsPlaceholder}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue