1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-06-28 08:37:57 +02:00
blog/src/components/Location/Flag.tsx
Matthias Kretschmann 3b25ae2282
Location fetching (#843)
* location component

* fetching with @nanostores/query

* layouts reorg

* typescript plugins cleanup

* location component unit test cases

* fetch only when visible
2023-10-04 14:45:54 +01:00

24 lines
475 B
TypeScript

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>
)
}