2018-05-16 14:00:16 +00:00
|
|
|
// @flow
|
|
|
|
|
2018-05-22 19:44:40 +00:00
|
|
|
import React from 'react';
|
2018-05-16 14:00:16 +00:00
|
|
|
|
2020-05-18 11:54:55 +00:00
|
|
|
import Icon from '../../icons/components/Icon';
|
|
|
|
|
2018-05-22 19:44:40 +00:00
|
|
|
import AbstractCircularLabel, {
|
|
|
|
type Props as AbstractProps
|
|
|
|
} from './AbstractCircularLabel';
|
2018-05-16 14:00:16 +00:00
|
|
|
|
2018-05-22 19:44:40 +00:00
|
|
|
type Props = AbstractProps & {
|
2018-05-16 14:00:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Additional CSS class names to add to the root of {@code CircularLabel}.
|
|
|
|
*/
|
|
|
|
className: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* HTML ID attribute to add to the root of {@code CircularLabel}.
|
|
|
|
*/
|
|
|
|
id: string
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* React Component for showing short text in a circle.
|
|
|
|
*
|
|
|
|
* @extends Component
|
|
|
|
*/
|
2018-09-11 10:16:01 +00:00
|
|
|
export default class CircularLabel extends AbstractCircularLabel<Props, {}> {
|
2018-05-16 14:00:16 +00:00
|
|
|
/**
|
|
|
|
* Default values for {@code CircularLabel} component's properties.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*/
|
|
|
|
static defaultProps = {
|
|
|
|
className: ''
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
className,
|
2020-05-18 11:54:55 +00:00
|
|
|
icon,
|
2018-05-22 19:44:40 +00:00
|
|
|
id,
|
|
|
|
label
|
2018-05-16 14:00:16 +00:00
|
|
|
} = this.props;
|
|
|
|
|
2020-05-18 11:54:55 +00:00
|
|
|
const labelComponent = icon
|
|
|
|
? (
|
|
|
|
<Icon
|
|
|
|
src = { icon } />
|
|
|
|
) : label;
|
|
|
|
|
2018-05-16 14:00:16 +00:00
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className = { `circular-label ${className}` }
|
|
|
|
id = { id }>
|
2020-05-18 11:54:55 +00:00
|
|
|
{ labelComponent }
|
2018-05-16 14:00:16 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|