Skip to content

Instantly share code, notes, and snippets.

@johnleider
Created September 11, 2018 19:08
Show Gist options
  • Save johnleider/e5e5d18be791c6a8174b9a280bde5e52 to your computer and use it in GitHub Desktop.
Save johnleider/e5e5d18be791c6a8174b9a280bde5e52 to your computer and use it in GitHub Desktop.
<template>
<v-app>
<v-content class="pa-5">
<v-treeview
v-model="tree"
:open="open"
:items="items"
item-key="name"
open-on-click
>
<template slot="prepend" slot-scope="{ item, open, leaf }">
<v-icon v-if="!item.file">
{{ open ? 'mdi-folder-open' : 'mdi-folder' }}
</v-icon>
<v-icon v-else>
{{ files[item.file] }}
</v-icon>
</template>
</v-treeview>
</v-content>
</v-app>
</template>
<script>
export default {
data: () => ({
open: ['public'],
files: {
html: 'mdi-language-html5',
js: 'mdi-nodejs',
json: 'mdi-json',
md: 'mdi-markdown',
pdf: 'mdi-file-pdf',
png: 'mdi-file-image',
txt: 'mdi-file-document-outline',
xls: 'mdi-file-excel'
},
tree: [],
items: [
{
name: '.git'
},
{
name: 'node_modules'
},
{
name: 'public',
children: [
{
name: 'static',
children: [{
name: 'logo.png',
file: 'png'
}]
},
{
name: 'favicon.ico',
file: 'png'
},
{
name: 'index.html',
file: 'html'
}
]
},
{
name: '.gitignore',
file: 'txt',
},
{
name: 'babel.config.js',
file: 'js'
},
{
name: 'package.json',
file: 'json'
},
{
name: 'README.md',
file: 'md'
},
{
name: 'vue.config.js',
file: 'js'
},
{
name: 'yarn.lock',
file: 'txt'
}
]
})
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment