1+ <template >
2+ <transition :name =" fade ? 'fade' : null" :appear =" true" >
3+ <div
4+ v-if =" state"
5+ :class =" alertClasses"
6+ role =" alert"
7+ aria-live =" polite"
8+ aria-atomic =" true"
9+ >
10+ <CButtonClose
11+ v-if =" dismissible && dismissible !== 'customButton' "
12+ @click =" dismiss()"
13+ :iconHtml =" iconHtml"
14+ :disabled =" this.dismissible === 'disabled'"
15+ />
16+ <slot :dismiss =" dismiss" >
17+
18+ </slot >
19+ </div >
20+ </transition >
21+ </template >
22+
123<script >
224import CButtonClose from ' ../Button/CButtonClose'
3-
425export default {
526 name: ' CAlert' ,
627 components: { CButtonClose },
@@ -9,7 +30,10 @@ export default {
930 type: String ,
1031 default: ' info'
1132 },
12- dismissible: [Boolean , String ],
33+ dismissible: {
34+ type: [Boolean , String ],
35+ validator : val => [false , true , ' disabled' , ' customButton' ]
36+ },
1337 show: {
1438 type: [Boolean , Number ],
1539 default: true
@@ -24,13 +48,14 @@ export default {
2448 }
2549 },
2650 computed: {
27- classObject () {
28- return [' c-alert' ,
29- {
30- ' c-alert-dismissible' : this .dismissible ,
31- [` c-alert-${ this .variant } ` ]: this .variant
32- }
33- ]
51+ alertClasses () {
52+ return [
53+ ' c-alert' ,
54+ {
55+ ' c-alert-dismissible' : this .dismissible ,
56+ [` c-alert-${ this .variant } ` ]: this .variant
57+ }
58+ ]
3459 }
3560 },
3661 watch: {
@@ -42,7 +67,7 @@ export default {
4267 state: {
4368 immediate: true ,
4469 handler (val , oldVal ) {
45- if (val == oldVal) return
70+ if (val == oldVal) return
4671
4772 if (! val && oldVal) {
4873 this .clearCounter ()
@@ -71,39 +96,30 @@ export default {
7196 this .countdownTimeout = null
7297 }
7398 }
74- },
75- render (h ) {
76- if (! this .state ) return h (false )
77-
78- let dismissBtn = h (false )
79- if (this .dismissible ) {
80- dismissBtn = h (
81- ' CButtonClose' ,
82- {
83- on: { click: this .dismiss },
84- props: { iconHtml: this .iconHtml },
85- attrs: { disabled: this .dismissible === ' disabled' }
86- }
87- )
88- }
89- const alert = h (
90- ' div' ,
91- {
92- class: this .classObject ,
93- attrs: { role: ' alert' , ' aria-live' : ' polite' , ' aria-atomic' : true }
94- },
95- [dismissBtn, this .$scopedSlots .default ({dismiss: this .dismiss })]
96- )
97- return ! this .fade ? alert : h (
98- ' transition' ,
99- { props: { name: ' fade' , appear: true } },
100- [ alert ]
101- )
10299 }
103100}
104101 </script >
102+ <style scoped>
103+ .fade-enter-active , .fade-leave-active {
104+ transition : opacity .3s ;
105+ }
106+ .fade-enter , .fade-leave-to {
107+ opacity : 0 ;
108+ }
109+ /* /deep/ .c-alert-dismissible .c-close {
110+ position: absolute;
111+ top: 0;
112+ right: 0;
113+ padding: 0.75rem 1.25rem;
114+ color: inherit;
115+ } */
116+ </style >
105117
106-
107- <style scoped lang="scss">
108- @import " ~@coreui/coreui/scss/partials/alert.scss" ;
118+ <style lang="scss">
119+ div :not (.coreui-custom-styles ) {
120+ // .c-alert {
121+ // background-color: grey !important;
122+ // }
123+ @import " ~@coreui/coreui/scss/partials/alert.scss" ;
124+ }
109125 </style >
0 commit comments