From 96946763ec4166e2190f443c334a8792aa014110 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 14 Feb 2024 17:31:51 -0600 Subject: [PATCH] Website: add page buttons to component (#16683) Closes: #16304 Changes: - Added page buttons to the `` component --- .../testimonials-pagination-next-48x48@2x.png | Bin 0 -> 2259 bytes ...timonials-pagination-previous-48x48@2x.png | Bin 0 -> 2285 bytes .../components/scrollable-tweets.component.js | 73 ++++++++++--- .../scrollable-tweets.component.less | 103 ++++++++++-------- 4 files changed, 119 insertions(+), 57 deletions(-) create mode 100644 website/assets/images/testimonials-pagination-next-48x48@2x.png create mode 100644 website/assets/images/testimonials-pagination-previous-48x48@2x.png diff --git a/website/assets/images/testimonials-pagination-next-48x48@2x.png b/website/assets/images/testimonials-pagination-next-48x48@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..e8ff756ae1f8ed36ea115dd83385bee15511f74f GIT binary patch literal 2259 zcmV;^2rT!BP)d0m=z3acUtLaa;+up(7zrXt7#0wFO#(|AP)2___7 zc|kk@dx8gEFd#HlAk+=Q18<;7Ov~!DX~NR{t=&5D|NHOk{yaH#6Fae;Yv-n&3Ql?WX8-&RCoPr*#ecysW8GlNg zYm{=+D3`Jzm(w9b&fUHHw=$d%CnCUw3$G|S-5Bk*(Hp@{ znvMkJbTau?7P?GV1sJ>drKn~0j5zLI9Kzz3Cdqt#?e;rq=n`EK01ahgsi^Rm6g9_phI*-01U1ROQENkY^opt7$f>5veAiP?YIE( z=@~Vj3B)Bv7zjkC+>&EP!dkCO&&7-~9jBB~5DY>H;}%u>L(keB#HC$u2uE7L#Kg5= z4&Yg@`ubME)}YY9q7yFZ*exIyn+=y3KTpBzfl~suhB7zR$hoOpc4JY8V{j}1Ful~d zd5%#YfKvvFKs95qf8-fGn_4bHo3t%JrBkJ|xQPC~SvV&Y<3i+2Tx(Z^wgjjeAABkt zM}(FI@Qq)ec138(ePF=VN^~52>SNOJ*yY)l#<`kq0hnrHwsRT-ZnI!au!?$QGhz(kp{$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Lt()!T0h3)Ea79UaYrW00000NkvXX Hu0mjfDC}Hm literal 0 HcmV?d00001 diff --git a/website/assets/js/components/scrollable-tweets.component.js b/website/assets/js/components/scrollable-tweets.component.js index 26c2258dc..4737c58e4 100644 --- a/website/assets/js/components/scrollable-tweets.component.js +++ b/website/assets/js/components/scrollable-tweets.component.js @@ -23,16 +23,16 @@ parasails.registerComponent('scrollableTweets', { return { quotesToDisplay: [], quotesWithVideoLinks: [], - currentTweetPage: 0, - numberOfTweetCards: 0, - numberOfTweetPages: 0, + tweetsDiv: undefined, + tweetCards: undefined, + pageWidth: undefined, + numberOfTweetCardsDisplayedOnThisPage: undefined, + showPreviousPageButton: false, + showNextPageButton: true, numberOfTweetsPerPage: 0, - tweetCardWidth: 0, - tweetPageWidth: 0, - screenSize: 0, - scrolledAmount: 0, - scrollableAmount: 0, - modal: '' + syncing: false, + firstCardPosition: 0, + modal: '', }; }, @@ -41,7 +41,10 @@ parasails.registerComponent('scrollableTweets', { // ╩ ╩ ╩ ╩ ╩╩═╝ template: ` @@ -93,7 +94,13 @@ parasails.registerComponent('scrollableTweets', { }, mounted: async function(){ - + this.tweetsDiv = $('div[purpose="tweets"]')[0]; + this.tweetCards = $('a[purpose="tweet-card"]'); + this.firstCardPosition = this.tweetCards[0].getBoundingClientRect().x; + this.numberOfTweetCardsDisplayedOnThisPage = this.tweetCards.length; + this.calculateHowManyFullTweetsCanBeDisplayed(); + $(window).on('resize', this.calculateHowManyFullTweetsCanBeDisplayed); + $(window).on('wheel', this.updatePageIndicators); }, beforeDestroy: function() { @@ -103,6 +110,46 @@ parasails.registerComponent('scrollableTweets', { // ║║║║ ║ ║╣ ╠╦╝╠═╣║ ║ ║║ ║║║║╚═╗ // ╩╝╚╝ ╩ ╚═╝╩╚═╩ ╩╚═╝ ╩ ╩╚═╝╝╚╝╚═╝ methods: { + calculateHowManyFullTweetsCanBeDisplayed: function() { + let firstTweetCard = this.tweetCards[0]; + let nextTweetCard = this.tweetCards[1]; + this.tweetCardWidth = nextTweetCard.getBoundingClientRect().x - firstTweetCard.getBoundingClientRect().x; + this.numberOfTweetsPerPage = Math.floor((document.body.clientWidth - this.firstCardPosition)/this.tweetCardWidth); + if(this.numberOfTweetsPerPage < 1){ + this.numberOfTweetsPerPage = 1; + } + this.pageWidth = this.tweetCardWidth * this.numberOfTweetsPerPage; + if(this.numberOfTweetsPerPage >= this.numberOfTweetCardsDisplayedOnThisPage){ + $(this.tweetsDiv).addClass('mx-auto'); + } else { + $(this.tweetsDiv).removeClass('mx-auto'); + } + this.updatePageIndicators(); + }, + + clickNextPage: async function() { + if(!this.syncing){ + this.tweetsDiv.scrollLeft += this.pageWidth; + await setTimeout(()=>{ + this.updatePageIndicators(); + }, 600); + } + }, + + clickPreviousPage: async function() { + if(!this.syncing){ + this.tweetsDiv.scrollLeft -= this.pageWidth; + await setTimeout(()=>{ + this.updatePageIndicators(); + }, 600); + } + }, + + updatePageIndicators: function() { + this.syncing = false; + this.showPreviousPageButton = this.tweetsDiv.scrollLeft > (this.firstCardPosition * 0.5); + this.showNextPageButton = (this.tweetsDiv.scrollWidth - this.tweetsDiv.scrollLeft - this.tweetsDiv.clientWidth) >= this.tweetCardWidth * .25; + }, clickOpenVideoModal: function(modalName) { this.modal = _.kebabCase(modalName); diff --git a/website/assets/styles/components/scrollable-tweets.component.less b/website/assets/styles/components/scrollable-tweets.component.less index c0844ae1f..6e46904a1 100644 --- a/website/assets/styles/components/scrollable-tweets.component.less +++ b/website/assets/styles/components/scrollable-tweets.component.less @@ -9,24 +9,73 @@ font-size: 13px; line-height: 20px; + position: relative; [purpose='tweets']::-webkit-scrollbar { display: none; } + [purpose='previous-page-indicator'] { + display: none; + opacity: 0; + cursor: pointer; + z-index: 30; + position: absolute; + transition: transform 1s, opacity 0.25s ease-in; + transform: scale(0.5); + bottom: 50%; + left: 10px; + width: 48px; + height: 48px; + img { + width: 48px; + height: 48px; + } + } + + [purpose='next-page-indicator'] { + display: none; + opacity: 0; + cursor: pointer; + position: absolute; + transition: transform 1s, opacity 0.25s ease-in; + transform: scale(0.5); + bottom: 50%; + z-index: 30; + right: 10px; + width: 48px; + height: 48px; + img { + width: 48px; + height: 48px; + } + } + [purpose='tweets'] { overflow-x: scroll; scroll-behavior: smooth; padding-left: 120px; padding-right: 120px; margin-top: 80px; - padding-bottom: 16px; + margin-bottom: 80px; scrollbar-width: none; -ms-overflow-style: none; + &:hover { + [purpose='previous-page-indicator'] { + opacity: 1; + transform: scale(1.0); + } + [purpose='next-page-indicator'] { + opacity: 1; + transform: scale(1.0); + } + } } [purpose='tweet-card'] { + box-shadow: none; + background-color: #FFF; [purpose='logo'] { img { max-height: 32px; @@ -78,33 +127,6 @@ box-shadow: 0px 4px 16px rgba(0, 0, 0, 0.1); } } - - [purpose='page-indictator-container'] { - margin-bottom: 80px; - padding-left: 120px; - padding-right: 120px; - } - [purpose='page-indicator'] { - cursor: pointer; - padding: 4px; - height: 16px; - width: 16px; - border-radius: 100%; - margin-right: 8px; - - background-color: @core-vibrant-blue-15; - &.selected { - background-color: @core-fleet-black-50; - } - - - } - [purpose='tweets-page-indicator'] { - li { - } - li.selected { - } - } [purpose='video-modal'] { [purpose='modal-dialog'] { width: 100%; @@ -139,15 +161,20 @@ } + @media(hover) { + [purpose='previous-page-indicator'] { + display: flex; + } + [purpose='next-page-indicator'] { + display: flex; + } + } + @media (max-width: 991px) { [purpose='tweets'] { padding-left: 80px; padding-right: 80px; } - [purpose='page-indictator-container'] { - padding-left: 80px; - padding-right: 80px; - } } @media (max-width: 768px) { @@ -155,10 +182,6 @@ padding-left: 40px; padding-right: 40px; } - [purpose='page-indictator-container'] { - padding-left: 40px; - padding-right: 40px; - } [purpose='video-modal'] { [purpose='modal-dialog'] { max-width: 97vw; @@ -179,19 +202,11 @@ padding-left: 20px; padding-right: 20px; } - [purpose='page-indictator-container'] { - padding-left: 20px; - padding-right: 20px; - } [purpose='tweet-card'] { min-width: 280px; padding: 20px; border-radius: 16px; } - [purpose='page-indicator'] { - padding: 12px; - margin-bottom: 8px; - } [purpose='video-modal'] { [purpose='modal-content'] { width: 95vw;