1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-06-30 13:41:54 +02:00
blog/src/components/Location/Flag.tsx

24 lines
475 B
TypeScript
Raw Normal View History

import styles from './index.module.css'
type Props = {
country: {
name: string
code: string
}
}
export function Flag({ country }: Props) {
// offset between uppercase ascii and regional indicator symbols
const OFFSET = 127397
const emoji = country?.code.replace(/./g, (char) =>
String.fromCodePoint(char.charCodeAt(0) + OFFSET)
)
return (
<span role="img" aria-label={country?.name} className={styles.emoji}>
{emoji}
</span>
)
}