import { createSignal, For, lazy, Show } from 'solid-js' import { useLocalize } from '../../../context/localize' import { MediaItem } from '../../../pages/types' import { getDescription } from '../../../utils/meta' import { Icon } from '../../_shared/Icon' import { Popover } from '../../_shared/Popover' import { SharePopup, getShareUrl } from '../SharePopup' import styles from './AudioPlayer.module.scss' const SimplifiedEditor = lazy(() => import('../../Editor/SimplifiedEditor')) const GrowingTextarea = lazy(() => import('../../_shared/GrowingTextarea/GrowingTextarea')) type Props = { media: MediaItem[] currentTrackIndex: number isPlaying: boolean onPlayMedia: (trackIndex: number) => void articleSlug?: string body?: string editorMode?: boolean onMediaItemFieldChange?: (index: number, field: keyof MediaItem, value: string) => void onChangeMediaIndex?: (direction: 'up' | 'down', index) => void } export const PlayerPlaylist = (props: Props) => { const { t } = useLocalize() const [activeEditIndex, setActiveEditIndex] = createSignal(-1) const toggleDropDown = (index) => { setActiveEditIndex(activeEditIndex() === index ? -1 : index) } const handleMediaItemFieldChange = (field: keyof MediaItem, value: string) => { props.onMediaItemFieldChange(activeEditIndex(), field, value) } const titleStyle = (mi: MediaItem) => { let portion = 0 if (mi.artist) portion += 5 if (mi.title) portion += 5 return { 'max-width': `calc(${portion}0% - 16px)` } } return ( ) }