You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CountryRow.tsx 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import React from 'react';
  2. import { makeStyles } from 'tss-react/mui';
  3. import { withPixelLineHeight } from '../../../../base/styles/functions.web';
  4. interface IProps {
  5. /**
  6. * Country of the entry.
  7. */
  8. country: { code: string; dialCode: string; name: string; };
  9. /**
  10. * Entry click handler.
  11. */
  12. onEntryClick: Function;
  13. }
  14. const useStyles = makeStyles()(theme => {
  15. return {
  16. container: {
  17. display: 'flex',
  18. padding: '10px',
  19. alignItems: 'center',
  20. backgroundColor: theme.palette.action03,
  21. '&:hover': {
  22. backgroundColor: theme.palette.action03Hover
  23. }
  24. },
  25. flag: {
  26. marginRight: theme.spacing(2)
  27. },
  28. text: {
  29. color: theme.palette.text01,
  30. ...withPixelLineHeight(theme.typography.bodyShortRegular),
  31. flexGrow: 1,
  32. overflow: 'hidden',
  33. textOverflow: 'ellipsis',
  34. whiteSpace: 'nowrap'
  35. }
  36. };
  37. });
  38. const CountryRow = ({ country, onEntryClick }: IProps) => {
  39. const { classes, cx } = useStyles();
  40. const _onClick = () => {
  41. onEntryClick(country);
  42. };
  43. return (
  44. <div
  45. className = { classes.container }
  46. // eslint-disable-next-line react/jsx-no-bind
  47. onClick = { _onClick }>
  48. <div className = { cx(classes.flag, 'iti-flag', country.code) } />
  49. <div className = { classes.text }>
  50. {`${country.name} (+${country.dialCode})`}
  51. </div>
  52. </div>
  53. );
  54. };
  55. export default CountryRow;