kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Rename justEmojis to onlyEmoji
rodzic
561c275c60
commit
2082c19c53
|
@ -9,7 +9,7 @@ import classnames from 'classnames';
|
||||||
import Icon from 'soapbox/components/icon';
|
import Icon from 'soapbox/components/icon';
|
||||||
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
|
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
|
||||||
import { addGreentext } from 'soapbox/utils/greentext';
|
import { addGreentext } from 'soapbox/utils/greentext';
|
||||||
import { justEmojis } from 'soapbox/utils/rich_content';
|
import { onlyEmoji } from 'soapbox/utils/rich_content';
|
||||||
|
|
||||||
const MAX_HEIGHT = 642; // 20px * 32 (+ 2px padding at the top)
|
const MAX_HEIGHT = 642; // 20px * 32 (+ 2px padding at the top)
|
||||||
const BIG_EMOJI_LIMIT = 10;
|
const BIG_EMOJI_LIMIT = 10;
|
||||||
|
@ -90,16 +90,16 @@ class StatusContent extends React.PureComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setJustEmojis = () => {
|
setOnlyEmoji = () => {
|
||||||
if (this.node && this.state.justEmojis === undefined) {
|
if (this.node && this.state.onlyEmoji === undefined) {
|
||||||
this.setState({ justEmojis: justEmojis(this.node, BIG_EMOJI_LIMIT) });
|
this.setState({ onlyEmoji: onlyEmoji(this.node, BIG_EMOJI_LIMIT) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh = () => {
|
refresh = () => {
|
||||||
this.setCollapse();
|
this.setCollapse();
|
||||||
this._updateStatusLinks();
|
this._updateStatusLinks();
|
||||||
this.setJustEmojis();
|
this.setOnlyEmoji();
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
@ -183,7 +183,7 @@ class StatusContent extends React.PureComponent {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { status } = this.props;
|
const { status } = this.props;
|
||||||
const { justEmojis } = this.state;
|
const { onlyEmoji } = this.state;
|
||||||
|
|
||||||
if (status.get('content').length === 0) {
|
if (status.get('content').length === 0) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -198,7 +198,7 @@ class StatusContent extends React.PureComponent {
|
||||||
'status__content--with-action': this.props.onClick && this.context.router,
|
'status__content--with-action': this.props.onClick && this.context.router,
|
||||||
'status__content--with-spoiler': status.get('spoiler_text').length > 0,
|
'status__content--with-spoiler': status.get('spoiler_text').length > 0,
|
||||||
'status__content--collapsed': this.state.collapsed === true,
|
'status__content--collapsed': this.state.collapsed === true,
|
||||||
'status__content--big': justEmojis,
|
'status__content--big': onlyEmoji,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isRtl(status.get('search_index'))) {
|
if (isRtl(status.get('search_index'))) {
|
||||||
|
@ -265,7 +265,7 @@ class StatusContent extends React.PureComponent {
|
||||||
tabIndex='0'
|
tabIndex='0'
|
||||||
ref={this.setRef}
|
ref={this.setRef}
|
||||||
className={classnames('status__content', {
|
className={classnames('status__content', {
|
||||||
'status__content--big': justEmojis,
|
'status__content--big': onlyEmoji,
|
||||||
})}
|
})}
|
||||||
style={directionStyle}
|
style={directionStyle}
|
||||||
dangerouslySetInnerHTML={content}
|
dangerouslySetInnerHTML={content}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import Bundle from 'soapbox/features/ui/components/bundle';
|
||||||
import DropdownMenuContainer from 'soapbox/containers/dropdown_menu_container';
|
import DropdownMenuContainer from 'soapbox/containers/dropdown_menu_container';
|
||||||
import { initReportById } from 'soapbox/actions/reports';
|
import { initReportById } from 'soapbox/actions/reports';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import { justEmojis } from 'soapbox/utils/rich_content';
|
import { onlyEmoji } from 'soapbox/utils/rich_content';
|
||||||
|
|
||||||
const BIG_EMOJI_LIMIT = 1;
|
const BIG_EMOJI_LIMIT = 1;
|
||||||
|
|
||||||
|
@ -124,8 +124,10 @@ class ChatMessageList extends ImmutablePureComponent {
|
||||||
link.setAttribute('target', '_blank');
|
link.setAttribute('target', '_blank');
|
||||||
});
|
});
|
||||||
|
|
||||||
if (justEmojis(c, BIG_EMOJI_LIMIT)) {
|
if (onlyEmoji(c, BIG_EMOJI_LIMIT)) {
|
||||||
c.classList.add('chat-message__bubble--onlyEmoji');
|
c.classList.add('chat-message__bubble--onlyEmoji');
|
||||||
|
} else {
|
||||||
|
c.classList.remove('chat-message__bubble--onlyEmoji');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
// Returns `true` if the node contains only emojis, up to a limit
|
// Returns `true` if the node contains only emojis, up to a limit
|
||||||
export const justEmojis = (node, limit = 1) => {
|
export const onlyEmoji = (node, limit = 1) => {
|
||||||
if (!node) return false;
|
if (!node) return false;
|
||||||
if (node.textContent.replaceAll(' ', '') !== '') return false;
|
if (node.textContent.replaceAll(' ', '') !== '') return false;
|
||||||
const emojis = [...node.querySelectorAll('img.emojione')];
|
const emojis = [...node.querySelectorAll('img.emojione')];
|
||||||
|
if (emojis.length === 0) return false;
|
||||||
if (emojis.length > limit) return false;
|
if (emojis.length > limit) return false;
|
||||||
const images = [...node.querySelectorAll('img')];
|
const images = [...node.querySelectorAll('img')];
|
||||||
if (images.length > emojis.length) return false;
|
if (images.length > emojis.length) return false;
|
||||||
|
|
|
@ -165,7 +165,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
&--onlyEmoji {
|
&--onlyEmoji {
|
||||||
background: transparent;
|
background: transparent !important;
|
||||||
|
|
||||||
img.emojione {
|
img.emojione {
|
||||||
width: 36px !important;
|
width: 36px !important;
|
||||||
|
|
Ładowanie…
Reference in New Issue