api-client/components/button/Secondary.vue

131 lines
2.6 KiB
Vue
Raw Normal View History

2021-07-02 05:01:29 +00:00
<template>
<SmartLink
:to="`${/^\/(?!\/).*$/.test(to) ? localePath(to) : to}`"
:exact="exact"
:blank="blank"
class="
font-medium
2021-07-17 17:40:28 +00:00
py-2
2021-07-02 05:01:29 +00:00
inline-flex
items-center
justify-center
whitespace-nowrap
hover:bg-primaryDark
2021-08-05 17:22:02 +00:00
focus:outline-none
focus-visible:bg-primaryDark
2021-07-02 05:01:29 +00:00
"
:class="[
color
2021-08-05 17:22:02 +00:00
? `text-${color}-500 hover:(text-${color}-600 text-${color}-600)`
2021-08-17 07:26:36 +00:00
: 'text-secondary hover:text-secondaryDark focus-visible:text-secondaryDark',
label ? 'rounded px-4' : 'px-2',
{ 'rounded-full': rounded },
2021-07-24 16:46:48 +00:00
{ 'opacity-75 cursor-not-allowed': disabled },
2021-07-02 05:01:29 +00:00
{ 'flex-row-reverse': reverse },
{ 'px-6 py-4 text-lg': large },
2021-07-02 05:01:29 +00:00
{
2021-08-17 07:26:36 +00:00
'border border-divider hover:border-dividerDark focus-visible:border-dividerDark':
2021-07-02 05:01:29 +00:00
outline,
},
]"
:disabled="disabled"
>
<i
v-if="icon"
2021-08-06 16:10:26 +00:00
class="material-icons"
2021-07-30 08:22:43 +00:00
:class="[
{ '!text-2xl': large },
label ? (reverse ? 'ml-2' : 'mr-2') : '',
]"
2021-07-02 05:01:29 +00:00
>
{{ icon }}
</i>
<SmartIcon
v-if="svg"
:name="svg"
2021-08-06 16:10:26 +00:00
class="svg-icons"
2021-07-30 08:22:43 +00:00
:class="[
{ '!h-6 !w-6': large },
label ? (reverse ? 'ml-2' : 'mr-2') : '',
]"
2021-07-02 05:01:29 +00:00
/>
{{ label }}
<div v-if="shortcut.length && SHORTCUT_INDICATOR" class="ml-2">
2021-07-17 17:40:28 +00:00
<kbd
v-for="(key, index) in shortcut"
2021-07-17 17:40:28 +00:00
:key="`key-${index}`"
class="bg-dividerLight text-secondaryLight ml-1 px-1 inline-flex"
2021-07-17 17:40:28 +00:00
>
{{ key }}
</kbd>
</div>
2021-07-02 05:01:29 +00:00
</SmartLink>
</template>
2021-08-12 08:14:10 +00:00
<script lang="ts">
import { defineComponent } from "@nuxtjs/composition-api"
import { useSetting } from "~/newstore/settings"
2021-07-19 16:42:56 +00:00
2021-08-12 08:14:10 +00:00
export default defineComponent({
2021-07-02 05:01:29 +00:00
props: {
to: {
type: String,
default: "",
},
exact: {
type: Boolean,
default: true,
},
blank: {
type: Boolean,
default: false,
},
label: {
type: String,
default: "",
},
icon: {
type: String,
default: "",
},
svg: {
type: String,
default: "",
},
color: {
type: String,
default: "",
},
disabled: {
type: Boolean,
default: false,
},
reverse: {
type: Boolean,
default: false,
},
rounded: {
type: Boolean,
default: false,
},
large: {
type: Boolean,
default: false,
},
2021-07-02 05:01:29 +00:00
outline: {
type: Boolean,
default: false,
},
shortcut: {
2021-07-17 17:40:28 +00:00
type: Array,
default: () => [],
},
2021-07-02 05:01:29 +00:00
},
2021-08-12 08:14:10 +00:00
setup() {
2021-07-19 16:42:56 +00:00
return {
2021-08-12 08:14:10 +00:00
SHORTCUT_INDICATOR: useSetting("SHORTCUT_INDICATOR"),
2021-07-19 16:42:56 +00:00
}
},
2021-08-12 08:14:10 +00:00
})
2021-07-02 05:01:29 +00:00
</script>