@inkline/inkline
Version:
Inkline is the intuitive UI Components library that gives you a developer-friendly foundation for building high-quality, accessible, and customizable Vue.js 3 Design Systems.
20 lines (19 loc) • 655 B
JavaScript
import { computed, resolveComponent } from "vue";
import { useInkline } from "@inkline/inkline/composables/useInkline";
export function useLinkable(props) {
const inkline = useInkline();
const isLink = computed(() => {
return props.to.value || props.href.value;
});
const tag = computed(() => {
const routerComponent = inkline?.options?.routerComponent;
if (props.to.value && routerComponent) {
return typeof routerComponent === "string" ? resolveComponent(routerComponent) : routerComponent;
} else if (props.href.value) {
return "a";
} else {
return props.tag.value;
}
});
return { tag, isLink };
}