Files
jitsi-meet/react/features/prejoin/components/web/country-picker/CountrySelector.tsx
Robert Pintilii d7cad9d560 feat(prejoin) Update design & refactor (#13089)
Update Dial Out Dialog design
Update Country Picker design
Convert some files to TS
Move styles from SCSS to JSS
Replace atlaskit InlineDialog with Popover in CountryPIcker and Prejoin components
2023-03-23 11:45:29 +02:00

78 lines
2.1 KiB
TypeScript

import React, { useCallback } from 'react';
import { makeStyles } from 'tss-react/mui';
import Icon from '../../../../base/icons/components/Icon';
import { IconArrowDown } from '../../../../base/icons/svg';
import { withPixelLineHeight } from '../../../../base/styles/functions.web';
interface IProps {
/**
* Country object of the entry.
*/
country: { code: string; dialCode: string; name: string; };
/**
* Click handler for the selector.
*/
onClick: () => void;
}
const useStyles = makeStyles()(theme => {
return {
container: {
padding: '8px 10px',
display: 'flex',
alignItems: 'center',
cursor: 'pointer',
backgroundColor: theme.palette.ui01,
borderRight: `1px solid ${theme.palette.ui03}`,
color: theme.palette.text01,
...withPixelLineHeight(theme.typography.bodyShortRegular),
position: 'relative',
width: '88px',
borderTopLeftRadius: theme.shape.borderRadius,
borderBottomLeftRadius: theme.shape.borderRadius
},
text: {
flexGrow: 1
},
flag: {
marginRight: theme.spacing(2)
}
};
});
/**
* This component displays the country selector with the flag.
*
* @returns {ReactElement}
*/
function CountrySelector({ country: { code, dialCode }, onClick }: IProps) {
const { classes, cx } = useStyles();
const onKeyPressHandler = useCallback(e => {
if (onClick && (e.key === ' ' || e.key === 'Enter')) {
e.preventDefault();
onClick();
}
}, [ onClick ]);
return (
<div
className = { classes.container }
onClick = { onClick }
onKeyPress = { onKeyPressHandler }>
<div className = { cx(classes.flag, 'iti-flag', code) } />
<span className = { classes.text }>{`+${dialCode}`}</span>
<Icon
size = { 16 }
src = { IconArrowDown } />
</div>
);
}
export default CountrySelector;