all files / src/snackbar/ snackbar.vue

0% Statements 0/4
100% Branches 0/0
100% Functions 0/0
0% Lines 0/4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112                                                                                                                                                                                                                               
<template>
<transition name="mu-snackbar">
  <div class="mu-snackbar" v-clickoutside="clickOutSide" :style="{'z-index': zIndex}">
    <div class="mu-snackbar-message">
      {{message}}
    </div>
    <flat-button v-if="action" @click="handleActionClick" class="mu-snackbar-action" :color="actionColor"  rippleColor="#FFF" :rippleOpacity="0.3" secondary :label="action"/>
  </div>
</transition>
</template>
 
<script>
import flatButton from '../flatButton'
import {getZIndex} from '../internal/popup/utils'
import clickoutside from '../internal/clickoutside'
export default {
  name: 'mu-snackbar',
  props: {
    action: {
      type: String
    },
    actionColor: {
      type: String
    },
    message: {
      type: String
    }
  },
  data () {
    return {
      zIndex: getZIndex()
    }
  },
  methods: {
    clickOutSide () {
      this.$emit('close', 'clickOutSide')
    },
    handleActionClick () {
      this.$emit('actionClick')
      this.$emit('action-click')
    }
  },
  components: {
    'flat-button': flatButton
  },
  directives: {
    clickoutside
  }
}
</script>
 
<style lang="less">
@import "../styles/import.less";
.mu-snackbar {
  position: fixed;
  bottom: 0;
  left: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: @alternateTextColor;
  background-color: @textColor;
  padding: 0px 24px;
  min-height: 48px;
  width: 100%;
  max-width: 568px;
}
 
.mu-snackbar-action{
  margin: 0 -16px 0 24px;
}
 
.mu-snackbar-message {
  display: flex;
  flex: 1;
  padding-top: 8px;
  padding-bottom: 8px;
}
 
@media only screen and (max-width: 992px) and (min-width: 601px) {
  .mu-snackbar {
    width: auto;
    min-width: 288px;
    left: 5%;
    bottom: 7%;
  }
}
@media only screen and (min-width: 993px) {
  .mu-snackbar {
    width: auto;
    min-width: 8%;
    top: 10%;
    right: 7%;
    left: auto;
    bottom: auto;
    min-width: 288px;
  }
}
 
.mu-snackbar-enter-active,.mu-snackbar-leave-active{
  transition: transform .4s @easeOutFunction, opacity .4s @easeOutFunction;
  backface-visibility: hidden;
}
 
.mu-snackbar-enter,
.mu-snackbar-leave-active{
  transform: translate3d(0, 100%, 0);
  opacity: 0;
}
 
</style>