Last active
February 20, 2023 07:06
-
-
Save gokhantaskan/5d0598107f80a9b9f807a1ab44df8789 to your computer and use it in GitHub Desktop.
Simple Vue `v-tippy` directive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "tippy.js/dist/tippy.css"; | |
import "tippy.js/animations/scale.css"; | |
import tippy, { | |
type DefaultProps as DefaultTippyProps, | |
type Props as TippyProps, | |
} from "tippy.js"; | |
import type { Directive } from "vue"; | |
const defaultProps: Partial<DefaultTippyProps> = { | |
animation: "scale", | |
arrow: false, | |
ignoreAttributes: true, | |
interactive: false, | |
placement: "bottom", | |
duration: [100, 100], | |
}; | |
tippy.setDefaultProps({ ...defaultProps }); | |
export default { | |
created(el, binding) { | |
const props: Partial<TippyProps> = binding.value; | |
tippy(el, { ...props }); | |
}, | |
} as Directive<Element, Partial<TippyProps>>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment