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

54 lines
2.0 KiB
TypeScript
Raw Normal View History

2021-01-24 01:22:28 -08:00
import React from 'react';
import { Select } from "antd";
2021-01-23 20:16:01 -08:00
import { SocialHandleDropdownItem } from "../../../types/config-section";
2021-01-19 10:34:06 -08:00
import { NEXT_PUBLIC_API_HOST } from '../../../utils/apis';
2021-01-24 01:22:28 -08:00
import { OTHER_SOCIAL_HANDLE_OPTION } from './constants';
2021-01-19 10:34:06 -08:00
interface DropdownProps {
2021-01-23 20:16:01 -08:00
iconList: SocialHandleDropdownItem[];
2021-01-24 01:22:28 -08:00
selectedOption: string;
onSelected: any;
2021-01-19 10:34:06 -08:00
}
2021-01-24 01:22:28 -08:00
export default function SocialDropdown({ iconList, selectedOption, onSelected }: DropdownProps) {
2021-01-19 10:34:06 -08:00
2021-01-24 01:22:28 -08:00
const handleSelected = value => {
if (onSelected) {
onSelected(value);
}
2021-01-19 10:34:06 -08:00
};
2021-01-24 01:22:28 -08:00
const inititalSelected = selectedOption === '' ? null : selectedOption;
2021-01-19 10:34:06 -08:00
return (
<div className="social-dropdown-container">
2021-01-24 01:22:28 -08:00
<p className="">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>
<p className="">If you DO have a logo, drop it in to the <code>/webroot/img/platformicons</code> directory and update the <code>/socialHandle.go</code> list. Then restart the server and it will show up in the list.</p>
2021-01-19 10:34:06 -08:00
<Select
style={{ width: 240 }}
className="social-dropdown"
placeholder="Social platform..."
2021-01-24 01:22:28 -08:00
defaultValue={inititalSelected}
value={inititalSelected}
onSelect={handleSelected}
2021-01-19 10:34:06 -08:00
>
{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>
);
})
}
2021-01-24 01:22:28 -08:00
<Select.Option className="social-option" key={`platform-${OTHER_SOCIAL_HANDLE_OPTION}`} value={OTHER_SOCIAL_HANDLE_OPTION}>
Other...
</Select.Option>
2021-01-19 10:34:06 -08:00
</Select>
</div>
);
}