UNPKG

jobiqo-cl

Version:

[![CircleCI](https://circleci.com/gh/jobiqo/jobiqo-cl.svg?style=svg&circle-token=5a24efa5b8bbc4879276123e77d0d3f35ca7144c)](https://circleci.com/gh/jobiqo/jobiqo-cl)

47 lines (44 loc) 2.08 kB
import React__default from 'react'; import { AtIcon } from '../../../icons/At.js'; import { DeIcon } from '../../../icons/De.js'; import { PtIcon } from '../../../icons/Pt.js'; import { UkIcon } from '../../../icons/Uk.js'; import { UsIcon } from '../../../icons/Us.js'; import { MenuItem } from '../../../../node_modules/@reach/menu-button/es/index.js'; import MenuDropdownButton from '../04-navigation/01-menu-button/index.js'; /** * @file index.tsx * * @fileoverview Renders a country menu button used to toggle between different countries. */ const getCountry = (country) => { switch (country) { case 'at': return React__default.createElement(AtIcon, { title: "Austria", height: "30", width: "30" }); case 'de': return React__default.createElement(DeIcon, { title: "Germany", height: "30", width: "30" }); case 'pt': return React__default.createElement(PtIcon, { title: "Portugal", height: "30", width: "30" }); case 'uk': return React__default.createElement(UkIcon, { title: "United Kingdom", height: "30", width: "30" }); case 'us': return React__default.createElement(UsIcon, { title: "United States", height: "30", width: "30" }); } }; const CountrySwitch = ({ countries, currentCountry, onSelectCountry, showLabel }) => { let currentSelectedCountry; if (currentCountry) { currentSelectedCountry = countries.filter(c => c.name === currentCountry)[0]; } else { currentSelectedCountry = countries[0]; } return (React__default.createElement(MenuDropdownButton, { styledButton: false, button: getCountry(currentSelectedCountry.name) }, countries.map(country => { return (React__default.createElement(MenuItem, { key: country.name, onSelect: () => { onSelectCountry(country.name); } }, getCountry(country.name), showLabel && React__default.createElement("span", null, country.title))); }))); }; export { CountrySwitch };