chore: header bar component

This commit is contained in:
Ramires Viana
2021-02-25 18:37:07 +00:00
parent 62fff5ca60
commit 95811e99bc
17 changed files with 415 additions and 448 deletions

View File

@@ -1,18 +1,13 @@
<template>
<div id="editor-container">
<div class="bar">
<button @click="back" :title="$t('files.closePreview')" :aria-label="$t('files.closePreview')" id="close" class="action">
<i class="material-icons">close</i>
</button>
<header-bar>
<action icon="close" :label="$t('buttons.close')" @action="close()" />
<title>{{ req.name }}</title>
<div class="title">
<span>{{ req.name }}</span>
</div>
<button @click="save" v-show="user.perm.modify" :aria-label="$t('buttons.save')" :title="$t('buttons.save')" id="save-button" class="action">
<i class="material-icons">save</i>
</button>
</div>
<template #actions>
<action id="save-button" icon="save" :label="$t('buttons.save')" @action="save()" />
</template>
</header-bar>
<div id="breadcrumbs">
<span><i class="material-icons">home</i></span>
@@ -30,16 +25,23 @@
<script>
import { mapState } from 'vuex'
import { files as api } from '@/api'
import { theme } from '@/utils/constants'
import buttons from '@/utils/buttons'
import url from '@/utils/url'
import ace from 'ace-builds/src-min-noconflict/ace.js'
import modelist from 'ace-builds/src-min-noconflict/ext-modelist.js'
import 'ace-builds/webpack-resolver'
import { theme } from '@/utils/constants'
import HeaderBar from '@/components/header/HeaderBar'
import Action from '@/components/header/Action'
export default {
name: 'editor',
components: {
HeaderBar,
Action
},
data: function () {
return {}
},
@@ -82,7 +84,7 @@ export default {
window.removeEventListener('keydown', this.keyEvent)
this.editor.destroy();
},
mounted: function () {
mounted: function () {
const fileContent = this.req.content || '';
this.editor = ace.edit('editor', {
@@ -126,6 +128,10 @@ export default {
buttons.done(button)
this.$showError(e)
}
},
close () {
let uri = url.removeLastDir(this.$route.path) + '/'
this.$router.push({ path: uri })
}
}
}

View File

@@ -1,24 +1,17 @@
<template>
<div id="previewer" @mousemove="toggleNavigation" @touchstart="toggleNavigation">
<div class="bar">
<button @click="back" class="action" :title="$t('files.closePreview')" :aria-label="$t('files.closePreview')" id="close">
<i class="material-icons">close</i>
</button>
<header-bar>
<action icon="close" :label="$t('buttons.close')" @action="close()" />
<title>{{ name }}</title>
<preview-size-button v-if="isResizeEnabled && req.type === 'image'" @change-size="toggleSize" v-bind:size="fullSize" :disabled="loading" />
<div class="title">{{ this.name }}</div>
<preview-size-button v-if="isResizeEnabled && this.req.type === 'image'" @change-size="toggleSize" v-bind:size="fullSize" :disabled="loading"></preview-size-button>
<button @click="openMore" id="more" :aria-label="$t('buttons.more')" :title="$t('buttons.more')" class="action">
<i class="material-icons">more_vert</i>
</button>
<div id="dropdown" :class="{ active : showMore }">
<rename-button :disabled="loading" v-if="user.perm.rename"></rename-button>
<delete-button :disabled="loading" v-if="user.perm.delete"></delete-button>
<download-button :disabled="loading" v-if="user.perm.download"></download-button>
<info-button :disabled="loading"></info-button>
</div>
</div>
<template #actions>
<rename-button :disabled="loading" v-if="user.perm.rename" />
<delete-button :disabled="loading" v-if="user.perm.delete" />
<download-button :disabled="loading" v-if="user.perm.download" />
<info-button :disabled="loading" />
</template>
</header-bar>
<div class="loading" v-if="loading">
<div class="spinner">
@@ -56,17 +49,18 @@
<button @click="next" @mouseover="hoverNav = true" @mouseleave="hoverNav = false" :class="{ hidden: !hasNext || !showNav }" :aria-label="$t('buttons.next')" :title="$t('buttons.next')">
<i class="material-icons">chevron_right</i>
</button>
<div v-show="showMore" @click="resetPrompts" class="overlay"></div>
</div>
</template>
<script>
import { mapState } from 'vuex'
import url from '@/utils/url'
import { baseURL, resizePreview } from '@/utils/constants'
import { files as api } from '@/api'
import { baseURL, resizePreview } from '@/utils/constants'
import url from '@/utils/url'
import throttle from 'lodash.throttle'
import HeaderBar from '@/components/header/HeaderBar'
import Action from '@/components/header/Action'
import PreviewSizeButton from '@/components/buttons/PreviewSize'
import InfoButton from '@/components/buttons/Info'
import DeleteButton from '@/components/buttons/Delete'
@@ -84,6 +78,8 @@ const mediaTypes = [
export default {
name: 'preview',
components: {
HeaderBar,
Action,
PreviewSizeButton,
InfoButton,
DeleteButton,
@@ -251,7 +247,11 @@ export default {
this.showNav = false || this.hoverNav
this.navTimeout = null
}, 1500);
}, 500)
}, 500),
close () {
let uri = url.removeLastDir(this.$route.path) + '/'
this.$router.push({ path: uri })
}
}
}
</script>