Skip to content

Commit 2c974f7

Browse files
Merge pull request #28 from mesqueeb/fix/prevent-css-polution
fix: prevent global CSS pollution
2 parents db3b31d + 76f08a3 commit 2c974f7

File tree

6 files changed

+27
-26
lines changed

6 files changed

+27
-26
lines changed

src/Toaster.vue

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
>
66
<div
77
v-show="isActive"
8-
:class="['c-toast', `c-toast--${type}`, `c-toast--${position}`]"
8+
:class="['vue-toaster', `vue-toaster--${type}`, `vue-toaster--${position}`]"
99
@mouseover="toggleTimer(true)"
1010
@mouseleave="toggleTimer(false)"
1111
@click="click"
@@ -92,20 +92,20 @@ export default {
9292
},
9393
methods: {
9494
createParents() {
95-
this.parentTop = document.querySelector('.c-toast-container--top')
96-
this.parentBottom = document.querySelector('.c-toast-container--bottom')
95+
this.parentTop = document.querySelector('.vue-toaster-container--top')
96+
this.parentBottom = document.querySelector('.vue-toaster-container--bottom')
9797
9898
if (this.parentTop && this.parentBottom) return
9999
100100
if (!this.parentTop) {
101101
this.parentTop = document.createElement('div')
102-
this.parentTop.className = 'c-toast-container c-toast-container--top'
102+
this.parentTop.className = 'vue-toaster-container vue-toaster-container--top'
103103
}
104104
105105
if (!this.parentBottom) {
106106
this.parentBottom = document.createElement('div')
107107
this.parentBottom.className =
108-
'c-toast-container c-toast-container--bottom'
108+
'vue-toaster-container vue-toaster-container--bottom'
109109
}
110110
},
111111
setDefaultCss() {
@@ -180,12 +180,12 @@ export default {
180180
return definePosition(
181181
this.position,
182182
{
183-
enter: 'fadeInDown',
184-
leave: 'fadeOut'
183+
enter: 'vue-toaster-fade-in-down',
184+
leave: 'vue-toaster-fade-out'
185185
},
186186
{
187-
enter: 'fadeInUp',
188-
leave: 'fadeOut'
187+
enter: 'vue-toaster-fade-in-up',
188+
leave: 'vue-toaster-fade-out'
189189
}
190190
)
191191
}
@@ -195,6 +195,7 @@ export default {
195195
}
196196
}
197197
</script>
198+
198199
<style lang="stylus">
199200
@import './themes/default/index.styl'
200201
.v--default-css

src/themes/default/animations.styl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
// Animations are taken from animate.css
22
// https://daneden.github.io/animate.css
33

4-
@keyframes fadeOut
4+
@keyframes vue-toaster-fade-out
55
from
66
opacity 1
77
to
88
opacity 0
99

10-
.fadeOut
11-
animation-name fadeOut
10+
.vue-toaster-fade-out
11+
animation-name vue-toaster-fade-out
1212

13-
@keyframes fadeInDown
13+
@keyframes vue-toaster-fade-in-down
1414
from
1515
opacity .5
1616
transform translate3d(0, -100%, 0)
1717
to
1818
opacity 1
1919
transform none
2020

21-
.fadeInDown
22-
animation-name fadeInDown
21+
.vue-toaster-fade-in-down
22+
animation-name vue-toaster-fade-in-down
2323

24-
@keyframes fadeInUp
24+
@keyframes vue-toaster-fade-in-up
2525
from
2626
opacity .5
2727
transform translate3d(0, 100%, 0)
2828
to
2929
opacity 1
3030
transform none
3131

32-
.fadeInUp
33-
animation-name fadeInUp
32+
.vue-toaster-fade-in-up
33+
animation-name vue-toaster-fade-in-up
3434

3535
// VUE
3636

37-
.fade-enter-active
37+
.vue-toaster-fade-enter-active
3838
transition opacity 300ms ease-in
39-
.fade-leave-active
39+
.vue-toaster-fade-leave-active
4040
transition opacity 150ms ease-out
4141

42-
.fade-enter,
43-
.fade-leave-to
42+
.vue-toaster-fade-enter,
43+
.vue-toaster-fade-leave-to
4444
opacity 0

src/themes/default/colors.styl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
for key, value in $toast-colors
2-
.c-toast--{key}
2+
.vue-toaster--{key}
33
background-color value

src/themes/default/toast-container.styl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.c-toast-container
1+
.vue-toaster-container
22
position fixed
33
display flex
44
top 0

src/themes/default/toast-positions.styl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.c-toast
1+
.vue-toaster
22
&--top, &--bottom
33
align-self center
44

src/themes/default/toast.styl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.c-toast
1+
.vue-toaster
22
display grid
33
align-items center
44
animation-duration 150ms

0 commit comments

Comments
 (0)