diff --git a/app/javascript/flavours/glitch/components/content_warning.tsx b/app/javascript/flavours/glitch/components/content_warning.tsx new file mode 100644 index 0000000000..82f9ca83ed --- /dev/null +++ b/app/javascript/flavours/glitch/components/content_warning.tsx @@ -0,0 +1,27 @@ +/* Significantly rewritten from upstream to keep the old design for now */ + +import { FormattedMessage } from 'react-intl'; + +export const ContentWarning: React.FC<{ + text: string; + expanded?: boolean; + onClick?: () => void; + icons?: React.ReactNode[]; +}> = ({ text, expanded, onClick, icons }) => ( +

+ {' '} + +

+); diff --git a/app/javascript/flavours/glitch/components/filter_warning.tsx b/app/javascript/flavours/glitch/components/filter_warning.tsx new file mode 100644 index 0000000000..4305e43038 --- /dev/null +++ b/app/javascript/flavours/glitch/components/filter_warning.tsx @@ -0,0 +1,23 @@ +import { FormattedMessage } from 'react-intl'; + +import { StatusBanner, BannerVariant } from './status_banner'; + +export const FilterWarning: React.FC<{ + title: string; + expanded?: boolean; + onClick?: () => void; +}> = ({ title, expanded, onClick }) => ( + +

+ +

+
+); diff --git a/app/javascript/flavours/glitch/components/status_banner.tsx b/app/javascript/flavours/glitch/components/status_banner.tsx new file mode 100644 index 0000000000..8ff17a9b2e --- /dev/null +++ b/app/javascript/flavours/glitch/components/status_banner.tsx @@ -0,0 +1,37 @@ +import { FormattedMessage } from 'react-intl'; + +export enum BannerVariant { + Yellow = 'yellow', + Blue = 'blue', +} + +export const StatusBanner: React.FC<{ + children: React.ReactNode; + variant: BannerVariant; + expanded?: boolean; + onClick?: () => void; +}> = ({ children, variant, expanded, onClick }) => ( +
+ {children} + + +
+); diff --git a/app/javascript/flavours/glitch/components/status_content.jsx b/app/javascript/flavours/glitch/components/status_content.jsx index 634ab0db29..d6dfd9f490 100644 --- a/app/javascript/flavours/glitch/components/status_content.jsx +++ b/app/javascript/flavours/glitch/components/status_content.jsx @@ -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 MovieIcon from '@/material-icons/400-24px/movie.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 { identityContextPropShape, withIdentity } from 'flavours/glitch/identity_context'; 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 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 classNames = classnames('status__content', { 'status__content--with-action': parseClick && !disabled, @@ -375,45 +376,26 @@ class StatusContent extends PureComponent { )).reduce((aggregate, item) => [...aggregate, item, ' '], []); - let toggleText = null; - if (hidden) { - toggleText = [ - , - ]; - if (mediaIcons) { - const mediaComponents = { - 'link': LinkIcon, - 'picture-o': ImageIcon, - 'tasks': InsertChartIcon, - 'video-camera': MovieIcon, - 'music': MusicNoteIcon, - }; + let spoilerIcons = []; + if (hidden && mediaIcons) { + const mediaComponents = { + 'link': LinkIcon, + 'picture-o': ImageIcon, + 'tasks': InsertChartIcon, + 'video-camera': MovieIcon, + 'music': MusicNoteIcon, + }; - mediaIcons.forEach((mediaIcon, idx) => { - toggleText.push( -