api-client/components/smart/Item.vue

108 lines
2.2 KiB
Vue
Raw Normal View History

2021-07-03 13:14:58 +00:00
<template>
<SmartLink
:to="`${/^\/(?!\/).*$/.test(to) ? localePath(to) : to}`"
:exact="exact"
:blank="blank"
class="
rounded
2021-07-13 05:37:29 +00:00
font-semibold
2021-07-17 17:40:28 +00:00
text-xs
py-2
px-4
2021-07-03 13:14:58 +00:00
transition
2021-07-17 17:40:28 +00:00
inline-flex
items-center
2021-07-03 13:14:58 +00:00
focus:bg-primaryDark focus:text-secondaryDark
hover:bg-primaryDark hover:text-secondaryDark
focus:outline-none
"
:class="[
2021-07-24 16:46:48 +00:00
{ 'opacity-75 cursor-not-allowed': disabled },
{ 'pointer-events-none': loading },
2021-07-03 13:14:58 +00:00
{ 'flex-1': label },
{ 'flex-row-reverse justify-end': reverse },
]"
:disabled="disabled"
:tabindex="loading ? '-1' : '0'"
2021-07-03 13:14:58 +00:00
>
<span v-if="!loading" class="inline-flex items-center">
<i
v-if="icon"
:class="label ? (reverse ? 'ml-4 opacity-75' : 'mr-4 opacity-75') : ''"
class="material-icons"
>
{{ icon }}
</i>
<SmartIcon
v-if="svg"
:name="svg"
:class="label ? (reverse ? 'ml-4 opacity-75' : 'mr-4 opacity-75') : ''"
class="svg-icons"
/>
</span>
<SmartSpinner v-else class="mr-4" />
2021-07-03 13:14:58 +00:00
<div class="inline-flex items-start" :class="{ 'flex-col': description }">
<div class="font-semibold">
{{ label }}
</div>
<p v-if="description" class="my-2 text-left text-secondaryLight">
2021-07-03 13:14:58 +00:00
{{ description }}
</p>
</div>
2021-07-17 17:40:28 +00:00
<i v-if="infoIcon" class="text-accent ml-4 material-icons">
{{ infoIcon }}
</i>
2021-07-03 13:14:58 +00:00
</SmartLink>
</template>
<script>
export default {
props: {
to: {
type: String,
default: "",
},
exact: {
type: Boolean,
default: true,
},
blank: {
type: Boolean,
default: false,
},
label: {
type: String,
default: "",
},
description: {
type: String,
default: "",
},
icon: {
type: String,
default: "",
},
svg: {
type: String,
default: "",
},
disabled: {
type: Boolean,
default: false,
},
loading: {
type: Boolean,
default: false,
2021-07-03 13:14:58 +00:00
},
reverse: {
type: Boolean,
default: false,
},
infoIcon: {
type: String,
default: "",
},
2021-07-03 13:14:58 +00:00
},
}
</script>