aboutsummaryrefslogtreecommitdiff
path: root/app/javascript/mastodon/components/icon_button.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/javascript/mastodon/components/icon_button.js')
-rw-r--r--app/javascript/mastodon/components/icon_button.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/app/javascript/mastodon/components/icon_button.js b/app/javascript/mastodon/components/icon_button.js
index fd715bc3c..7ec39198a 100644
--- a/app/javascript/mastodon/components/icon_button.js
+++ b/app/javascript/mastodon/components/icon_button.js
@@ -2,6 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import Icon from 'mastodon/components/icon';
+import AnimatedNumber from 'mastodon/components/animated_number';
export default class IconButton extends React.PureComponent {
@@ -24,6 +25,8 @@ export default class IconButton extends React.PureComponent {
animate: PropTypes.bool,
overlay: PropTypes.bool,
tabIndex: PropTypes.string,
+ counter: PropTypes.number,
+ obfuscateCount: PropTypes.bool,
};
static defaultProps = {
@@ -97,6 +100,8 @@ export default class IconButton extends React.PureComponent {
pressed,
tabIndex,
title,
+ counter,
+ obfuscateCount,
} = this.props;
const {
@@ -111,8 +116,13 @@ export default class IconButton extends React.PureComponent {
activate,
deactivate,
overlayed: overlay,
+ 'icon-button--with-counter': typeof counter !== 'undefined',
});
+ if (typeof counter !== 'undefined') {
+ style.width = 'auto';
+ }
+
return (
<button
aria-label={title}
@@ -128,7 +138,7 @@ export default class IconButton extends React.PureComponent {
tabIndex={tabIndex}
disabled={disabled}
>
- <Icon id={icon} fixedWidth aria-hidden='true' />
+ <Icon id={icon} fixedWidth aria-hidden='true' /> {typeof counter !== 'undefined' && <span className='icon-button__counter'><AnimatedNumber value={counter} obfuscate={obfuscateCount} /></span>}
</button>
);
}