import { createEffect, createSignal, Match, Switch, Show } from 'solid-js' import { Button } from '../Button' import { Icon } from '../Icon' import { Popover } from '../Popover' import { clsx } from 'clsx' import styles from './VideoPlayer.module.scss' import { useLocalize } from '../../../context/localize' type Props = { videoUrl: string title?: string description?: string class?: string deleteAction?: () => void } export const VideoPlayer = (props: Props) => { const { t } = useLocalize() const [videoId, setVideoId] = createSignal() const [isVimeo, setIsVimeo] = createSignal(false) createEffect(() => { const isYoutube = props.videoUrl.includes('youtube.com') || props.videoUrl.includes('youtu.be') setIsVimeo(!isYoutube) if (isYoutube) { if (props.videoUrl.includes('youtube.com')) { const videoIdMatch = props.videoUrl.match(/v=(\w+)/) setVideoId(videoIdMatch && videoIdMatch[1]) } else { const videoIdMatch = props.videoUrl.match(/youtu.be\/(\w+)/) setVideoId(videoIdMatch && videoIdMatch[1]) } } else { const videoIdMatch = props.videoUrl.match(/vimeo.com\/(\d+)/) setVideoId(videoIdMatch && videoIdMatch[1]) } }) return (
{(triggerRef: (el) => void) => (