{"version":3,"file":"featuredArticles-CyO4J3LR.js","sources":["../../../../../src/scripts/modules/featuredArticles.ts"],"sourcesContent":["import { Component } from '@verndale/core';\n\nclass RelatedPatientStories extends Component {\n page: number = 0;\n cardsLength: number = 0;\n itemsPerPage: number = 6;\n\n constructor(el: HTMLElement) {\n super(el);\n this.cardsLength = (this.dom.cards as NodeListOf).length || 0;\n\n if (this.cardsLength === 0) {\n (this.dom.showMoreBtn as HTMLElement).style.display = 'none';\n }\n }\n\n setupDefaults() {\n this.dom = {\n featuredCardsContainer: this.el.querySelector(\n '.featured-articles__cards-container'\n ),\n showMoreBtn: this.el.querySelector('.featured-articles__show-more-btn'),\n cards: this.el.querySelectorAll('.article-card') as NodeListOf\n };\n }\n\n addListeners() {\n (this.dom.showMoreBtn as HTMLButtonElement)?.addEventListener(\n 'click',\n this.showMore.bind(this)\n );\n }\n\n showMore(e: Event) {\n const showMoreButton = e.target as HTMLElement;\n const cards = this.el.querySelectorAll('.article-card') as NodeListOf;\n\n (this.dom.featuredCardsContainer as HTMLElement).style.display = 'grid';\n\n this.page++;\n\n if (this.page * this.itemsPerPage >= this.cardsLength) {\n showMoreButton.style.display = 'none';\n }\n\n for (let i = 0; i < this.page * this.itemsPerPage; i++) {\n if (cards[i]) {\n cards[i].classList.add('article-card--visible');\n }\n }\n }\n}\n\nexport default RelatedPatientStories;\n"],"names":["RelatedPatientStories","Component","el","__publicField","_a","showMoreButton","cards","i"],"mappings":"iNAEA,MAAMA,UAA8BC,CAAU,CAK5C,YAAYC,EAAiB,CAC3B,MAAMA,CAAE,EALVC,EAAA,YAAe,GACfA,EAAA,mBAAsB,GACtBA,EAAA,oBAAuB,GAIrB,KAAK,YAAe,KAAK,IAAI,MAAwC,QAAU,EAE3E,KAAK,cAAgB,IACtB,KAAK,IAAI,YAA4B,MAAM,QAAU,OAE1D,CAEA,eAAgB,CACd,KAAK,IAAM,CACT,uBAAwB,KAAK,GAAG,cAC9B,qCACF,EACA,YAAa,KAAK,GAAG,cAA2B,mCAAmC,EACnF,MAAO,KAAK,GAAG,iBAAiB,eAAe,CAAA,CAEnD,CAEA,cAAe,QACZC,EAAA,KAAK,IAAI,cAAT,MAAAA,EAA4C,iBAC3C,QACA,KAAK,SAAS,KAAK,IAAI,EAE3B,CAEA,SAAS,EAAU,CACjB,MAAMC,EAAiB,EAAE,OACnBC,EAAQ,KAAK,GAAG,iBAAiB,eAAe,EAErD,KAAK,IAAI,uBAAuC,MAAM,QAAU,OAE5D,KAAA,OAED,KAAK,KAAO,KAAK,cAAgB,KAAK,cACxCD,EAAe,MAAM,QAAU,QAGjC,QAASE,EAAI,EAAGA,EAAI,KAAK,KAAO,KAAK,aAAcA,IAC7CD,EAAMC,CAAC,GACTD,EAAMC,CAAC,EAAE,UAAU,IAAI,uBAAuB,CAGpD,CACF"}