framework7-vue
Version:
Build full featured iOS & Android apps using Framework7 & Vue
68 lines • 2.41 kB
JavaScript
import { toDisplayString as _toDisplayString, renderSlot as _renderSlot, createTextVNode as _createTextVNode, mergeProps as _mergeProps, createElementVNode as _createElementVNode, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
function render(_ctx, _cache) {
return _openBlock(), _createElementBlock("li", null, [_createElementVNode("a", _mergeProps({
ref: "linkElRef",
class: _ctx.linkClasses
}, _ctx.linkAttrs, {
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
}), [_createTextVNode(_toDisplayString(_ctx.title) + " " + _toDisplayString(_ctx.text) + " ", 1), _renderSlot(_ctx.$slots, "default")], 16)]);
}
import { computed, ref } from 'vue';
import { classNames, isStringProp } from '../shared/utils.js';
import { colorClasses, colorProps, actionsAttrs, actionsClasses, actionsProps, routerAttrs, routerClasses, routerProps } from '../shared/mixins.js';
import { useTooltip } from '../shared/use-tooltip.js';
import { useRouteProps } from '../shared/use-route-props.js';
export default {
name: 'f7-list-button',
render,
props: {
title: [String, Number],
text: [String, Number],
tabLink: [Boolean, String],
tabLinkActive: Boolean,
link: [Boolean, String],
href: [Boolean, String],
target: String,
tooltip: String,
tooltipTrigger: String,
...colorProps,
...actionsProps,
...routerProps
},
emits: ['click'],
setup(props, {
emit
}) {
const linkElRef = ref(null);
const onClick = e => {
emit('click', e);
};
useTooltip(linkElRef, props);
useRouteProps(linkElRef, props);
const linkAttrs = computed(() => {
return {
href: typeof props.link === 'boolean' && typeof props.href === 'boolean' ? '#' : props.link || props.href,
target: props.target,
'data-tab': isStringProp(props.tabLink) && props.tabLink,
...routerAttrs(props),
...actionsAttrs(props)
};
});
const linkClasses = computed(() => {
return classNames({
'list-button': true,
'tab-link': props.tabLink || props.tabLink === '',
'tab-link-active': props.tabLinkActive,
...colorClasses(props),
...routerClasses(props),
...actionsClasses(props)
});
});
return {
linkAttrs,
linkClasses,
onClick,
linkElRef
};
}
};