owncast/web/components/config/social-icons-dropdown.tsx

64 lines
2.1 KiB
TypeScript
Raw Normal View History

2021-01-24 12:22:28 +03:00
import React from 'react';
2021-01-31 12:38:20 +03:00
import { Select } from 'antd';
import { SocialHandleDropdownItem } from '../../types/config-section';
import { NEXT_PUBLIC_API_HOST } from '../../utils/apis';
import { OTHER_SOCIAL_HANDLE_OPTION } from '../../utils/config-constants';
2021-01-19 21:34:06 +03:00
interface DropdownProps {
2021-01-24 07:16:01 +03:00
iconList: SocialHandleDropdownItem[];
2021-01-24 12:22:28 +03:00
selectedOption: string;
onSelected: any;
2021-01-19 21:34:06 +03:00
}
2021-01-24 12:22:28 +03:00
export default function SocialDropdown({ iconList, selectedOption, onSelected }: DropdownProps) {
const handleSelected = (value: string) => {
2021-01-24 12:22:28 +03:00
if (onSelected) {
onSelected(value);
}
2021-01-19 21:34:06 +03:00
};
2021-01-24 12:22:28 +03:00
const inititalSelected = selectedOption === '' ? null : selectedOption;
2021-01-19 21:34:06 +03:00
return (
<div className="social-dropdown-container">
<p className="description">
2021-01-31 12:38:20 +03:00
If you are looking for a platform name not on this list, please select Other and type in
your own name. A logo will not be provided.
</p>
<div className="formfield-container">
<div className="label-side">
<span className="formfield-label">Social Platform</span>
</div>
<div className="input-side">
<Select
style={{ width: 240 }}
className="social-dropdown"
placeholder="Social platform..."
defaultValue={inititalSelected}
value={inititalSelected}
onSelect={handleSelected}
>
{iconList.map(item => {
const { platform, icon, key } = item;
return (
<Select.Option className="social-option" key={`platform-${key}`} value={key}>
<span className="option-icon">
<img src={`${NEXT_PUBLIC_API_HOST}${icon}`} alt="" className="option-icon" />
</span>
<span className="option-label">{platform}</span>
</Select.Option>
);
})}
<Select.Option
className="social-option"
key={`platform-${OTHER_SOCIAL_HANDLE_OPTION}`}
value={OTHER_SOCIAL_HANDLE_OPTION}
>
Other...
2021-01-19 21:34:06 +03:00
</Select.Option>
</Select>
</div>
</div>
2021-01-19 21:34:06 +03:00
</div>
);
}