diff --git a/packages/manager/.changeset/pr-9288-added-1687360493313.md b/packages/manager/.changeset/pr-9288-added-1687360493313.md new file mode 100644 index 00000000000..cae93f6f088 --- /dev/null +++ b/packages/manager/.changeset/pr-9288-added-1687360493313.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Added +--- + +Outline to some country flags ([#9288](https://github.com/linode/manager/pull/9288)) diff --git a/packages/manager/src/components/EnhancedSelect/variants/RegionSelect/RegionSelect.tsx b/packages/manager/src/components/EnhancedSelect/variants/RegionSelect/RegionSelect.tsx index 5b60c070c56..6bda044fb0e 100644 --- a/packages/manager/src/components/EnhancedSelect/variants/RegionSelect/RegionSelect.tsx +++ b/packages/manager/src/components/EnhancedSelect/variants/RegionSelect/RegionSelect.tsx @@ -8,7 +8,7 @@ import { _SingleValue } from 'src/components/EnhancedSelect/components/SingleVal import { Region } from '@linode/api-v4/lib/regions'; import { RegionOption, RegionItem } from './RegionOption'; import { Flag } from 'src/components/Flag'; -import { ContinentNames } from './utils'; +import { ContinentNames, Country } from './utils'; import { getRegionCountryGroup } from 'src/utilities/formatRegion'; interface Props @@ -49,7 +49,7 @@ export const getRegionOptions = (regions: Region[]) => { groups[group].push({ label: `${region.label} (${region.id})`, value: region.id, - flag: , + flag: } />, country: region.country, }); } diff --git a/packages/manager/src/components/EnhancedSelect/variants/RegionSelect/utils.ts b/packages/manager/src/components/EnhancedSelect/variants/RegionSelect/utils.ts index fbf836fa492..bf15f09adc7 100644 --- a/packages/manager/src/components/EnhancedSelect/variants/RegionSelect/utils.ts +++ b/packages/manager/src/components/EnhancedSelect/variants/RegionSelect/utils.ts @@ -254,6 +254,8 @@ export const COUNTRY_CODE_TO_CONTINENT_CODE = Object.freeze({ ZW: 'AF', }); +export type Country = keyof typeof COUNTRY_CODE_TO_CONTINENT_CODE; + export const CONTINENT_CODE_TO_CONTINENT = Object.freeze({ EU: 'Europe', AS: 'Asia', diff --git a/packages/manager/src/components/Flag.stories.tsx b/packages/manager/src/components/Flag.stories.tsx new file mode 100644 index 00000000000..1c2b2c8be88 --- /dev/null +++ b/packages/manager/src/components/Flag.stories.tsx @@ -0,0 +1,19 @@ +import React from 'react'; +import { Meta, StoryObj } from '@storybook/react'; +import { Flag } from './Flag'; + +const meta: Meta = { + title: 'Components/Flag', + component: Flag, +}; + +type Story = StoryObj; + +export const Default: Story = { + render: (args) => , + args: { + country: 'us', + }, +}; + +export default meta; diff --git a/packages/manager/src/components/Flag.tsx b/packages/manager/src/components/Flag.tsx index bb836146138..79eb58a141d 100644 --- a/packages/manager/src/components/Flag.tsx +++ b/packages/manager/src/components/Flag.tsx @@ -1,21 +1,33 @@ import React from 'react'; import 'flag-icons/css/flag-icons.min.css'; +import { Country } from './EnhancedSelect/variants/RegionSelect/utils'; +import { styled } from '@mui/material/styles'; -const countryFlagOverrides = { +const COUNTRY_FLAG_OVERRIDES = { uk: 'gb', }; interface Props { - /** expects a iso code of a country - `us`, `ca`, etc... */ - country: string; + country: Lowercase; } +/** + * Flag icons are provided by the [flag-icons](https://www.npmjs.com/package/flag-icon) package + */ export const Flag = (props: Props) => { const country = props.country.toLowerCase(); + return ( -
); }; + +const StyledFlag = styled('div', { label: 'StyledFlag' })(({ theme }) => ({ + fontSize: '1.5rem', + boxShadow: + theme.palette.mode === 'light' ? `0px 0px 0px 1px #00000010` : undefined, + verticalAlign: 'top', + width: '1.41rem', +})); diff --git a/packages/manager/src/features/Linodes/MigrateLinode/ConfigureForm.tsx b/packages/manager/src/features/Linodes/MigrateLinode/ConfigureForm.tsx index 0dc40f397fa..97970415e37 100644 --- a/packages/manager/src/features/Linodes/MigrateLinode/ConfigureForm.tsx +++ b/packages/manager/src/features/Linodes/MigrateLinode/ConfigureForm.tsx @@ -7,6 +7,7 @@ import { RegionSelect } from 'src/components/EnhancedSelect/variants/RegionSelec import { useRegionsQuery } from 'src/queries/regions'; import { getRegionCountryGroup } from 'src/utilities/formatRegion'; import { Flag } from 'src/components/Flag'; +import { Country } from 'src/components/EnhancedSelect/variants/RegionSelect/utils'; const useStyles = makeStyles((theme: Theme) => ({ root: { @@ -53,7 +54,7 @@ const ConfigureForm = (props: Props) => { Configure Migration Current Region
- + } /> {`${getRegionCountryGroup(currentActualRegion)}: ${ currentActualRegion?.label ?? currentRegion }`} diff --git a/packages/manager/src/utilities/formatRegion.ts b/packages/manager/src/utilities/formatRegion.ts index 213abbac83e..ab19af5d1b4 100644 --- a/packages/manager/src/utilities/formatRegion.ts +++ b/packages/manager/src/utilities/formatRegion.ts @@ -2,6 +2,7 @@ import { Region } from '@linode/api-v4'; import { COUNTRY_CODE_TO_CONTINENT_CODE, CONTINENT_CODE_TO_CONTINENT, + Country, } from 'src/components/EnhancedSelect/variants/RegionSelect/utils'; export const getRegionCountryGroup = (region: Region | undefined) => { @@ -10,9 +11,7 @@ export const getRegionCountryGroup = (region: Region | undefined) => { } const continentCode = - COUNTRY_CODE_TO_CONTINENT_CODE[ - region.country.toUpperCase() as keyof typeof COUNTRY_CODE_TO_CONTINENT_CODE - ]; + COUNTRY_CODE_TO_CONTINENT_CODE[region.country.toUpperCase() as Country]; return continentCode ? CONTINENT_CODE_TO_CONTINENT[continentCode] ?? 'Other'