forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change status content markup to match upstream (#2923)
* Remove option to have media outside of CWs Upstream adopted the media-in-CW design glitch-soc originally had. * Move poll to StatusContent * Refactor status media icons * Rename `forceFilter` to `showDespiteFilter` for consistency with upstream * Change media and status content markup to match upstream's * Add mention placeholders back
- Loading branch information
1 parent
5e65586
commit b7afca0
Showing
11 changed files
with
232 additions
and
330 deletions.
There are no files selected for viewing
12 changes: 10 additions & 2 deletions
12
app/javascript/flavours/glitch/components/content_warning.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
import type { IconName } from './media_icon'; | ||
import { MediaIcon } from './media_icon'; | ||
import { StatusBanner, BannerVariant } from './status_banner'; | ||
|
||
export const ContentWarning: React.FC<{ | ||
text: string; | ||
expanded?: boolean; | ||
onClick?: () => void; | ||
icons?: React.ReactNode[]; | ||
icons?: IconName[]; | ||
}> = ({ text, expanded, onClick, icons }) => ( | ||
<StatusBanner | ||
expanded={expanded} | ||
onClick={onClick} | ||
variant={BannerVariant.Warning} | ||
> | ||
{icons} | ||
{icons?.map((icon) => ( | ||
<MediaIcon | ||
className='status__content__spoiler-icon' | ||
icon={icon} | ||
key={`icon-${icon}`} | ||
/> | ||
))} | ||
<p dangerouslySetInnerHTML={{ __html: text }} /> | ||
</StatusBanner> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { defineMessages, useIntl } from 'react-intl'; | ||
|
||
import ImageIcon from '@/material-icons/400-24px/image.svg?react'; | ||
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 { Icon } from 'flavours/glitch/components/icon'; | ||
|
||
const messages = defineMessages({ | ||
link: { | ||
id: 'status.has_preview_card', | ||
defaultMessage: 'Features an attached preview card', | ||
}, | ||
'picture-o': { | ||
id: 'status.has_pictures', | ||
defaultMessage: 'Features attached pictures', | ||
}, | ||
tasks: { id: 'status.is_poll', defaultMessage: 'This toot is a poll' }, | ||
'video-camera': { | ||
id: 'status.has_video', | ||
defaultMessage: 'Features attached videos', | ||
}, | ||
music: { | ||
id: 'status.has_audio', | ||
defaultMessage: 'Features attached audio files', | ||
}, | ||
}); | ||
|
||
const iconComponents = { | ||
link: LinkIcon, | ||
'picture-o': ImageIcon, | ||
tasks: InsertChartIcon, | ||
'video-camera': MovieIcon, | ||
music: MusicNoteIcon, | ||
}; | ||
|
||
export type IconName = keyof typeof iconComponents; | ||
|
||
export const MediaIcon: React.FC<{ | ||
className?: string; | ||
icon: IconName; | ||
}> = ({ className, icon }) => { | ||
const intl = useIntl(); | ||
|
||
return ( | ||
<Icon | ||
className={className} | ||
id={icon} | ||
icon={iconComponents[icon]} | ||
title={intl.formatMessage(messages[icon])} | ||
aria-hidden='true' | ||
/> | ||
); | ||
}; |
29 changes: 29 additions & 0 deletions
29
app/javascript/flavours/glitch/components/mentions_placeholder.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import ImmutablePropTypes from 'react-immutable-proptypes'; | ||
|
||
import { Permalink } from 'flavours/glitch/components/permalink'; | ||
|
||
export const MentionsPlaceholder = ({ status }) => { | ||
if (status.get('spoiler_text').length === 0 || !status.get('mentions')) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className='status__content'> | ||
{status.get('mentions').map(item => ( | ||
<Permalink | ||
to={`/@${item.get('acct')}`} | ||
href={item.get('url')} | ||
key={item.get('id')} | ||
className='mention' | ||
> | ||
@<span>{item.get('username')}</span> | ||
</Permalink> | ||
)).reduce((aggregate, item) => [...aggregate, item, ' '], [])} | ||
</div> | ||
); | ||
}; | ||
|
||
MentionsPlaceholder.propTypes = { | ||
status: ImmutablePropTypes.map.isRequired, | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.