mirror of
https://github.com/plausible/analytics.git
synced 2024-12-25 10:33:01 +03:00
21 lines
330 B
JavaScript
21 lines
330 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()
|
||
|
},
|
||
|
})
|