SocialDropdown.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import React, { FC } from 'react';
  2. import { Select } from 'antd';
  3. import { SocialHandleDropdownItem } from '../../types/config-section';
  4. import { OTHER_SOCIAL_HANDLE_OPTION } from '../../utils/config-constants';
  5. export type DropdownProps = {
  6. iconList: SocialHandleDropdownItem[];
  7. selectedOption: string;
  8. onSelected: any;
  9. };
  10. export const SocialDropdown: FC<DropdownProps> = ({ iconList, selectedOption, onSelected }) => {
  11. const handleSelected = (value: string) => {
  12. if (onSelected) {
  13. onSelected(value);
  14. }
  15. };
  16. const inititalSelected = selectedOption === '' ? null : selectedOption;
  17. return (
  18. <div className="social-dropdown-container">
  19. <p className="description">
  20. If you are looking for a platform name not on this list, please select Other and type in
  21. your own name. A logo will not be provided.
  22. </p>
  23. <div className="formfield-container">
  24. <div className="label-side">
  25. <span className="formfield-label">Social Platform</span>
  26. </div>
  27. <div className="input-side">
  28. <Select
  29. style={{ width: 240 }}
  30. className="social-dropdown"
  31. placeholder="Social platform..."
  32. defaultValue={inititalSelected}
  33. value={inititalSelected}
  34. onSelect={handleSelected}
  35. >
  36. {iconList.map(item => {
  37. const { platform, icon, key } = item;
  38. return (
  39. <Select.Option className="social-option" key={`platform-${key}`} value={key}>
  40. <span className="option-icon">
  41. <img src={icon} alt="" className="option-icon" />
  42. </span>
  43. <span className="option-label">{platform}</span>
  44. </Select.Option>
  45. );
  46. })}
  47. <Select.Option
  48. className="social-option"
  49. key={`platform-${OTHER_SOCIAL_HANDLE_OPTION}`}
  50. value={OTHER_SOCIAL_HANDLE_OPTION}
  51. >
  52. Other...
  53. </Select.Option>
  54. </Select>
  55. </div>
  56. </div>
  57. </div>
  58. );
  59. };