Skip to content

Commit

Permalink
Show country names with flag
Browse files Browse the repository at this point in the history
Refs #31
  • Loading branch information
thewilkybarkid committed Jul 9, 2024
1 parent 607d5a2 commit f02513c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/users.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ toc: false
```js
const parseTimestamp = d3.utcParse('%Y-%m-%dT%H:%M:%SZ')

const regionNames = new Intl.DisplayNames(['en-US'], { type: 'region' })
const regionName = code => regionNames.of(code)

const getFlagEmoji = code =>
String.fromCodePoint(
...code
.toUpperCase()
.split('')
.map(char => 127397 + char.charCodeAt()),
)

const regionNameWithFlag = code => `${getFlagEmoji(code)} ${regionName(code)}`

const careerStage = id => {
switch (id) {
case 'early':
Expand Down Expand Up @@ -136,7 +149,7 @@ function usersByCareerStage({ width } = {}) {
function usersByLocation() {
return Inputs.table(
usersInTimePeriod.flatMap(user => (user.location ? { location: user.location, country: user.country } : [])),
{ header: { country: 'Country', location: 'Location' }, sort: 'location' },
{ format: { country: regionNameWithFlag }, header: { country: 'Country', location: 'Location' }, sort: 'location' },
)
}
```
Expand Down

0 comments on commit f02513c

Please sign in to comment.