summaryrefslogtreecommitdiffstats
path: root/front/odiparpack/app/components/Badges/LimitedBadges.js
blob: a0e0ecd0de5324c77685b57fa9439b6467179a7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { Badge } from '@material-ui/core';

class LimitedBadges extends PureComponent {
  render() {
    const {
      children,
      limit,
      value,
      ...rest
    } = this.props;
    return (
      <Badge badgeContent={value > limit ? limit + '+' : value} {...rest}>
        { children }
      </Badge>
    );
  }
}

LimitedBadges.propTypes = {
  children: PropTypes.node.isRequired,
  value: PropTypes.number.isRequired,
  limit: PropTypes.number.isRequired,
};

export default LimitedBadges;