๐Ÿ“ฆ vuetifyjs / material-kit-theme

๐Ÿ“„ Drawer.vue ยท 121 lines
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
113
114
115
116
117
118
119
120
121<template>
  <v-navigation-drawer
    v-model="drawer"
    app
    class="grey darken-4"
    floating
    width="200"
  >
    <v-list color="transparent">
      <v-list-item class="mb-4">
        <v-list-item-avatar tile>
          <v-img
            src="https://cdn.vuetifyjs.com/images/logos/v-alt.svg"
            contain
          />
        </v-list-item-avatar>

        <v-list-item-title>Vuetify</v-list-item-title>
      </v-list-item>

      <template v-for="(item, i) in items">
        <v-list-item
          v-if="!item.spacer"
          :key="`tile-${i}`"
          :to="item.to"
          :value="item.value"
          color="grey"
          exact
          v-on="item.click && {
            'click': item.click
          }"
        >
          <v-list-item-avatar>
            <v-icon
              style="color: inherit"
              v-text="item.icon"
            />
          </v-list-item-avatar>

          <v-list-item-content>
            <v-list-item-title v-text="item.text" />
          </v-list-item-content>
        </v-list-item>

        <div
          v-else
          :key="`divider-${i}`"
          class="my-auto"
        />
      </template>
    </v-list>
  </v-navigation-drawer>
</template>

<script>
  // Utilities
  import {
    mapMutations,
    mapState,
  } from 'vuex'

  export default {
    name: 'CoreDrawer',

    computed: {
      ...mapState('downloads', {
        downloadDrawer: 'drawer',
      }),
      drawer: {
        get () {
          return this.$store.state.app.drawer
        },
        set (val) {
          this.setDrawer(val)
        },
      },
      items () {
        return [
          {
            icon: 'mdi-home-variant',
            text: 'Home',
            to: '/',
          },
          {
            icon: 'mdi-fire',
            text: 'Store',
            to: '/store',
          },
          {
            icon: 'mdi-view-grid',
            text: 'Library',
            to: '/library',
          },
          { spacer: true },
          {
            icon: 'mdi-download',
            text: 'Downloads',
            value: this.downloadDrawer,
            click: () => {
              this.$vuetify.breakpoint.smAndDown && this.setDrawer(false)
              this.toggleDownloadDrawer()
            },
          },
          {
            icon: 'mdi-settings',
            text: 'Settings',
            to: '/settings',
          },
        ]
      },
    },

    methods: {
      ...mapMutations('app', ['setDrawer']),
      ...mapMutations('downloads', {
        toggleDownloadDrawer: 'toggleDrawer',
      }),
    },
  }
</script>