1
0

chore: move frontend files

This commit is contained in:
kolaente
2024-02-07 14:56:56 +01:00
parent 447641c222
commit fc4676315d
606 changed files with 0 additions and 0 deletions

View File

@ -0,0 +1,21 @@
import type {Directive} from 'vue'
declare global {
interface Window {
Cypress: object;
}
}
const cypressDirective = <Directive<HTMLElement,string>>{
mounted(el, {arg, value}) {
const testingId = arg || value
if ((window.Cypress || import.meta.env.DEV) && testingId) {
el.setAttribute('data-cy', testingId)
}
},
beforeUnmount(el) {
el.removeAttribute('data-cy')
},
}
export default cypressDirective

View File

@ -0,0 +1,16 @@
import type {Directive} from 'vue'
const focus = <Directive<HTMLElement,string>>{
// When the bound element is inserted into the DOM...
mounted(el, {modifiers}) {
// Focus the element only if the viewport is big enough
// auto focusing elements on mobile can be annoying since in these cases the
// keyboard always pops up and takes half of the available space on the screen.
// The threshhold is the same as the breakpoints in css.
if (window.innerWidth > 769 || modifiers?.always) {
el.focus()
}
},
}
export default focus

View File

@ -0,0 +1,16 @@
import type {Directive} from 'vue'
import {install, uninstall} from '@github/hotkey'
const directive = <Directive<HTMLElement,string>>{
mounted(el, {value}) {
if(value === '') {
return
}
install(el, value)
},
beforeUnmount(el) {
uninstall(el)
},
}
export default directive