Skip to content

Commit

Permalink
Fix default css import #8, #12
Browse files Browse the repository at this point in the history
  • Loading branch information
jprodrigues70 committed Feb 6, 2021
1 parent 438b931 commit 712c74d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
4 changes: 3 additions & 1 deletion example/src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@

<span
class="c-code--object-line"
v-if="options.maxToasts !== false"
v-if="options.maxToasts || options.maxToasts === 0"
>
<code>max:</code>
<code class="c-code--number">{{ options.maxToasts }}</code>
Expand Down Expand Up @@ -228,8 +228,10 @@ export default {
onClick: this.onClick
}
typeof type === 'string' && (options.type = type)
typeof this.options.maxToasts === 'string' &&
(this.options.maxToasts = parseInt(this.options.maxToasts))
this.$toast.show(this.message, {
...options,
...this.options
Expand Down
17 changes: 12 additions & 5 deletions src/Toaster.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,11 @@ export default {
},
beforeMount() {
this.createParents()
this.setDefaultCss()
this.setupContainer()
},
mounted() {
this.showNotice()
if (this.useDefaultCss) {
require('./themes/default/index.styl')
}
eventBus.$on('toast-clear', this.close)
},
methods: {
Expand All @@ -112,6 +108,11 @@ export default {
'c-toast-container c-toast-container--bottom'
}
},
setDefaultCss() {
const type = this.useDefaultCss ? 'add' : 'remove'
this.parentTop.classList[type]('v--default-css')
this.parentBottom.classList[type]('v--default-css')
},
setupContainer() {
const container = document.body
container.appendChild(this.parentTop)
Expand Down Expand Up @@ -194,3 +195,9 @@ export default {
}
}
</script>
<style lang="stylus">
@import './themes/default/index.styl'
.v--default-css
@import './colors'
@import './toast'
</style>
3 changes: 1 addition & 2 deletions src/themes/default/index.styl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@import './variables';
@import './colors';
@import './animations';
@import './toast-container';
@import './toast';
@import './toast-positions';
9 changes: 9 additions & 0 deletions src/themes/default/toast-positions.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.c-toast
&--top, &--bottom
align-self center

&--top-right, &--bottom-right
align-self flex-end

&--top-left, &--bottom-left
align-self flex-start
9 changes: 0 additions & 9 deletions src/themes/default/toast.styl
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,3 @@
font-family: Avenir, Helvetica, Arial, sans-serif;
padding 0.5em 2em
word-break break-word

&--top, &--bottom
align-self center

&--top-right, &--bottom-right
align-self flex-end

&--top-left, &--bottom-left
align-self flex-start

0 comments on commit 712c74d

Please sign in to comment.