You've already forked AstralRinth
forked from didirus/AstralRinth
* refactor: migrate to common eslint+prettier configs * fix: prettier frontend * feat: config changes * fix: lint issues * fix: lint * fix: type imports * fix: cyclical import issue * fix: lockfile * fix: missing dep * fix: switch to tabs * fix: continue switch to tabs * fix: rustfmt parity * fix: moderation lint issue * fix: lint issues * fix: ui intl * fix: lint issues * Revert "fix: rustfmt parity" This reverts commit cb99d2376c321d813d4b7fc7e2a213bb30a54711. * feat: revert last rs
125 lines
2.4 KiB
Vue
125 lines
2.4 KiB
Vue
<script setup>
|
|
import { ExternalIcon, UnknownIcon } from '@modrinth/assets'
|
|
import { computed } from 'vue'
|
|
|
|
const props = defineProps({
|
|
link: {
|
|
type: String,
|
|
default: null,
|
|
},
|
|
external: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
action: {
|
|
type: Function,
|
|
default: null,
|
|
},
|
|
color: {
|
|
type: String,
|
|
default: 'default',
|
|
},
|
|
iconOnly: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
large: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
outline: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
transparent: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
hoverFilled: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
hoverFilledOnly: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
})
|
|
|
|
const accentedButton = computed(() =>
|
|
['danger', 'primary', 'red', 'orange', 'green', 'blue', 'purple', 'gray'].includes(props.color),
|
|
)
|
|
|
|
const classes = computed(() => {
|
|
const color = props.color
|
|
return {
|
|
'icon-only': props.iconOnly,
|
|
'btn-large': props.large,
|
|
'btn-danger': color === 'danger',
|
|
'btn-primary': color === 'primary',
|
|
'btn-secondary': color === 'secondary',
|
|
'btn-highlight': color === 'highlight',
|
|
'btn-red': color === 'red',
|
|
'btn-orange': color === 'orange',
|
|
'btn-green': color === 'green',
|
|
'btn-blue': color === 'blue',
|
|
'btn-purple': color === 'purple',
|
|
'btn-gray': color === 'gray',
|
|
'btn-transparent': props.transparent,
|
|
'btn-hover-filled': props.hoverFilled,
|
|
'btn-hover-filled-only': props.hoverFilledOnly,
|
|
'btn-outline': props.outline,
|
|
'color-accent-contrast': accentedButton,
|
|
}
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<router-link
|
|
v-if="link && link.startsWith('/')"
|
|
class="btn"
|
|
:class="classes"
|
|
:to="link"
|
|
:target="external ? '_blank' : '_self'"
|
|
@click="
|
|
(event) => {
|
|
if (action) {
|
|
action(event)
|
|
}
|
|
}
|
|
"
|
|
>
|
|
<slot />
|
|
<ExternalIcon v-if="external && !iconOnly" class="external-icon" />
|
|
<UnknownIcon v-if="!$slots.default" />
|
|
</router-link>
|
|
<a
|
|
v-else-if="link"
|
|
class="btn"
|
|
:class="classes"
|
|
:href="link"
|
|
:target="external ? '_blank' : '_self'"
|
|
@click="
|
|
(event) => {
|
|
if (action) {
|
|
action(event)
|
|
}
|
|
}
|
|
"
|
|
>
|
|
<slot />
|
|
<ExternalIcon v-if="external && !iconOnly" class="external-icon" />
|
|
<UnknownIcon v-if="!$slots.default" />
|
|
</a>
|
|
<button v-else class="btn" :class="classes" @click="action">
|
|
<slot />
|
|
<UnknownIcon v-if="!$slots.default" />
|
|
</button>
|
|
</template>
|
|
|
|
<style lang="scss" scoped>
|
|
:where(button) {
|
|
background: none;
|
|
color: var(--color-base);
|
|
}
|
|
</style>
|