import React, { useMemo } from 'react'; import { HMSPlaylistItem } from '@100mslive/hms-video-store'; import { Text } from '../Text'; import { useHMSTheme } from '../../hooks/HMSThemeProvider'; import { formatDuration } from '../../utils/timerUtils'; import { hmsUiClassParserGenerator } from '../../utils/classes'; export interface PlaylistItemClasses { root?: string; titleContainer?: string; } const defaultClasses = { root: 'flex justify-between items-center w-full px-3 py-3 hover:bg-gray-600 dark:hover:bg-gray-300 cursor-pointer', titleContainer: 'flex flex-col flex-1', }; export interface PlaylistItemProps { item: HMSPlaylistItem; onClick?: () => void; iconRight?: JSX.Element; classes?: PlaylistItemClasses; highlightSelection?: boolean; } export const PlaylistItem = ({ item, classes, onClick, iconRight, highlightSelection = true, }: PlaylistItemProps) => { const { tw } = useHMSTheme(); const styler = useMemo( () => hmsUiClassParserGenerator({ tw, classes, defaultClasses, tag: 'hmsui-playlistitem', }), [], ); return (
{item.name} {item.metadata?.description}
{iconRight ? ( iconRight ) : ( {formatDuration(item.duration)} )}
); };