2023-01-11 17:29:38 +00:00
/ * *
* < scrollable - tweets >
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* A horizontally scrolling row of tweets with an auto - updating page indicator
*
* @ type { Component }
*
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
parasails . registerComponent ( 'scrollableTweets' , {
// ╔═╗╦═╗╔═╗╔═╗╔═╗
// ╠═╝╠╦╝║ ║╠═╝╚═╗
// ╩ ╩╚═╚═╝╩ ╚═╝
2023-12-18 21:09:58 +00:00
props : [
'testimonials'
] ,
2023-01-11 17:29:38 +00:00
// ╦╔╗╔╦╔╦╗╦╔═╗╦ ╔═╗╔╦╗╔═╗╔╦╗╔═╗
// ║║║║║ ║ ║╠═╣║ ╚═╗ ║ ╠═╣ ║ ║╣
// ╩╝╚╝╩ ╩ ╩╩ ╩╩═╝ ╚═╝ ╩ ╩ ╩ ╩ ╚═╝
data : function ( ) {
return {
2023-12-18 21:09:58 +00:00
quotesToDisplay : [ ] ,
quotesWithVideoLinks : [ ] ,
2023-02-09 02:04:56 +00:00
currentTweetPage : 0 ,
2023-11-08 20:07:41 +00:00
numberOfTweetCards : 0 ,
2023-01-11 17:29:38 +00:00
numberOfTweetPages : 0 ,
numberOfTweetsPerPage : 0 ,
tweetCardWidth : 0 ,
2023-12-18 21:09:58 +00:00
tweetPageWidth : 0 ,
screenSize : 0 ,
scrolledAmount : 0 ,
scrollableAmount : 0 ,
modal : ''
2023-01-11 17:29:38 +00:00
} ;
} ,
// ╦ ╦╔╦╗╔╦╗╦
// ╠═╣ ║ ║║║║
// ╩ ╩ ╩ ╩ ╩╩═╝
template : `
< div class = "d-flex flex-column" >
< div purpose = "tweets" class = "d-flex flex-row flex-nowrap" >
2024-01-13 01:22:36 +00:00
< a purpose = "tweet-card" class = "card" v - for = "testimonial in quotesToDisplay" target = "_blank" : href = "testimonial.quoteLinkUrl" >
< div purpose = "logo" class = "mb-4" >
< img : height = "testimonial.imageHeight" v - if = "testimonial.quoteImageFilename" : src = "'/images/'+testimonial.quoteImageFilename" / >
2023-12-18 21:09:58 +00:00
< / d i v >
2024-01-13 01:22:36 +00:00
< p purpose = "quote" >
2023-12-18 21:09:58 +00:00
{ { testimonial . quote } }
2024-01-13 01:22:36 +00:00
< a purpose = "video-link" v - if = "testimonial.youtubeVideoUrl" @ click . prevent . self = "clickOpenVideoModal(testimonial.quoteAuthorName)" > See the video . < / a >
2023-12-18 21:09:58 +00:00
< / p >
2024-01-13 01:22:36 +00:00
< div purpose = "quote-author-info" class = "d-flex flex-row align-items-center" >
< div purpose = "profile-picture" >
< img : src = "'/images/'+testimonial.quoteAuthorProfileImageFilename" >
< / d i v >
< div class = "d-flex flex-column align-self-top" >
< p purpose = "name" class = "font-weight-bold m-0" > { { testimonial . quoteAuthorName } } < / p >
< p purpose = "job-title" class = "m-0" > { { testimonial . quoteAuthorJobTitle } } < / p >
2023-10-06 23:31:16 +00:00
< / d i v >
< / d i v >
2024-01-13 01:22:36 +00:00
< / a >
2023-01-11 17:29:38 +00:00
< / d i v >
2023-12-18 21:09:58 +00:00
< div purpose = "page-indictator-container" class = "mx-auto d-flex flex-row justify-content-center" >
< / d i v >
< div v - for = "video in quotesWithVideoLinks" >
< modal purpose = "video-modal" v - if = "modal === video.modalId" @ close = "closeModal()" >
2024-01-13 01:22:36 +00:00
< iframe width = "560" height = "315" : src = "'https://www.youtube.com/embed/'+video.embedId+'?rel=0'" title = "YouTube video player" frameborder = "0" allow = "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen > < / i f r a m e >
2023-12-18 21:09:58 +00:00
< / m o d a l >
2023-01-11 17:29:38 +00:00
< / d i v >
< / d i v >
` ,
// ╦ ╦╔═╗╔═╗╔═╗╦ ╦╔═╗╦ ╔═╗
// ║ ║╠╣ ║╣ ║ ╚╦╝║ ║ ║╣
// ╩═╝╩╚ ╚═╝╚═╝ ╩ ╚═╝╩═╝╚═╝
beforeMount : function ( ) {
2023-12-18 21:09:58 +00:00
if ( ! this . testimonials ) {
throw new Error ( 'Incomplete usage of <scrollable-tweets>: Please pass in a `testimonials` prop (an array of testimonials from sails.config.builtStaticContent.testimonials). For example: `<scrollable-tweets :testimonials="testimonials">`' ) ;
}
if ( ! _ . isArray ( this . testimonials ) ) {
throw new Error ( 'Incomplete usage of <scrollable-tweets>: The `testimonials` prop provided is an invalid type. Please provide an array of testimonial values.' ) ;
}
this . quotesToDisplay = _ . clone ( this . testimonials ) ;
for ( let quote of this . testimonials ) {
if ( quote . youtubeVideoUrl ) {
this . quotesWithVideoLinks . push ( {
modalId : _ . kebabCase ( quote . quoteAuthorName ) ,
embedId : quote . videoIdForEmbed ,
} ) ;
}
}
2023-01-11 17:29:38 +00:00
} ,
mounted : async function ( ) {
2023-12-18 21:09:58 +00:00
2023-01-11 17:29:38 +00:00
} ,
beforeDestroy : function ( ) {
2023-12-18 21:09:58 +00:00
2023-01-11 17:29:38 +00:00
} ,
// ╦╔╗╔╔╦╗╔═╗╦═╗╔═╗╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
// ║║║║ ║ ║╣ ╠╦╝╠═╣║ ║ ║║ ║║║║╚═╗
// ╩╝╚╝ ╩ ╚═╝╩╚═╩ ╩╚═╝ ╩ ╩╚═╝╝╚╝╚═╝
methods : {
2023-12-18 21:09:58 +00:00
clickOpenVideoModal : function ( modalName ) {
this . modal = _ . kebabCase ( modalName ) ;
2023-01-11 17:29:38 +00:00
} ,
2023-02-09 02:04:56 +00:00
2023-12-18 21:09:58 +00:00
closeModal : function ( ) {
this . modal = undefined ;
2023-01-11 17:29:38 +00:00
} ,
2023-02-09 02:04:56 +00:00
2023-01-11 17:29:38 +00:00
}
} ) ;