adds fullwidth prop

This commit is contained in:
2026-05-12 21:41:47 -04:00
parent 204b0760c3
commit 386566e0dc
2 changed files with 23 additions and 6 deletions
+13 -3
View File
@@ -1,12 +1,13 @@
<template>
<div class="button-group">
<MyButton variant="primary"
size="sm">
Primary Small
</MyButton>
<MyButton variant="secondary"
size="md">
<MyButton>
Primary Medium
</MyButton>
<MyButton variant="secondary">
Secondary Medium
</MyButton>
<MyButton variant="danger"
@@ -26,16 +27,25 @@
Danger Large
</MyButton>
</div>
<div class="button-group">
<MyButton variant="danger"
size="lg"
:fullwidth="true">
Danger Fullwidth
</MyButton>
</div>
</template>
<script setup lang="ts">
import MyButton from './components/MyButton.vue';
</script>
<style scoped>
.button-group {
display: flex;
align-items: center;
gap: 1rem;
margin-block-start: 1rem;
}
</style>
+10 -3
View File
@@ -22,15 +22,17 @@ import { computed } from 'vue';
interface ButtonProps {
disabled?: boolean
fullwidth?: boolean
icon?: string
loading?: boolean
size: 'sm' | 'md' | 'lg'
variant: 'primary' | 'secondary' | 'danger'
size?: 'sm' | 'md' | 'lg'
variant?: 'primary' | 'secondary' | 'danger'
}
const {
variant = "primary",
size = "md",
fullwidth = false,
disabled = false,
loading = false
} = defineProps<ButtonProps>()
@@ -39,7 +41,8 @@ const emit = defineEmits(['click'])
const classes = computed(() => [
`btn--${variant}`,
`btn--${size}`
`btn--${size}`,
fullwidth && 'btn--fullwidth'
])
</script>
@@ -89,6 +92,10 @@ const classes = computed(() => [
--border-radius: 0.5rem;
}
&.btn--fullwidth {
width: 100%;
}
&[aria-busy="true"] {
opacity: 0.5;
}