chore: improve minification
This commit is contained in:
parent
50da2beca1
commit
55326dab7d
8 changed files with 69 additions and 57 deletions
|
@ -40,4 +40,24 @@ window.addEventListener('load', () => {
|
|||
}
|
||||
})
|
||||
})()
|
||||
|
||||
;(() => {
|
||||
const button = document.querySelector('[data-toggle-button]')
|
||||
const content = document.querySelector('[data-toggle-content]')
|
||||
const text = document.querySelectorAll('[data-toggle-content] p')
|
||||
const minHeight = 500 // this needs to match the height set on [data-toggle-content].text-toggle-hidden in text-toggle.css
|
||||
const interiorHeight = Array.from(text).reduce((acc, node) => acc + node.scrollHeight, 0)
|
||||
|
||||
if (!button || !content || !text) return
|
||||
|
||||
if (interiorHeight < minHeight) {
|
||||
content.classList.remove('text-toggle-hidden')
|
||||
button.style.display = 'none'
|
||||
}
|
||||
|
||||
button.addEventListener('click', () => {
|
||||
const isHidden = content.classList.toggle('text-toggle-hidden')
|
||||
button.textContent = isHidden ? 'Show more' : 'Show less'
|
||||
})
|
||||
})
|
||||
})
|
|
@ -1,17 +0,0 @@
|
|||
window.addEventListener('load', () => {
|
||||
const button = document.querySelector('[data-toggle-button]')
|
||||
const content = document.querySelector('[data-toggle-content]')
|
||||
const text = document.querySelectorAll('[data-toggle-content] p')
|
||||
const minHeight = 500 // this needs to match the height set on [data-toggle-content].text-toggle-hidden in text-toggle.css
|
||||
const interiorHeight = Array.from(text).reduce((acc, node) => acc + node.scrollHeight, 0)
|
||||
|
||||
if (interiorHeight < minHeight) {
|
||||
content.classList.remove('text-toggle-hidden')
|
||||
button.style.display = 'none'
|
||||
}
|
||||
|
||||
button.addEventListener('click', () => {
|
||||
const isHidden = content.classList.toggle('text-toggle-hidden')
|
||||
button.textContent = isHidden ? 'Show more' : 'Show less'
|
||||
})
|
||||
})
|
Reference in a new issue