Skip to content

Commit 1401dee

Browse files
committed
fix(CToast): add missing color prop
1 parent 85dfea5 commit 1401dee

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

src/components/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ declare class ToastProps extends Vue {
634634
export declare class CToast extends ToastProps {
635635
show?: boolean
636636
header?: string
637+
color?: string
637638
}
638639

639640
export declare class CToaster extends ToastProps {

src/components/toast/CToast.vue

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<transition :name="props.fade ? 'fade' : null" :appear="true">
33
<div
44
v-if="isShowed"
5-
class="toast"
5+
:class="toastClasses"
66
role="alert"
77
aria-live="assertive"
88
aria-atomic="true"
@@ -76,6 +76,12 @@ export default {
7676
computedProps[key] = propIsInherited ? this.injectedProps[key] : this[key]
7777
return computedProps
7878
}, {})
79+
},
80+
toastClasses () {
81+
return [
82+
'toast',
83+
{ [`toast-${this.color}`]: !!this.color }
84+
]
7985
}
8086
},
8187
methods: {

src/components/toast/tests/CToast.spec.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const customWrapper = mount(Component, {
1515
show: true,
1616
position: 'bottom-center',
1717
header: 'title',
18-
autohide: 1000
18+
autohide: 1000,
19+
color: 'danger'
1920
},
2021
slots: {
2122
default: 'CToast body'

src/components/toast/tests/__snapshots__/CToast.spec.js.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ exports[`CToast renders correctly custom wrapper 1`] = `
2222
appear="true"
2323
aria-atomic="true"
2424
aria-live="assertive"
25-
class="toast"
25+
class="toast toast-danger"
2626
name="fade"
2727
position="bottom-center"
2828
role="alert"
@@ -31,14 +31,14 @@ exports[`CToast renders correctly custom wrapper 1`] = `
3131
class="toast-header"
3232
>
3333
<strong
34-
class="mr-auto"
34+
class="mfe-auto"
3535
>
3636
title
3737
</strong>
3838
3939
<button
4040
aria-label="Close"
41-
class="ml-2 mb-1 close"
41+
class="mfs-2 mb-1 close"
4242
type="button"
4343
>
4444
×

src/components/toast/toast-props.js

+4
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,9 @@ export const props = {
1010
fade: {
1111
type: Boolean,
1212
default: true
13+
},
14+
color: {
15+
type: String,
16+
default: ''
1317
}
1418
}

0 commit comments

Comments
 (0)