UNPKG

@kiwicom/orbit-components

Version:

Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.

37 lines (35 loc) 1 kB
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", componentId: "h98fwe-0" })(["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;