summaryrefslogtreecommitdiff
path: root/src/client/app/mobile/views/components/mute-button.vue
blob: 316fbda8f1e714826502502de03a346b9ff644a0 (plain)
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
<template>
<button
  class="mk-mute-button"
  :class="{ active: user.isMuted }"
  @click="onClick">
  <span v-if="!user.isMuted">%fa:eye-slash% %i18n:@mute%</span>
  <span v-else>%fa:eye% %i18n:@unmute%</span>
</button>
</template>

<script lang="ts">
import Vue from 'vue'
export default Vue.extend({
  props: {
    user: {
      type: Object,
      required: true
    }
  },
  methods: {
    onClick() {
      if (!this.user.isMuted) {
        this.mute();
      } else {
        this.unmute();
      }
    },
    mute() {
      (this as any).api('mute/create', { userId: this.user.id})
        .then(() => { this.user.isMuted = true })
        .catch(() => { alert('error')})
    },
    unmute() {
      (this as any).api('mute/delete', { userId: this.user.id })
        .then(() => { this.user.isMuted = false })
        .catch(() => { alert('error') })
    }
  },
})
</script>


<style lang="stylus" scoped>


.mk-mute-button
  display block
  user-select none
  cursor pointer
  padding 0 16px
  margin 0
  min-width 100px
  line-height 36px
  font-size 14px
  font-weight bold
  color var(--primary)
  background transparent
  outline none
  border solid 1px var(--primary)
  border-radius 36px

  &:hover
    background var(--primaryAlpha01)

  &:active
    background var(--primaryAlpha02)

  &.active
    color var(--primaryForeground)
    background var(--primary)

    &:hover
      background var(--primaryLighten10)
      border-color var(--primaryLighten10)
    &:active
      background var(--primaryDarken10)
      border-color var(--primaryDarken10)

</style>