import VideoCard from './card.js' import SubmitCard from './submit-card.js' function getCardType ( video ) { const isSubmitCard = video.endpoint.includes('https://docs.google.com/forms') if ( isSubmitCard ) return SubmitCard return VideoCard } export default async function ( videos, options = {} ) { const { cardWidth = '325', classes = '' } = options // Math.random should be unique because of its seeding algorithm. // Convert it to base 36 (numbers + letters), and grab the first 9 characters // after the decimal. const uid = Math.random().toString(36).substr(2, 9) const rowId = `row-${ uid }` // Setup inline lazysizes await this.usingComponent( 'helpers/scroll.js' ) // console.log('video', video) const renderedCards = await Promise.all(videos.map( async video => { const Card = getCardType( video ) // console.log('Card', this.boundComponent(Card)( video ) ) return await this.boundComponent(Card)( video ) } )) const cardsHtml = renderedCards.join('') // console.log( 'cardsHtml', cardsHtml ) return /* html */`