diff --git a/apps/web/src/components/Icon/assets/collection.svg b/apps/web/src/components/Icon/assets/collection.svg new file mode 100644 index 000000000..c0eb1fd5d --- /dev/null +++ b/apps/web/src/components/Icon/assets/collection.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/apps/web/src/components/Icon/assets/pause-template.svg b/apps/web/src/components/Icon/assets/pause-template.svg new file mode 100644 index 000000000..81dacf1a0 --- /dev/null +++ b/apps/web/src/components/Icon/assets/pause-template.svg @@ -0,0 +1,3 @@ + + + diff --git a/apps/web/src/components/Icon/assets/pause.svg b/apps/web/src/components/Icon/assets/pause.svg index facad699e..6aed4d57a 100644 --- a/apps/web/src/components/Icon/assets/pause.svg +++ b/apps/web/src/components/Icon/assets/pause.svg @@ -1,8 +1,3 @@ - - - - - - + diff --git a/apps/web/src/components/Icon/assets/play.svg b/apps/web/src/components/Icon/assets/play.svg new file mode 100644 index 000000000..f8661a7cd --- /dev/null +++ b/apps/web/src/components/Icon/assets/play.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web/src/components/Icon/icons.ts b/apps/web/src/components/Icon/icons.ts index 7a3eb4bd1..89170527b 100644 --- a/apps/web/src/components/Icon/icons.ts +++ b/apps/web/src/components/Icon/icons.ts @@ -10,6 +10,7 @@ import ChevronLeft from './assets/chevron-left.svg' import ChevronRight from './assets/chevron-right.svg' import ChevronUp from './assets/chevron-up.svg' import Code from './assets/code.svg' +import Collection from './assets/collection.svg' import Copy from './assets/copy.svg' import Cross16 from './assets/cross-16.svg' import Cross from './assets/cross.svg' @@ -26,7 +27,9 @@ import Info16 from './assets/info-16.svg' import Move from './assets/move.svg' import NewWindow from './assets/new-window.svg' import NounsConnect from './assets/nouns-connect.svg' +import PauseTemplate from './assets/pause-template.svg' import Pause from './assets/pause.svg' +import Play from './assets/play.svg' import Plus from './assets/plus.svg' import Refresh from './assets/refresh.svg' import Trash from './assets/trash.svg' @@ -47,6 +50,7 @@ export const icons = { chevronRight: ChevronRight, chevronUp: ChevronUp, code: Code, + collection: Collection, copy: Copy, cross: Cross, 'cross-16': Cross16, @@ -64,6 +68,8 @@ export const icons = { newWindow: NewWindow, nounsConnect: NounsConnect, pause: Pause, + pauseTemplate: PauseTemplate, + play: Play, plus: Plus, refresh: Refresh, trash: Trash, diff --git a/apps/web/src/components/MediaPreview/Audio.tsx b/apps/web/src/components/MediaPreview/Audio.tsx new file mode 100644 index 000000000..a57bb72b3 --- /dev/null +++ b/apps/web/src/components/MediaPreview/Audio.tsx @@ -0,0 +1,69 @@ +import { Box } from '@zoralabs/zord' +import NextImage from 'next/image' +import { useCallback, useRef, useState } from 'react' + +import { Icon } from '../Icon' + +export interface AudioProps { + src: string + cover?: string +} + +export const Audio: React.FC = ({ src, cover }) => { + const [playing, setPlaying] = useState(false) + const audioRef = useRef(null) + + const togglePlay = useCallback(async () => { + if (!audioRef.current) return + if (playing) audioRef.current.pause() + else audioRef.current.play() + }, [audioRef, playing]) + + return ( + + {!cover ? ( + + ) : ( + + )} + + + + + + + ) +} diff --git a/apps/web/src/components/MediaPreview/Image.tsx b/apps/web/src/components/MediaPreview/Image.tsx new file mode 100644 index 000000000..cb6be49ab --- /dev/null +++ b/apps/web/src/components/MediaPreview/Image.tsx @@ -0,0 +1,23 @@ +import NextImage from 'next/image' + +export interface ImageProps { + src: string +} + +export const Image: React.FC = ({ src }) => { + return ( + + ) +} diff --git a/apps/web/src/components/MediaPreview/MediaPreview.tsx b/apps/web/src/components/MediaPreview/MediaPreview.tsx new file mode 100644 index 000000000..a2bd7f97f --- /dev/null +++ b/apps/web/src/components/MediaPreview/MediaPreview.tsx @@ -0,0 +1,36 @@ +import { Box } from '@zoralabs/zord' +import { getFetchableUrl } from 'ipfs-service' +import { useMemo } from 'react' + +import { Audio } from './Audio' +import { Image } from './Image' +import { Video } from './Video' + +export interface MediaPreviewProps { + mediaUrl: string + mediaType?: string + coverUrl?: string +} + +export const MediaPreview: React.FC = ({ + mediaType, + mediaUrl, + coverUrl, +}) => { + const fetchableMediaURL = useMemo(() => getFetchableUrl(mediaUrl) || '', [mediaUrl]) + const fetchableCoverURL = useMemo(() => getFetchableUrl(coverUrl) || '', [coverUrl]) + + if (fetchableMediaURL && mediaType?.startsWith('image')) { + return + } + + if (fetchableMediaURL && mediaType?.startsWith('video')) { + return