@kiwicom/orbit-components
Version:
<div align="center"> <a href="https://orbit.kiwi" target="_blank"> <img alt="orbit-components" src="https://orbit.kiwi/wp-content/uploads/2018/08/orbit-components.png" srcset="https://orbit.kiwi/wp-content/uploads/2018/08/orbit-components@2x.png 2x"
27 lines (22 loc) • 956 B
JavaScript
import * as React from "react";
import styled from "styled-components";
import defaultTokens from "../defaultTokens";
import { baseURL, CODES } from "./consts";
const StyledCountryFlag = styled.img.withConfig({
displayName: "CountryFlag__StyledCountryFlag"
})(["height:", ";width:", ";border-radius:", ";background-color:", ";"], ({ theme }) => theme.orbit.heightCountryFlag, ({ theme }) => theme.orbit.widthCountryFlag, ({ theme }) => theme.orbit.borderRadiusSmall, ({ theme }) => theme.orbit.backgroundCountryFlag);
StyledCountryFlag.defaultProps = {
theme: defaultTokens
};
const CountryFlag = props => {
const { code = CODES.ANYWHERE, name = "Anywhere", dataTest } = props;
return React.createElement(StyledCountryFlag, {
key: code,
src: `${baseURL}/flags/24x0/flag-${code}.jpg`,
srcSet: `${baseURL}/flags/48x0/flag-${code}.jpg 2x`,
alt: name,
title: name,
"data-test": dataTest
});
};
export default CountryFlag;