mirror of
https://github.com/kremalicious/blog.git
synced 2024-06-30 13:41:54 +02:00
* location component * fetching with @nanostores/query * layouts reorg * typescript plugins cleanup * location component unit test cases * fetch only when visible
24 lines
475 B
TypeScript
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>
|
|
)
|
|
}
|