Skip to content

Commit

Permalink
Create progressbar component
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Ambrosini <marcoambrosini@pm.me>
  • Loading branch information
marcoambrosini committed Jul 13, 2020
1 parent 9ec4cfe commit 226024f
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,49 +37,62 @@
<span v-if="isLoading"
class="preview loading" />
<strong>{{ name }}</strong>
<v-progress-linear v-if="isTemporaryUpload" color="#033" :value="uploadProgress" />
<ProgressBar v-if="isTemporaryUpload" :value="uploadProgress" />
</a>
</template>

<script>
import { generateUrl, imagePath } from '@nextcloud/router'
import ProgressBar from '../../../../ProgressBar'
export default {
name: 'FilePreview',
components: {
ProgressBar,
},
props: {
type: {
type: String,
required: true,
},
id: {
type: String,
required: true,
},
name: {
type: String,
required: true,
},
path: {
type: String,
default: '',
},
link: {
type: String,
default: '',
},
mimetype: {
type: String,
default: '',
},
previewAvailable: {
type: String,
default: 'no',
},
previewSize: {
type: Number,
default: 128,
},
// In case this component is used to display a file that is being uploaded
// this parameter is used to access the file upload status in the store
uploadId: {
Expand Down Expand Up @@ -205,6 +218,7 @@ export default {
<style lang="scss" scoped>
.container {
width: 100%;
/* The file preview can not be a block; otherwise it would fill the whole
width of the container and the loading icon would not be centered on the
image. */
Expand Down
80 changes: 80 additions & 0 deletions src/components/ProgressBar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<!--
- @copyright Copyright (c) 2020 Marco Ambrosini <marcoambrosini@pm.me>
-
- @author Marco Ambrosini <marcoambrosini@pm.me>
-
- @license GNU AGPL version 3 or any later version
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

<docs>
</docs>

<template>
<div class="progress-bar">
<div class="progress-bar__loaded" :style="progressLoadedWidth" />
<div class="progress-bar__total" />
</div>
</template>

<script>
export default {
name: 'ProgressBar',
props: {
/**
* An integer between 1 and 100
*/
value: {
type: Number,
required: true,
},
},
computed: {
progressLoadedWidth() {
return {
width: `${this.value}px`,
}
},
},
}
</script>

<style lang="scss" scoped>
.progress-bar {
position: relative;
width: 100%;
&__loaded,
&__total {
position: absolute;
top: 0;
left: 0;
height: 4px;
}
&__loaded {
background-color: var(--color-primary-element-light);
z-index: 1;
}
&__total {
width: 100%;
background-color: var(--color-box-shadow);;
}
}
</style>

0 comments on commit 226024f

Please sign in to comment.