-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathUIButtonTest.vue
More file actions
107 lines (97 loc) · 2.42 KB
/
UIButtonTest.vue
File metadata and controls
107 lines (97 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<template>
<button
class="ui-button-test"
:class="{ disabled, loading }"
:disabled="disabled || loading"
:type="htmlType"
>
<div class="content">
<UIIcon v-if="loading" class="icon" type="loading" />
<UIIcon v-else-if="icon" class="icon" :type="icon" />
<slot v-else name="icon"></slot>
<slot></slot>
</div>
</button>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import UIIcon, { type Type as IconType } from './icons/UIIcon.vue'
const props = withDefaults(
defineProps<{
icon?: IconType
disabled?: boolean
loading?: boolean
htmlType?: 'button' | 'submit' | 'reset'
}>(),
{
icon: undefined,
disabled: false,
loading: false,
htmlType: 'button'
}
)
const disabled = computed(() => props.disabled)
</script>
<style lang="scss" scoped>
.ui-button-test {
display: flex;
flex-direction: column;
justify-content: flex-end;
align-items: center;
background: none;
border: none;
cursor: pointer;
padding: 0 0 4px 0;
height: 40px; // Total height of 40px (36px content + 4px shadow offset)
border-radius: 12px;
outline: none;
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
.content {
flex: 1;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
padding: 0 24px;
border-radius: 12px;
font-size: 15px;
line-height: 1.6;
gap: 8px;
font-weight: normal;
color: var(--ui-color-grey-100);
background-color: var(--ui-color-primary-main);
box-shadow: 0 4px var(--ui-color-primary-700);
transition: inherit;
font-family: var(--ui-font-family-main);
}
.icon {
width: 18px;
height: 18px;
}
&:hover:not(:disabled):not(.loading) {
.content {
background-color: var(--ui-color-primary-400);
}
}
&:active:not(:disabled):not(.loading),
&.loading {
padding-bottom: 0;
.content {
box-shadow: none;
}
}
&:disabled:not(.loading) {
cursor: not-allowed;
.content {
// These colors are specifically requested in the design draft (via variables in colors.ts)
color: var(--ui-color-primary-700); // Specified as $turquoise700
background-color: var(--ui-color-grey-300); // Specified as $grey300
box-shadow: 0 4px var(--ui-color-grey-500); // Specified as $grey500
}
}
&:focus-visible {
outline: 2px solid var(--ui-color-primary-700);
outline-offset: 2px;
}
}
</style>