2017-09-27 21:23:31 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2017-05-19 15:12:24 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
|
|
|
/**
|
2017-06-07 16:45:04 +00:00
|
|
|
* Implements a React {@link Component} to render a country flag icon.
|
2017-05-19 15:12:24 +00:00
|
|
|
*/
|
2017-06-07 16:45:04 +00:00
|
|
|
export default class CountryIcon extends Component {
|
2017-05-19 15:12:24 +00:00
|
|
|
/**
|
|
|
|
* {@code CountryIcon}'s property types.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*/
|
|
|
|
static propTypes = {
|
|
|
|
/**
|
|
|
|
* The css style class name.
|
|
|
|
*/
|
2017-09-27 21:23:31 +00:00
|
|
|
className: PropTypes.string,
|
2017-05-19 15:12:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The 2-letter country code.
|
|
|
|
*/
|
2017-09-27 21:23:31 +00:00
|
|
|
countryCode: PropTypes.string
|
2017-06-02 02:01:50 +00:00
|
|
|
};
|
2017-05-19 15:12:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
const iconClassName
|
2017-10-02 23:08:07 +00:00
|
|
|
= `flag-icon flag-icon-${
|
|
|
|
this.props.countryCode} flag-icon-squared ${
|
|
|
|
this.props.className}`;
|
2017-05-19 15:12:24 +00:00
|
|
|
|
|
|
|
return <span className = { iconClassName } />;
|
|
|
|
}
|
|
|
|
}
|