Merge branch 'media-rounded' into 'develop'

Improve rounded courners in MediaGallery and Chats

See merge request soapbox-pub/soapbox!2310
This commit is contained in:
Alex Gleason 2023-02-24 16:06:40 +00:00
commit b7c1d7d44a
3 changed files with 33 additions and 8 deletions

View File

@ -152,7 +152,14 @@ const Item: React.FC<IItem> = ({
); );
return ( return (
<div className={clsx('media-gallery__item', { standalone })} key={attachment.id} style={{ position, float, left, top, right, bottom, height, width: `${width}%` }}> <div
className={clsx('media-gallery__item', {
standalone,
'rounded-md': total > 1,
})}
key={attachment.id}
style={{ position, float, left, top, right, bottom, height, width: `${width}%` }}
>
<a className='media-gallery__item-thumbnail' href={attachment.url} target='_blank' style={{ cursor: 'pointer' }}> <a className='media-gallery__item-thumbnail' href={attachment.url} target='_blank' style={{ cursor: 'pointer' }}>
<Blurhash hash={attachment.blurhash} className='media-gallery__preview' /> <Blurhash hash={attachment.blurhash} className='media-gallery__preview' />
<span className='media-gallery__item__icons'>{attachmentIcon}</span> <span className='media-gallery__item__icons'>{attachmentIcon}</span>
@ -245,7 +252,14 @@ const Item: React.FC<IItem> = ({
} }
return ( return (
<div className={clsx('media-gallery__item', `media-gallery__item--${attachment.type}`, { standalone })} key={attachment.id} style={{ position, float, left, top, right, bottom, height, width: `${width}%` }}> <div
className={clsx('media-gallery__item', `media-gallery__item--${attachment.type}`, {
standalone,
'rounded-md': total > 1,
})}
key={attachment.id}
style={{ position, float, left, top, right, bottom, height, width: `${width}%` }}
>
{last && total > ATTACHMENT_LIMIT && ( {last && total > ATTACHMENT_LIMIT && (
<div className='media-gallery__item-overflow'> <div className='media-gallery__item-overflow'>
+{total - ATTACHMENT_LIMIT + 1} +{total - ATTACHMENT_LIMIT + 1}
@ -260,7 +274,7 @@ const Item: React.FC<IItem> = ({
); );
}; };
interface IMediaGallery { export interface IMediaGallery {
sensitive?: boolean sensitive?: boolean
media: ImmutableList<Attachment> media: ImmutableList<Attachment>
height?: number height?: number
@ -270,13 +284,15 @@ interface IMediaGallery {
visible?: boolean visible?: boolean
onToggleVisibility?: () => void onToggleVisibility?: () => void
displayMedia?: string displayMedia?: string
compact: boolean compact?: boolean
className?: string
} }
const MediaGallery: React.FC<IMediaGallery> = (props) => { const MediaGallery: React.FC<IMediaGallery> = (props) => {
const { const {
media, media,
defaultWidth = 0, defaultWidth = 0,
className,
onOpenMedia, onOpenMedia,
cacheWidth, cacheWidth,
compact, compact,
@ -546,7 +562,11 @@ const MediaGallery: React.FC<IMediaGallery> = (props) => {
}, [node.current]); }, [node.current]);
return ( return (
<div className={clsx('media-gallery', { 'media-gallery--compact': compact })} style={sizeData.style} ref={node}> <div
className={clsx(className, 'media-gallery', { 'media-gallery--compact': compact })}
style={sizeData.style}
ref={node}
>
{children} {children}
</div> </div>
); );

View File

@ -23,6 +23,7 @@ import ChatMessageReaction from './chat-message-reaction';
import ChatMessageReactionWrapper from './chat-message-reaction-wrapper/chat-message-reaction-wrapper'; import ChatMessageReactionWrapper from './chat-message-reaction-wrapper/chat-message-reaction-wrapper';
import type { Menu as IMenu } from 'soapbox/components/dropdown-menu'; import type { Menu as IMenu } from 'soapbox/components/dropdown-menu';
import type { IMediaGallery } from 'soapbox/components/media-gallery';
import type { ChatMessage as ChatMessageEntity } from 'soapbox/types/entities'; import type { ChatMessage as ChatMessageEntity } from 'soapbox/types/entities';
const messages = defineMessages({ const messages = defineMessages({
@ -112,8 +113,12 @@ const ChatMessage = (props: IChatMessage) => {
return ( return (
<Bundle fetchComponent={MediaGallery}> <Bundle fetchComponent={MediaGallery}>
{(Component: any) => ( {(Component: React.FC<IMediaGallery>) => (
<Component <Component
className={clsx({
'rounded-br-sm': isMyMessage && content,
'rounded-bl-sm': !isMyMessage && content,
})}
media={chatMessage.media_attachments} media={chatMessage.media_attachments}
onOpenMedia={onOpenMedia} onOpenMedia={onOpenMedia}
visible visible

View File

@ -1,21 +1,21 @@
$media-compact-size: 50px; $media-compact-size: 50px;
.media-gallery { .media-gallery {
@apply rounded-lg;
box-sizing: border-box; box-sizing: border-box;
overflow: hidden; overflow: hidden;
border-radius: 10px;
isolation: isolate; isolation: isolate;
position: relative; position: relative;
width: 100%; width: 100%;
height: auto; height: auto;
&__item { &__item {
@apply rounded-sm;
border: 0; border: 0;
box-sizing: border-box; box-sizing: border-box;
display: block; display: block;
float: left; float: left;
position: relative; position: relative;
border-radius: 10px;
overflow: hidden; overflow: hidden;
&__icons { &__icons {