{"version":3,"file":"about-us-block-b013d970.js","sources":["../../../../src/scripts/modules/about-us-block.ts"],"sourcesContent":["import { Component } from '@verndale/core';\nimport { BREAKPOINTS } from '../helpers/breakpoints';\nimport { debounce } from '../helpers/debounce';\n\nclass AboutUsBlock extends Component {\n private expanded: boolean;\n\n constructor(el: HTMLElement) {\n super(el);\n\n this.expanded = false;\n this.setContentHeight();\n }\n\n setupDefaults() {\n this.dom = {\n description: this.el.querySelector(\n '.about-us-block__description'\n ),\n trigger: this.el.querySelector('.about-us-block__button'),\n triggerText: this.el.querySelector(\n '.about-us-block__button-text'\n )\n };\n }\n\n addListeners() {\n (this.dom.trigger as HTMLElement).addEventListener(\n 'click',\n this.handleTriggerClick.bind(this)\n );\n\n window.addEventListener(\n 'resize',\n debounce(this.setContentHeight.bind(this), 100)\n );\n }\n\n handleTriggerClick() {\n const trigger = this.dom.trigger as HTMLElement;\n const triggerText = this.dom.triggerText as HTMLElement;\n const content = this.dom.description as HTMLElement;\n\n this.expanded = !this.expanded;\n\n if (this.expanded) {\n content.classList.remove('about-us-block__description--collapsed');\n triggerText.textContent = trigger.dataset.expandedLabel || '';\n trigger.classList.add('about-us-block__button--expanded');\n trigger.dataset.layer = trigger.dataset.expandedLayer;\n } else {\n content.classList.add('about-us-block__description--collapsed');\n triggerText.textContent = trigger.dataset.collapsedLabel || '';\n trigger.classList.remove('about-us-block__button--expanded');\n trigger.dataset.layer = trigger.dataset.collapsedLayer;\n }\n\n trigger.setAttribute('aria-expanded', `${this.expanded}`);\n\n this.setContentHeight();\n }\n\n setContentHeight() {\n const content = this.dom.description as HTMLElement;\n const contentRealHeight = content.scrollHeight;\n\n content.style.setProperty(\n '--content-real-height',\n `${contentRealHeight}px`\n );\n\n if (!this.expanded) {\n const trigger = this.dom.trigger as HTMLElement;\n const lineHeight = parseInt(window.getComputedStyle(content).lineHeight);\n const lines = contentRealHeight / lineHeight;\n const maxLines = window.matchMedia(\n `(min-width: ${BREAKPOINTS.tabletLandscape}px)`\n ).matches\n ? 4\n : 5;\n content.style.setProperty(\n '--max-content-height',\n `${lineHeight * maxLines}px`\n );\n if (lines <= maxLines) {\n trigger?.style.setProperty('display', 'none');\n content.classList.remove('about-us-block__description--collapsed');\n } else {\n trigger?.style.removeProperty('display');\n content.classList.add('about-us-block__description--collapsed');\n }\n }\n }\n}\n\nexport default AboutUsBlock;\n"],"names":["AboutUsBlock","Component","el","__publicField","debounce","trigger","triggerText","content","contentRealHeight","lineHeight","lines","maxLines","BREAKPOINTS"],"mappings":"8YAIA,MAAMA,UAAqBC,CAAU,CAGnC,YAAYC,EAAiB,CAC3B,MAAMA,CAAE,EAHFC,EAAA,iBAKN,KAAK,SAAW,GAChB,KAAK,iBAAiB,CACxB,CAEA,eAAgB,CACd,KAAK,IAAM,CACT,YAAa,KAAK,GAAG,cACnB,8BACF,EACA,QAAS,KAAK,GAAG,cAA2B,yBAAyB,EACrE,YAAa,KAAK,GAAG,cACnB,8BACF,CAAA,CAEJ,CAEA,cAAe,CACZ,KAAK,IAAI,QAAwB,iBAChC,QACA,KAAK,mBAAmB,KAAK,IAAI,CAAA,EAG5B,OAAA,iBACL,SACAC,EAAS,KAAK,iBAAiB,KAAK,IAAI,EAAG,GAAG,CAAA,CAElD,CAEA,oBAAqB,CACb,MAAAC,EAAU,KAAK,IAAI,QACnBC,EAAc,KAAK,IAAI,YACvBC,EAAU,KAAK,IAAI,YAEpB,KAAA,SAAW,CAAC,KAAK,SAElB,KAAK,UACCA,EAAA,UAAU,OAAO,wCAAwC,EACrDD,EAAA,YAAcD,EAAQ,QAAQ,eAAiB,GACnDA,EAAA,UAAU,IAAI,kCAAkC,EAChDA,EAAA,QAAQ,MAAQA,EAAQ,QAAQ,gBAEhCE,EAAA,UAAU,IAAI,wCAAwC,EAClDD,EAAA,YAAcD,EAAQ,QAAQ,gBAAkB,GACpDA,EAAA,UAAU,OAAO,kCAAkC,EACnDA,EAAA,QAAQ,MAAQA,EAAQ,QAAQ,gBAG1CA,EAAQ,aA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