Skip to content

Commit 3d0b407

Browse files
Merge pull request #484 from aziontech/fix/button-state
fix: delete and create loading state
2 parents ac3d59a + e70ccd1 commit 3d0b407

4 files changed

Lines changed: 38 additions & 2 deletions

File tree

apps/storybook/src/stories/components/buttons/ButtonCreate.stories.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ export default {
3232
control: 'boolean',
3333
description: 'Whether the button is outlined'
3434
},
35+
loading: {
36+
control: 'boolean',
37+
description: 'Whether the button shows loading state'
38+
},
3539
disabled: {
3640
control: 'boolean',
3741
description: 'Whether the button is disabled'
@@ -86,6 +90,14 @@ export const Disabled = {
8690
}
8791
};
8892

93+
export const Loading = {
94+
args: {
95+
label: 'Creating...',
96+
loading: true,
97+
size: 'large'
98+
}
99+
};
100+
89101
export const Secondary = {
90102
args: {
91103
label: 'Create New',

apps/storybook/src/stories/components/buttons/ButtonDelete.stories.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ export default {
3232
control: 'boolean',
3333
description: 'Whether the button is outlined'
3434
},
35+
loading: {
36+
control: 'boolean',
37+
description: 'Whether the button shows loading state'
38+
},
3539
disabled: {
3640
control: 'boolean',
3741
description: 'Whether the button is disabled'
@@ -70,6 +74,14 @@ export const Disabled = {
7074
}
7175
};
7276

77+
export const Loading = {
78+
args: {
79+
label: 'Deleting...',
80+
loading: true,
81+
size: ''
82+
}
83+
};
84+
7385
export const WithCustomIcon = {
7486
args: {
7587
label: 'Delete',

packages/webkit/src/components/buttons/button-create/button-create.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script setup>
2+
import { computed } from 'vue'
23
import Button from 'primevue/button'
34
45
const props = defineProps({
@@ -9,12 +10,16 @@ const props = defineProps({
910
severity: { type: String, default: 'primary' },
1011
size: { type: String, default: '' },
1112
outlined: { type: Boolean, default: false },
13+
loading: { type: Boolean, default: false },
1214
disabled: { type: Boolean, default: false }
1315
})
1416
1517
const emit = defineEmits(['click'])
1618
19+
const computedDisabled = computed(() => props.disabled || props.loading)
20+
1721
const handleClick = () => {
22+
if (computedDisabled.value) return
1823
emit('click')
1924
}
2025
</script>
@@ -27,7 +32,8 @@ const handleClick = () => {
2732
:severity="severity"
2833
:size="size"
2934
:outlined="outlined"
30-
:disabled="disabled"
35+
:disabled="computedDisabled"
36+
:loading="loading"
3137
:aria-label="label"
3238
:data-testid="data-testid"
3339
@click="handleClick"

packages/webkit/src/components/buttons/button-delete/button-delete.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script setup>
2+
import { computed } from 'vue'
23
import Button from 'primevue/button'
34
45
const props = defineProps({
@@ -9,12 +10,16 @@ const props = defineProps({
910
severity: { type: String, default: 'danger' },
1011
size: { type: String, default: '' },
1112
outlined: { type: Boolean, default: true },
13+
loading: { type: Boolean, default: false },
1214
disabled: { type: Boolean, default: false }
1315
})
1416
1517
const emit = defineEmits(['click'])
1618
19+
const computedDisabled = computed(() => props.disabled || props.loading)
20+
1721
const handleClick = () => {
22+
if (computedDisabled.value) return
1823
emit('click')
1924
}
2025
</script>
@@ -27,7 +32,8 @@ const handleClick = () => {
2732
:severity="severity"
2833
:size="size"
2934
:outlined="outlined"
30-
:disabled="disabled"
35+
:disabled="computedDisabled"
36+
:loading="loading"
3137
:aria-label="label"
3238
:data-testid="data-testid"
3339
@click="handleClick"

0 commit comments

Comments
 (0)