Files
geovisio-website/src/components/Button.vue
2024-01-31 09:00:25 +00:00

233 lines
4.5 KiB
Vue

<template>
<button
:disabled="isLoading || disabled"
:type="type"
:class="[look, 'default', { disabled: disabled || isLoading }]"
@click="$emit('trigger')"
>
<i v-if="icon" :class="[icon, 'icon']"></i>
<span v-if="text.length" class="text">{{ text }}</span>
<span v-if="tooltip && tooltip.length" class="tooltip-button">{{
tooltip
}}</span>
</button>
</template>
<script lang="ts" setup>
import type { PropType } from 'vue'
type TypeInterface = 'button' | 'submit' | 'reset'
defineProps({
icon: { type: String, default: null },
disabled: { type: Boolean, default: false },
isLoading: { type: Boolean, default: false },
text: { type: String, default: '' },
tooltip: { type: String, default: '' },
look: { type: String, default: '' },
type: { type: String as PropType<TypeInterface>, default: 'button' }
})
</script>
<style lang="scss" scoped>
@media (min-width: toRem(76.8)) {
.default:hover {
opacity: 0.8;
}
}
.default {
height: toRem(3);
min-width: toRem(3.5);
@include text(s-regular);
display: flex;
align-items: center;
justify-content: center;
border: none;
background-color: transparent;
position: relative;
z-index: 1;
border-radius: toRem(1);
padding: toRem(1.3);
.icon {
font-size: toRem(2);
}
&:hover .tooltip-button {
visibility: visible;
}
}
.row-reverse {
flex-direction: row-reverse;
justify-content: flex-start;
width: 100%;
padding: 0;
font-size: toRem(1.2);
.icon {
margin-left: toRem(0.5);
margin-right: 0;
}
}
.button--black {
color: var(--white);
background-color: var(--black);
}
.button-border--black {
font-size: toRem(1.4);
background-color: var(--white);
border: toRem(0.1) solid var(--black);
.icon {
font-size: toRem(1.4);
color: var(--black);
}
}
.button--blue {
color: var(--white);
background-color: var(--blue);
&.disabled {
opacity: 0.6;
color: var(--white);
cursor: not-allowed;
}
}
.button--transparent {
border: toRem(0.1) solid var(--white);
background-color: var(--black);
color: var(--white);
}
.button--red {
color: var(--white);
background-color: var(--red-pale);
border: toRem(0.1) solid var(--red-pale);
.icon {
margin-right: 0;
font-size: toRem(1.4);
color: var(--white);
}
.text {
margin-left: toRem(1);
}
&.background-white {
color: var(--red-pale);
.icon {
color: var(--red-pale);
}
&.disabled {
.icon {
color: var(--grey-pale);
}
}
}
}
.button--white {
color: var(--blue);
background-color: var(--white);
border: toRem(0.1) solid var(--blue);
.icon {
font-size: toRem(1.4);
color: var(--blue);
margin-right: toRem(1);
}
}
.no-text {
height: toRem(3);
width: toRem(3);
padding: 0;
.icon {
font-size: toRem(1.8);
margin-right: 0;
}
}
.no-text-white .icon {
color: var(--white);
margin-right: 0;
}
.no-text-blue-dark .icon {
color: var(--blue-dark);
margin-right: 0;
font-size: toRem(1.4);
}
.no-text-green .icon {
color: var(--blue);
margin-right: 0;
font-size: toRem(1.6);
}
.background-white {
background-color: var(--white);
}
.link--blue {
color: var(--blue);
text-decoration: underline;
.icon {
font-size: toRem(1.4);
color: var(--blue);
}
}
.link--grey {
color: var(--grey-semi-dark);
.icon {
font-size: toRem(1.4);
color: var(--grey-semi-dark);
}
}
.link--black {
color: var(--black);
.icon {
font-size: toRem(1.4);
color: var(--black);
}
}
.link--red {
color: var(--red-pale);
text-decoration: underline;
.icon {
font-size: toRem(1.4);
color: var(--red-pale);
}
}
.icon {
margin-right: toRem(1);
font-size: toRem(2);
color: var(--white);
}
.button--rounded {
display: flex;
justify-content: center;
align-items: center;
border-radius: 50%;
padding: 0;
height: toRem(4);
width: toRem(4);
background-color: var(--white);
border: toRem(0.1) solid var(--grey-pale);
.icon {
color: var(---black);
font-size: toRem(1.8);
margin-right: 0;
}
}
.tooltip-button {
background-color: var(--black);
color: var(--white);
text-align: center;
border-radius: toRem(0.5);
padding: toRem(0.5) toRem(1);
position: absolute;
bottom: -100%;
visibility: hidden;
width: toRem(20);
right: 0;
z-index: 9;
@include text(xss-regular);
}
.disabled {
color: var(--grey-pale);
border-color: var(--grey-pale);
cursor: not-allowed;
.icon {
color: var(--grey-pale);
}
}
</style>