A small module that exports country lists used by Comic Relief's frontend components. Country data comes from the popular npm country-list
package.
npm i @comicrelief/country-lists
# or
yarn add @comicrelief/country-lists
ALL_COUNTRIES
Includes every country as provided by the popular npm package country-list
.
UK_AND_CHANNEL_ISLES
Includes the United Kingdom and its Crown Dependencies: the Isle of Man, Jersey, and Guernsey.
-
.getSelectItems()
: returns the required{ value, displayValue }
objects for the current<Select>
component from ourhttps://github.com/comicrelief/component-library
repo. -
.getLegacySelectItems()
: returns the required{ label, value }
objects for the legacySelectField
component from ourhttps://github.com/comicrelief/storybook
repo. -
.getNames()
: returns a plain list of country names.
import { Select } from "@comicrelief/component-library";
import { ALL_COUNTRIES } from '@comicrelief/country-lists'
...
<Select
label="country"
description="Please choose your country"
options={ ALL_COUNTRIES.getSelectItems() }
/>
import { SelectField } from '@comicrelief/storybook';
import { ALL_COUNTRIES } from '@comicrelief/country-lists';
...
// Adding a Label to the imported country list package
const selectLabel = { label: 'Please choose your country', selected: true };
const countryDataWithLabel = ALL_COUNTRIES.getLegacySelectItems();
countryDataWithLabel.unshift(selectLabel);
<SelectField
...
options={ countryDataWithLabel }
/>