improve signing form header

This commit is contained in:
Alex Turchyn
2025-04-18 12:16:11 +03:00
committed by GitHub
parent 7964d6e0f0
commit 847e70ec1b
5 changed files with 78 additions and 6 deletions
+56
View File
@@ -0,0 +1,56 @@
export default class extends HTMLElement {
connectedCallback () {
this.header = document.querySelector('#signing_form_header')
window.addEventListener('scroll', this.onScroll.bind(this))
window.addEventListener('resize', this.onResize.bind(this))
this.onResize()
}
disconnectedCallback () {
window.removeEventListener('scroll', this.onScroll.bind(this))
window.removeEventListener('resize', this.onResize.bind(this))
}
onResize () {
if (this.isNarrow()) {
this.hideButtons(true)
} else if (this.isHeaderNotVisible()) {
this.showButtons()
}
}
isNarrow () {
return window.innerWidth < 1366
}
onScroll () {
if (this.isHeaderNotVisible() && !this.isNarrow()) {
this.showButtons()
} else {
this.hideButtons()
}
}
isHeaderNotVisible () {
const rect = this.header.getBoundingClientRect()
return rect.bottom <= 0 || rect.top >= window.innerHeight
}
showButtons () {
this.classList.remove('hidden', '-translate-y-10', 'opacity-0')
this.classList.add('translate-y-0', 'opacity-100')
}
hideButtons () {
this.classList.remove('translate-y-0', 'opacity-100')
this.classList.add('-translate-y-10', 'opacity-0')
setTimeout(() => {
if (this.classList.contains('-translate-y-10')) {
this.classList.add('hidden')
}
}, 300)
}
}
+2
View File
@@ -4,12 +4,14 @@ import Form from './submission_form/form'
import DownloadButton from './elements/download_button'
import ToggleSubmit from './elements/toggle_submit'
import FetchForm from './elements/fetch_form'
import ScrollButtons from './elements/scroll_buttons'
const safeRegisterElement = (name, element, options = {}) => !window.customElements.get(name) && window.customElements.define(name, element, options)
safeRegisterElement('download-button', DownloadButton)
safeRegisterElement('toggle-submit', ToggleSubmit)
safeRegisterElement('fetch-form', FetchForm)
safeRegisterElement('scroll-buttons', ScrollButtons)
safeRegisterElement('submission-form', class extends HTMLElement {
connectedCallback () {
this.appElem = document.createElement('div')
+3 -3
View File
@@ -193,9 +193,9 @@ export default {
})
}
if (window.decline_button) {
window.decline_button.setAttribute('disabled', 'true')
}
document.querySelectorAll('#decline_button').forEach((button) => {
button.setAttribute('disabled', 'true')
})
},
methods: {
sendCopyToEmail () {