Commit f0e23800 authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett

Covert vue components to single file components

parent bf2210c1
<script>
const RepoFile = { const RepoFile = {
template: `
<tr v-if='!loading.tree || hasFiles' :class='{"active": activeFile.url === file.url}'>
<td>
<i class='fa' :class='file.icon' :style='{"margin-left": file.level * 10 + "px"}'></i>
<a :href='file.url' @click.prevent='linkClicked(file)' class='repo-file-name' :title='file.url'>{{file.name}}</a>
</td>
<td v-if='!isMini' class='hidden-sm hidden-xs'>
<div class='commit-message'>{{file.lastCommitMessage}}</div>
</td>
<td v-if='!isMini' class='hidden-xs'>
<span>{{file.lastCommitUpdate}}</span>
</td>
</tr>
`,
props: { props: {
name: 'repo-file', name: 'repo-file',
file: Object, file: Object,
...@@ -29,4 +16,23 @@ const RepoFile = { ...@@ -29,4 +16,23 @@ const RepoFile = {
}, },
}, },
}; };
export default RepoFile; export default RepoFile;
</script>
<template>
<tr v-if="!loading.tree || hasFiles" :class="{'active': activeFile.url === file.url}">
<td>
<i class="fa" :class="file.icon" :style="{'margin-left': file.level * 10 + 'px'}"></i>
<a :href="file.url" @click.prevent="linkClicked(file)" class="repo-file-name" :title="file.url">{{file.name}}</a>
</td>
<td v-if="!isMini" class="hidden-sm hidden-xs">
<div class="commit-message">{{file.lastCommitMessage}}</div>
</td>
<td v-if="!isMini" class="hidden-xs">
<span>{{file.lastCommitUpdate}}</span>
</td>
</tr>
</template>
const RepoFileOptions = {
template: `
<tr v-if='isMini' class='repo-file-options'>
<td>
<span class='title'>{{projectName}}</span>
<ul>
<li>
<a href='#' title='New File'>
<i class='fa fa-file-o'></i>
</a>
</li>
<li>
<a href='#' title='New Folder'>
<i class='fa fa-folder-o'></i>
</a>
</li>
</ul>
</td>
</tr>
`,
props: {
name: 'repo-file-options',
isMini: Boolean,
projectName: String,
},
};
export default RepoFileOptions;
<script>
const RepoFileOptions = {
props: {
name: 'repo-file-options',
isMini: Boolean,
projectName: String,
},
};
export default RepoFileOptions;
</script>
<template>
<tr v-if="isMini" class="repo-file-options">
<td>
<span class="title">{{projectName}}</span>
<ul>
<li>
<a href="#" title="New File">
<i class="fa fa-file-o"></i>
</a>
</li>
<li>
<a href="#" title="New Folder">
<i class="fa fa-folder-o"></i>
</a>
</li>
</ul>
</td>
</tr>
</template>
const RepoLoadingFile = {
template: `
<tr v-if='loading.tree && !hasFiles'>
<td>
<div class="animation-container animation-container-small">
<div v-for="n in 6" :class="lineOfCode(n)"></div>
</div>
</td>
<td v-if="!isMini" class='hidden-sm hidden-xs'>
<div class="animation-container">
<div v-for="n in 6" :class="lineOfCode(n)"></div>
</div>
</td>
<td v-if="!isMini" class='hidden-xs'>
<div class="animation-container animation-container-small">
<div v-for="n in 6" :class="lineOfCode(n)"></div>
</div>
</td>
</tr>
`,
methods: {
lineOfCode(n) {
return `line-of-code-${n}`;
},
},
props: {
loading: Object,
hasFiles: Boolean,
isMini: Boolean,
},
};
export default RepoLoadingFile;
<script>
const RepoLoadingFile = {
methods: {
lineOfCode(n) {
return `line-of-code-${n}`;
},
},
props: {
loading: Object,
hasFiles: Boolean,
isMini: Boolean,
},
};
export default RepoLoadingFile;
</script>
<template>
<tr v-if="loading.tree && !hasFiles">
<td>
<div class="animation-container animation-container-small">
<div v-for="n in 6" :class="lineOfCode(n)"></div>
</div>
</td>
<td v-if="!isMini" class="hidden-sm hidden-xs">
<div class="animation-container">
<div v-for="n in 6" :class="lineOfCode(n)"></div>
</div>
</td>
<td v-if="!isMini" class="hidden-xs">
<div class="animation-container animation-container-small">
<div v-for="n in 6" :class="lineOfCode(n)"></div>
</div>
</td>
</tr>
</template>
<script>
const RepoPreviousDirectory = { const RepoPreviousDirectory = {
template: `
<tr>
<td colspan='3'>
<a :href='prevUrl' @click.prevent='linkClicked(prevUrl)'>..</a>
</td>
</tr>
`,
props: { props: {
name: 'repo-previous-directory', name: 'repo-previous-directory',
prevUrl: String, prevUrl: String,
...@@ -17,4 +11,14 @@ const RepoPreviousDirectory = { ...@@ -17,4 +11,14 @@ const RepoPreviousDirectory = {
}, },
}, },
}; };
export default RepoPreviousDirectory; export default RepoPreviousDirectory;
</script>
<template>
<tr>
<td colspan="3">
<a :href="prevUrl" @click.prevent="linkClicked(prevUrl)">..</a>
</td>
</tr>
</template>
...@@ -2,10 +2,10 @@ import Vue from 'vue'; ...@@ -2,10 +2,10 @@ import Vue from 'vue';
import Service from './repo_service'; import Service from './repo_service';
import Helper from './repo_helper'; import Helper from './repo_helper';
import Store from './repo_store'; import Store from './repo_store';
import RepoPreviousDirectory from './repo_prev_directory'; import RepoPreviousDirectory from './repo_prev_directory.vue';
import RepoFileOptions from './repo_file_options'; import RepoFileOptions from './repo_file_options.vue';
import RepoFile from './repo_file'; import RepoFile from './repo_file.vue';
import RepoLoadingFile from './repo_loading_file'; import RepoLoadingFile from './repo_loading_file.vue';
import RepoMiniMixin from './repo_mini_mixin'; import RepoMiniMixin from './repo_mini_mixin';
export default class RepoSidebar { export default class RepoSidebar {
......
...@@ -55,7 +55,7 @@ const RepoStore = { ...@@ -55,7 +55,7 @@ const RepoStore = {
toggleRawPreview() { toggleRawPreview() {
this.activeFile.raw = !this.activeFile.raw; this.activeFile.raw = !this.activeFile.raw;
this.activeFileLabel = this.activeFile.raw ? 'Display rendered file' : 'Display source'; this.activeFileLabel = this.activeFile.raw ? 'Display rendered file' : 'Display source';
}, },
setActiveFiles(file) { setActiveFiles(file) {
......
import RepoHelper from './repo_helper'; <script>
import RepoStore from './repo_store'; import RepoStore from './repo_store';
const RepoTab = { const RepoTab = {
template: `
<li>
<a href='#' @click.prevent='xClicked(tab)' v-if='!tab.loading'>
<i class='fa' :class="changedClass"></i>
</a>
<a href='#' v-if='!tab.loading' :title='tab.url' @click.prevent='tabClicked(tab)'>{{tab.name}}</a>
<i v-if='tab.loading' class='fa fa-spinner fa-spin'></i>
</li>
`,
props: { props: {
name: 'repo-tab', name: 'repo-tab',
tab: Object, tab: Object,
...@@ -36,4 +27,18 @@ const RepoTab = { ...@@ -36,4 +27,18 @@ const RepoTab = {
}, },
}, },
}; };
export default RepoTab; export default RepoTab;
</script>
<template>
<li>
<a href="#" @click.prevent="xClicked(tab)" v-if="!tab.loading">
<i class="fa" :class="changedClass"></i>
</a>
<a href="#" v-if="!tab.loading" :title="tab.url" @click.prevent="tabClicked(tab)">{{tab.name}}</a>
<i v-if="tab.loading" class="fa fa-spinner fa-spin"></i>
</li>
</template>
import Vue from 'vue'; import Vue from 'vue';
import Store from './repo_store'; import Store from './repo_store';
import RepoTab from './repo_tab'; import RepoTab from './repo_tab.vue';
import RepoMiniMixin from './repo_mini_mixin'; import RepoMiniMixin from './repo_mini_mixin';
export default class RepoTabs { export default class RepoTabs {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment