diff --git a/components-eleventy/video/card.js b/components-eleventy/video/card.js index ceedfb1..0f77819 100644 --- a/components-eleventy/video/card.js +++ b/components-eleventy/video/card.js @@ -9,10 +9,11 @@ function pill ( text ) { ` } -export default function ( video, { - width = '325px', - classes = 'w-full flex-shrink-0 flex-grow-0 border-2 border-transparent rounded-2xl overflow-hidden' -} ) { +export default function ( video, options = {} ) { + const { + width = '325px', + classes = 'w-full flex-shrink-0 flex-grow-0 border-2 border-transparent rounded-2xl overflow-hidden' + } = options // Setup inline lazysizes this.usingComponent( 'node_modules/lazysizes/lazysizes.min.js' ) diff --git a/components-eleventy/video/row.js b/components-eleventy/video/row.js new file mode 100644 index 0000000..308e9c5 --- /dev/null +++ b/components-eleventy/video/row.js @@ -0,0 +1,80 @@ + +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 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 + this.usingComponent( 'helpers/scroll.js' ) + + // console.log('video', video) + + const cardsHtml = videos.map( video => { + const Card = getCardType( video ) + + // console.log('Card', this.boundComponent(Card)( video ) ) + + return this.boundComponent(Card)( video ) + } ).join('') + + // console.log( 'cardsHtml', cardsHtml ) + + return /* html */` + +