OtherNodes.vue 1.55 KB
Newer Older
Adam Procter's avatar
Adam Procter committed
1
<template>
Adam Procter's avatar
Adam Procter committed
2
3
4
5
  <div
    class="nodes"
    v-for="(nodes, index) in otherNodes.otherNodes"
    :key="index"
Adam Procter's avatar
Adam Procter committed
6
7
8
    :style="{
      backgroundColor: nodes.node_color,
    }"
Adam Procter's avatar
Adam Procter committed
9
  >
Adam Procter's avatar
Adam Procter committed
10
11
12
13
14
    <p
      class="readmode"
      :id="nodes.node_id"
      v-html="marked(nodes.node_text)"
    ></p>
Adam Procter's avatar
Adam Procter committed
15
16
17
18
19
20
21
22
23
24
    <button @click="openEmoji" class="emojiopen">☺️</button>
    <VuemojiPicker
      v-show="showEmoji"
      class="emojipicker"
      @emojiClick="handleEmojiClick"
      :pickerStyle="{
        borderSize: '0',
        background: nodes.node_color,
      }"
    />
Adam Procter's avatar
Adam Procter committed
25
26
27
28
29
30
  </div>
</template>

<script>
// @ is an alias to /src
import { mapState } from 'vuex'
Adam Procter's avatar
Adam Procter committed
31
import marked from 'marked'
Adam Procter's avatar
Adam Procter committed
32
import { VuemojiPicker } from 'vuemoji-picker'
Adam Procter's avatar
Adam Procter committed
33
34
35
36

export default {
  name: 'OtherNodes',

Adam Procter's avatar
Adam Procter committed
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
  props: {
    // these are for the emoji styling
    // https://github.com/wobsoriano/vuemoji-picker
    // isDark: Boolean,
    pickerStyle: Object,
  },

  data: function () {
    return {
      showEmoji: false,
    }
  },

  components: {
    VuemojiPicker,
  },

Adam Procter's avatar
Adam Procter committed
54
55
56
57
58
59
60
  computed: {
    ...mapState({
      otherNodes: (state) => state.otherNodes,
    }),
  },

  mounted() {
61
    this.$store.dispatch('getOthernodes')
Adam Procter's avatar
Adam Procter committed
62
    setTimeout(this.loadData, 500)
Adam Procter's avatar
Adam Procter committed
63
    setInterval(this.loadData, 5000)
Adam Procter's avatar
Adam Procter committed
64
65
66
  },

  methods: {
Adam Procter's avatar
Adam Procter committed
67
68
69
70
71
72
73
74
    handleEmojiClick(detail) {
      console.log(detail)
    },

    openEmoji() {
      this.showEmoji = !this.showEmoji
    },

Adam Procter's avatar
Adam Procter committed
75
    loadData() {
76
      this.$store.dispatch('setOthernodes')
Adam Procter's avatar
Adam Procter committed
77
    },
Adam Procter's avatar
Adam Procter committed
78
    marked,
Adam Procter's avatar
Adam Procter committed
79
80
81
82
  },
}
</script>

Adam Procter's avatar
Adam Procter committed
83
<style scoped>
Adam Procter's avatar
Adam Procter committed
84
.nodes {
Adam Procter's avatar
Adam Procter committed
85
  border: 2px solid black;
Adam Procter's avatar
Adam Procter committed
86
}
Adam Procter's avatar
Adam Procter committed
87
88
89
90

.emojiopen {
  font-size: 1.5em;
}
Adam Procter's avatar
Adam Procter committed
91
</style>