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