36 lines
700 B
TypeScript
36 lines
700 B
TypeScript
import { Box } from './Box';
|
|
|
|
export interface CountryFlagProps {
|
|
countryCode: string;
|
|
size?: 'sm' | 'md' | 'lg';
|
|
}
|
|
|
|
export const CountryFlag = ({
|
|
countryCode,
|
|
size = 'md'
|
|
}: CountryFlagProps) => {
|
|
const sizeMap = {
|
|
sm: '1rem',
|
|
md: '1.5rem',
|
|
lg: '2rem',
|
|
};
|
|
|
|
return (
|
|
<Box
|
|
width={sizeMap[size]}
|
|
height={sizeMap[size]}
|
|
display="flex"
|
|
alignItems="center"
|
|
justifyContent="center"
|
|
overflow="hidden"
|
|
style={{ borderRadius: '2px' }}
|
|
>
|
|
<img
|
|
src={`https://flagcdn.com/w40/${countryCode.toLowerCase()}.png`}
|
|
alt={countryCode}
|
|
className="w-full h-full object-cover"
|
|
/>
|
|
</Box>
|
|
);
|
|
};
|