PluginProbe ʕ •ᴥ•ʔ
Hostinger Tools / 3.0.71
Hostinger Tools v3.0.71
3.0.71 3.0.70 3.0.69 3.0.68 3.0.67 3.0.66 1.8.1 1.8.2 1.8.3 1.9.1 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.4 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.2 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 3.0.0 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.17 3.0.18 3.0.19 3.0.2 3.0.20 3.0.21 3.0.22 3.0.23 3.0.24 3.0.25 3.0.26 3.0.27 3.0.28 3.0.29 3.0.3 3.0.30 3.0.31 3.0.32 3.0.33 3.0.34 3.0.35 3.0.36 3.0.37 3.0.38 3.0.39 3.0.4 3.0.40 3.0.41 3.0.42 3.0.43 3.0.44 3.0.45 3.0.46 3.0.47 3.0.48 3.0.49 3.0.5 3.0.50 3.0.51 3.0.52 3.0.53 3.0.54 3.0.55 3.0.56 3.0.57 3.0.58 3.0.59 3.0.6 3.0.60 3.0.61 3.0.62 3.0.65 3.0.7 3.0.8 3.0.9 trunk 1.8.0
hostinger / vue-frontend / src / components / Button / Button.vue
hostinger / vue-frontend / src / components / Button Last commit date
Button.vue 9 months ago configuration.ts 9 months ago
Button.vue
162 lines
1 <script lang="ts" setup>
2 import { ref } from "vue";
3
4 import Icon from "@/components/Icon/Icon.vue";
5 import CircleLoader from "@/components/Loaders/CircleLoader.vue";
6 import { useButton } from "@/composables/useButton";
7 import type { IButtonProps } from "@/types";
8
9 type Emit = {
10 click: [event: Event];
11 };
12
13 const props = withDefaults(defineProps<IButtonProps>(), {
14 size: "medium",
15 variant: "contain",
16 color: "primary",
17 isDisabled: null,
18 isLoading: false
19 });
20 const emit = defineEmits<Emit>();
21 const buttonTextRef = ref<HTMLElement>();
22 const { style, tag } = useButton(props);
23
24 const handleClick = (event: Event) => {
25 if (props.isDisabled) {
26 event.preventDefault();
27 event.stopPropagation();
28
29 return;
30 }
31 emit("click", event);
32 };
33 </script>
34
35 <template>
36 <Component
37 :is="tag"
38 :to="isDisabled ? undefined : to"
39 :target="isDisabled ? undefined : target"
40 :href="isDisabled ? undefined : to"
41 class="button-v2"
42 :class="{
43 'button-v2--disabled': isDisabled,
44 'button-v2--hovered': isHovered,
45 'button-v2--loading': isLoading,
46 }"
47 :disabled="isDisabled || null"
48 @click="handleClick"
49 >
50 <Icon
51 v-if="iconPrepend && !isLoading"
52 class="button-v2__icon"
53 :name="iconPrepend"
54 :color="isDisabled ? 'gray' : style.icon.color"
55 :dimensions="style.icon.size"
56 />
57
58 <div class="button-v2__loader">
59 <CircleLoader
60 v-show="isLoading"
61 :dimensions="style.loader.size"
62 :border-color="style.loader.borderColor"
63 :border-size="style.loader.border"
64 :color="props.color"
65 />
66 </div>
67
68 <span
69 v-if="$slots.default"
70 ref="buttonTextRef"
71 class="button-v2__text"
72 >
73 <slot />
74 </span>
75
76 <Icon
77 v-if="iconAppend && !isLoading"
78 class="button-v2__icon"
79 :name="iconAppend"
80 :color="isDisabled ? 'gray' : style.icon.color"
81 :dimensions="style.icon.size"
82 />
83 </Component>
84 </template>
85
86 <style lang="scss">
87 .button-v2 {
88 $this: &;
89 padding: v-bind("style.padding");
90 color: v-bind("style.color");
91 background-color: v-bind("style.backgroundColor");
92 border: v-bind("style.border");
93 border-radius: 8px;
94 display: inline-flex;
95 align-items: center;
96 gap: 8px;
97 position: relative;
98 transition: background-color 0.1s ease-in-out;
99 text-decoration: none;
100 font-size: 12px;
101 line-height: 24px;
102 font-weight: 700;
103 width: fit-content;
104 flex-wrap: nowrap;
105 justify-content: center;
106 text-wrap: nowrap;
107
108 &--disabled,
109 &[disabled]] {
110 color: v-bind("style.colorDisabled") !important;
111 background-color: v-bind("style.backgroundColorDisabled");
112 font-size: 12px !important;
113 pointer-events: none;
114 cursor: not-allowed;
115 }
116
117 &--loading {
118 pointer-events: none;
119
120 #{$this}__text {
121 opacity: 0;
122 }
123
124 #{$this}__loader {
125 opacity: 1;
126 }
127 }
128
129 &__text {
130 opacity: 1;
131 transition: opacity 0.2s ease-in-out;
132 }
133
134 &__loader {
135 display: flex;
136 align-items: center;
137 justify-content: center;
138 position: absolute;
139 left: 0;
140 top: 0;
141 width: 100%;
142 height: 100%;
143 pointer-events: none;
144 opacity: 0;
145 transition: opacity 0.2s ease-in-out;
146 }
147
148 &--hovered:not(&--disabled):not([disabled]) {
149 background-color: v-bind("style.backgroundHoverColor");
150 }
151
152 &:hover:not(&--disabled):not([disabled]) {
153 background-color: v-bind("style.backgroundHoverColor");
154 cursor: pointer;
155 }
156
157 @media (max-width: 576px) {
158 width: 100%;
159 }
160 }
161 </style>
162