diff --git a/app/soapbox/components/media_gallery.js b/app/soapbox/components/media_gallery.js index 0fc7dcb67..3eda57795 100644 --- a/app/soapbox/components/media_gallery.js +++ b/app/soapbox/components/media_gallery.js @@ -6,6 +6,7 @@ import { is } from 'immutable'; import IconButton from './icon_button'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import { isIOS } from '../is_mobile'; +import { truncateFilename } from 'soapbox/utils/media'; import classNames from 'classnames'; import { decode } from 'blurhash'; import { isPanoramic, isPortrait, isNonConformingRatio, minimumAspectRatio, maximumAspectRatio } from '../utils/media_aspect_ratio'; @@ -14,6 +15,8 @@ import { getSettings } from 'soapbox/actions/settings'; import Icon from 'soapbox/components/icon'; import StillImage from 'soapbox/components/still_image'; +const MAX_FILENAME_LENGTH = 45; + const messages = defineMessages({ toggle_visible: { id: 'media_gallery.toggle_visible', defaultMessage: 'Toggle visibility' }, }); @@ -142,19 +145,8 @@ class Item extends React.PureComponent { let thumbnail = ''; - const MAX_FILENAME_LENGTH = 45; - const getCroppedFilename = () => { - const remoteURL = attachment.get('remote_url'); - const filenameLastIndex = remoteURL.lastIndexOf('/'); - const filename = remoteURL.substr(filenameLastIndex + 1); - if (filename.length <= MAX_FILENAME_LENGTH) - return filename; - else - return filename.substr(0, MAX_FILENAME_LENGTH/2) + '...' + filename.substr(filename.length - MAX_FILENAME_LENGTH/2); - }; - if (attachment.get('type') === 'unknown') { - const filename = getCroppedFilename(); + const filename = truncateFilename(attachment.get('remote_url'), MAX_FILENAME_LENGTH); return (
diff --git a/app/soapbox/utils/media.js b/app/soapbox/utils/media.js new file mode 100644 index 000000000..c8266c646 --- /dev/null +++ b/app/soapbox/utils/media.js @@ -0,0 +1,10 @@ +export const truncateFilename = (url, maxLength) => { + const filename = url.split('/').pop(); + + if (filename.length <= maxLength) return filename; + + return [ + filename.substr(0, maxLength/2), + filename.substr(filename.length - maxLength/2), + ].join('…'); +}; diff --git a/app/styles/chats.scss b/app/styles/chats.scss index 38550ac3b..49719a638 100644 --- a/app/styles/chats.scss +++ b/app/styles/chats.scss @@ -181,10 +181,64 @@ } .chat-box { + .upload-progress { + padding: 0 10px; + align-items: center; + height: 25px; + + .fa { + font-size: 22px; + } + + &__message { + font-size: 13px; + flex: 1; + align-items: center; + } + + &__backdrop { + margin-top: 2px; + } + } + + &__attachment { + display: flex; + align-items: center; + font-size: 13px; + padding: 0 10px; + height: 25px; + + .chat-box__remove-attachment { + margin-left: auto; + + .icon-button > div { + display: flex; + align-items: center; + } + } + } + &__actions { background: var(--foreground-color); margin-top: auto; padding: 6px; + position: relative; + + .icon-button { + position: absolute; + right: 10px; + top: 8px; + width: auto; + height: auto; + background: transparent !important; + border: 0; + padding: 0; + margin: 0; + } + + .chat-box__send .icon-button { + top: 12px; + } textarea { width: 100%; @@ -192,11 +246,13 @@ margin: 0; box-sizing: border-box; padding: 6px; + padding-right: 25px; background: var(--background-color); border: 0; border-radius: 6px; color: var(--primary-text-color); font-size: 15px; + overflow: hidden; } } } @@ -290,3 +346,27 @@ } } } + +.chat-message .media-gallery { + height: auto !important; + margin: 4px 0 8px; + + .spoiler-button { + display: none; + } + + .media-gallery__item:not(.media-gallery__item--image) { + max-width: 100%; + width: 120px !important; + height: 70px !important; + } + + &__preview { + background-color: transparent; + } + + &__item-thumbnail img, + &__item-thumbnail .still-image img { + object-fit: contain; + } +}