Skip to content

Commit 904ae2a

Browse files
Merge pull request #29 from nextcloud/fixes/design/img-bg_border-radius_use-modal-max
Fixes/design/img bg border radius use modal max
2 parents e0d1ad5 + 40a3e05 commit 904ae2a

6 files changed

Lines changed: 101 additions & 27 deletions

File tree

apps/viewer/package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/viewer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"debounce": "^1.2.0",
3939
"mime-types": "^2.1.22",
4040
"nextcloud-server": "^0.15.9",
41-
"nextcloud-vue": "^0.9.0",
41+
"nextcloud-vue": "^0.9.1",
4242
"vue": "^2.6.8",
4343
"vue-async-computed": "^3.6.1"
4444
},

apps/viewer/src/components/Images.vue

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,13 @@ img {
9494
max-height: 100%;
9595
align-self: center;
9696
justify-self: center;
97-
background-image: linear-gradient(45deg, #{$checkered-color} 25%, transparent 25%),
98-
linear-gradient(45deg, transparent 75%, #{$checkered-color} 75%),
99-
linear-gradient(45deg, transparent 75%, #{$checkered-color} 75%),
100-
linear-gradient(45deg, #{$checkered-color} 25%, #fff 25%);
101-
background-size: 2 * $checkered-size 2 * $checkered-size;
102-
background-position: 0 0, 0 0, -#{$checkered-size} -#{$checkered-size}, $checkered-size $checkered-size;
97+
&:hover {
98+
background-image: linear-gradient(45deg, #{$checkered-color} 25%, transparent 25%),
99+
linear-gradient(45deg, transparent 75%, #{$checkered-color} 75%),
100+
linear-gradient(45deg, transparent 75%, #{$checkered-color} 75%),
101+
linear-gradient(45deg, #{$checkered-color} 25%, #fff 25%);
102+
background-size: 2 * $checkered-size 2 * $checkered-size;
103+
background-position: 0 0, 0 0, -#{$checkered-size} -#{$checkered-size}, $checkered-size $checkered-size;
104+
}
103105
}
104106
</style>

apps/viewer/src/mixins/Mime.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ export default {
6464
this.$emit('loaded', event)
6565
},
6666
updateHeightWidth(contentHeight, contentWidth) {
67-
const modalContainer = this.$parent.$el.querySelector('#modal-wrapper')
67+
const modalContainer = this.$parent.$el.querySelector('.modal-wrapper')
6868
if (modalContainer) {
69-
// ! modal container have maxHeight:80% AND maxWidth: 900px
70-
const parentHeight = Math.round(modalContainer.clientHeight * 0.8) - 50 // minus header
71-
const parentWidth = modalContainer.clientWidth > 900
72-
? 900
73-
: modalContainer.clientWidth
69+
const wrapperMaxHeight = window.getComputedStyle(modalContainer.children[0]).maxHeight.replace('%', '')
70+
const wrapperMaxWidth = window.getComputedStyle(modalContainer.children[0]).maxWidth.replace('%', '')
71+
72+
const parentHeight = Math.round(modalContainer.clientHeight * Number(wrapperMaxHeight) / 100) - 50 // minus header
73+
const parentWidth = Math.round(modalContainer.clientWidth * Number(wrapperMaxWidth) / 100)
7474

7575
const heightRatio = parentHeight / contentHeight
7676
const widthRatio = parentWidth / contentWidth

apps/viewer/src/services/FileList.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222

2323
import axios from 'axios'
24+
import { generateRemoteUrl } from 'nextcloud-server/dist/router'
2425

2526
/**
2627
*
@@ -31,7 +32,7 @@ import axios from 'axios'
3132
export default async function(user, path, mimes) {
3233
const response = await axios({
3334
method: 'PROPFIND',
34-
url: `/remote.php/dav/files/${user}${path}`,
35+
url: generateRemoteUrl(`/dav/files/${user}${path}`),
3536
headers: {
3637
requesttoken: OC.requestToken,
3738
'content-Type': 'text/xml'

apps/viewer/src/views/Viewer.vue

Lines changed: 78 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,17 @@
2323
<template>
2424
<modal
2525
v-if="currentFile.modal"
26+
id="viewer-content"
2627
:class="{'icon-loading': loading}"
2728
:view="currentFile.modal"
2829
:actions="actions"
2930
:enable-slideshow="true"
3031
:has-previous="hasPrevious"
3132
:has-next="hasNext"
3233
:title="currentFileName"
34+
:disable-swipe="disableSwipe"
35+
:size="isMobile ? 'full' : 'large'"
36+
:style="{width: showSidebar ? `calc(100% - ${sidebarWidth}px)` : null}"
3337
@close="close"
3438
@previous="previous"
3539
@next="next">
@@ -84,6 +88,7 @@ import Mime from 'mime-types'
8488
import Vue from 'vue'
8589
8690
import Modal from 'nextcloud-vue/dist/Components/Modal'
91+
import { generateRemoteUrl } from 'nextcloud-server/dist/router'
8792
8893
import Error from 'Components/Error'
8994
import FileList from 'Services/FileList'
@@ -111,11 +116,15 @@ export default {
111116
112117
fileList: [],
113118
114-
failed: false,
119+
isMobile: window.outerWidth < 768,
120+
showSidebar: false,
121+
sidebarWidth: 0,
115122
123+
disableSwipe: false,
124+
failed: false,
116125
loading: true,
117126
118-
root: `/remote.php/dav/files/${OC.getCurrentUser().uid}`
127+
root: generateRemoteUrl(`/dav/files/${OC.getCurrentUser().uid}`)
119128
}),
120129
121130
computed: {
@@ -160,6 +169,11 @@ export default {
160169
})
161170
})
162171
172+
window.addEventListener('resize', this.onResize)
173+
},
174+
175+
beforeDestroy() {
176+
window.removeEventListener('resize', this.onResize)
163177
},
164178
165179
methods: {
@@ -172,6 +186,10 @@ export default {
172186
async openFile(fileName, fileInfo) {
173187
this.loading = true
174188
this.failed = false
189+
190+
// prevent scrolling while opened
191+
document.body.style.overflow = 'hidden'
192+
175193
const relativePath = `${fileInfo.dir !== '/' ? fileInfo.dir : ''}/${fileName}`
176194
const path = `${this.root}${relativePath}`
177195
@@ -193,7 +211,7 @@ export default {
193211
this.fileList = await FileList(OC.getCurrentUser().uid, fileInfo.dir, mimes)
194212
195213
// store current position
196-
this.currentIndex = this.fileList.findIndex(file => decodeURI(file.href) === this.root + relativePath)
214+
this.currentIndex = this.fileList.findIndex(file => file.name === fileName)
197215
198216
this.updatePreviousNext()
199217
},
@@ -362,6 +380,9 @@ export default {
362380
this.currentFile = {}
363381
this.currentModal = null
364382
this.fileList = []
383+
this.hideAppsSidebar()
384+
// restore default
385+
document.body.style.overflow = null
365386
},
366387
367388
/**
@@ -416,16 +437,56 @@ export default {
416437
showSharingSidebar() {
417438
// Open the sidebar sharing tab
418439
OCA.Files.App.fileList.showDetailsView(this.currentFileName, 'shareTabView')
419-
this.close()
440+
this.showAppsSidebar()
441+
},
442+
443+
showAppsSidebar() {
444+
this.showSidebar = true
445+
const sidebar = document.getElementById('app-sidebar')
446+
if (sidebar) {
447+
sidebar.classList.add('app-sidebar--full')
448+
}
449+
450+
// overriding closing function
451+
const origHideAppsSidebar = OC.Apps.hideAppSidebar
452+
OC.Apps.hideAppSidebar = ($el) => {
453+
this.hideAppsSidebar()
454+
origHideAppsSidebar($el)
455+
}
456+
457+
this.sidebarWidth = sidebar.offsetWidth
458+
},
459+
460+
hideAppsSidebar() {
461+
this.showSidebar = false
462+
const sidebar = document.getElementById('app-sidebar')
463+
if (sidebar) {
464+
sidebar.classList.remove('app-sidebar--full')
465+
}
466+
},
467+
468+
onResize(event) {
469+
// Update mobile mode
470+
this.isMobile = window.outerWidth < 768
471+
// update sidebar width
472+
const sidebar = document.getElementById('app-sidebar')
473+
if (sidebar) {
474+
this.sidebarWidth = sidebar.offsetWidth
475+
}
420476
}
421477
}
422478
}
423479
</script>
424480

425481
<style lang="scss">
426-
#modal-mask #modal-container {
427-
display: flex !important;
428-
width: auto !important;
482+
#viewer-content.modal-mask {
483+
transition: width ease 100ms;
484+
.modal-container {
485+
display: flex !important;
486+
width: auto !important;
487+
border-radius: 0 !important;
488+
background-color: black;
489+
}
429490
}
430491
431492
.component-fade-enter-active, .component-fade-leave-active {
@@ -445,4 +506,14 @@ export default {
445506
transition: height 100ms ease,
446507
width 100ms ease;
447508
}
509+
510+
#app-sidebar.app-sidebar--full {
511+
position: absolute;
512+
top: 0;
513+
height: 100%;
514+
z-index: 15000;
515+
.thumbnailContainer {
516+
display: none;
517+
}
518+
}
448519
</style>

0 commit comments

Comments
 (0)