mirror of
https://github.com/plausible/analytics.git
synced 2024-12-26 02:55:02 +03:00
27 lines
416 B
JavaScript
27 lines
416 B
JavaScript
|
// From https://alpinejs.dev/component/dropdown
|
||
|
|
||
|
export default () => ({
|
||
|
open: false,
|
||
|
toggle() {
|
||
|
if (this.open) {
|
||
|
return this.close()
|
||
|
}
|
||
|
|
||
|
this.$refs.button.focus()
|
||
|
this.open = true
|
||
|
},
|
||
|
|
||
|
close(focusAfter) {
|
||
|
if (! this.open) return
|
||
|
|
||
|
this.open = false
|
||
|
focusAfter && focusAfter.focus()
|
||
|
},
|
||
|
|
||
|
onPanelClick(e) {
|
||
|
if (e.target.tagName === 'A') {
|
||
|
this.close()
|
||
|
}
|
||
|
}
|
||
|
})
|