Spaces:
Sleeping
Sleeping
File size: 5,686 Bytes
4343907 |
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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
<template>
<button
:class="buttonClasses"
:disabled="disabled || loading"
@click="handleClick"
:type="type"
>
<span v-if="loading" class="saap-button__spinner">
<svg class="animate-spin -ml-1 mr-3 h-5 w-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
</span>
<span v-if="icon && !loading" :class="iconClasses">
<component :is="icon" />
</span>
<span class="saap-button__text">
<slot>{{ label }}</slot>
</span>
</button>
</template>
<script>
export default {
name: 'SaapButton',
props: {
variant: {
type: String,
default: 'primary',
validator: (value) => ['primary', 'secondary', 'tertiary', 'danger', 'success'].includes(value)
},
size: {
type: String,
default: 'md',
validator: (value) => ['sm', 'md', 'lg', 'xl'].includes(value)
},
disabled: {
type: Boolean,
default: false
},
loading: {
type: Boolean,
default: false
},
icon: {
type: [String, Object],
default: null
},
iconPosition: {
type: String,
default: 'left',
validator: (value) => ['left', 'right'].includes(value)
},
label: {
type: String,
default: ''
},
type: {
type: String,
default: 'button',
validator: (value) => ['button', 'submit', 'reset'].includes(value)
},
fullWidth: {
type: Boolean,
default: false
}
},
emits: ['click'],
computed: {
buttonClasses() {
return [
'saap-button',
`saap-button--${this.variant}`,
`saap-button--${this.size}`,
{
'saap-button--disabled': this.disabled,
'saap-button--loading': this.loading,
'saap-button--full-width': this.fullWidth,
'saap-button--icon-right': this.icon && this.iconPosition === 'right'
}
];
},
iconClasses() {
return [
'saap-button__icon',
{
'saap-button__icon--right': this.iconPosition === 'right'
}
];
}
},
methods: {
handleClick(event) {
if (!this.disabled && !this.loading) {
this.$emit('click', event);
}
}
}
};
</script>
<style scoped>
/* SAAP Design System - Button Component */
.saap-button {
/* Base styles */
@apply inline-flex items-center justify-center;
@apply font-medium rounded-lg transition-all duration-200;
@apply focus:outline-none focus:ring-2 focus:ring-offset-2;
@apply disabled:opacity-50 disabled:cursor-not-allowed;
/* Typography from Design System */
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
line-height: 1.5;
}
/* Size Variants - 8pt Grid System */
.saap-button--sm {
@apply px-3 py-1.5 text-sm;
min-height: 32px; /* 4 * 8pt */
}
.saap-button--md {
@apply px-4 py-2 text-sm;
min-height: 40px; /* 5 * 8pt */
}
.saap-button--lg {
@apply px-6 py-3 text-base;
min-height: 48px; /* 6 * 8pt */
}
.saap-button--xl {
@apply px-8 py-4 text-lg;
min-height: 56px; /* 7 * 8pt */
}
/* Variant Styles - SAAP Design System Colors */
.saap-button--primary {
background-color: #2563EB; /* Primary Blue */
border: 1px solid #2563EB;
color: white;
}
.saap-button--primary:hover:not(:disabled) {
background-color: #1D4ED8;
border-color: #1D4ED8;
box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.1);
}
.saap-button--primary:focus {
@apply ring-blue-500;
}
.saap-button--secondary {
background-color: #16A34A; /* Secondary Green */
border: 1px solid #16A34A;
color: white;
}
.saap-button--secondary:hover:not(:disabled) {
background-color: #15803D;
border-color: #15803D;
box-shadow: 0 4px 6px -1px rgba(22, 163, 74, 0.1);
}
.saap-button--secondary:focus {
@apply ring-green-500;
}
.saap-button--tertiary {
background-color: transparent;
border: 1px solid #D1D5DB;
color: #374151;
}
.saap-button--tertiary:hover:not(:disabled) {
background-color: #F9FAFB;
border-color: #9CA3AF;
}
.saap-button--tertiary:focus {
@apply ring-gray-500;
}
.saap-button--danger {
background-color: #DC2626;
border: 1px solid #DC2626;
color: white;
}
.saap-button--danger:hover:not(:disabled) {
background-color: #B91C1C;
border-color: #B91C1C;
}
.saap-button--danger:focus {
@apply ring-red-500;
}
.saap-button--success {
background-color: #16A34A;
border: 1px solid #16A34A;
color: white;
}
.saap-button--success:hover:not(:disabled) {
background-color: #15803D;
border-color: #15803D;
}
/* State Modifiers */
.saap-button--loading {
cursor: wait;
}
.saap-button--full-width {
@apply w-full;
}
/* Icon Styling */
.saap-button__icon {
@apply w-5 h-5 flex-shrink-0;
}
.saap-button__icon:not(.saap-button__icon--right) {
@apply mr-2;
}
.saap-button__icon--right {
@apply ml-2 order-2;
}
.saap-button--icon-right .saap-button__text {
@apply order-1;
}
/* Spinner */
.saap-button__spinner {
@apply flex items-center;
}
/* Accessibility */
@media (prefers-reduced-motion: reduce) {
.saap-button {
transition: none;
}
}
/* Dark mode support */
@media (prefers-color-scheme: dark) {
.saap-button--tertiary {
background-color: transparent;
border-color: #4B5563;
color: #D1D5DB;
}
.saap-button--tertiary:hover:not(:disabled) {
background-color: #111827;
border-color: #6B7280;
}
}
</style> |