Skip to content

Commit dd7cb1f

Browse files
committed
Fix component click outside and cleanup structure
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
1 parent e925b37 commit dd7cb1f

1 file changed

Lines changed: 95 additions & 71 deletions

File tree

src/views/Viewer.vue

Lines changed: 95 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<template>
2525
<Modal
2626
v-if="initiated || currentFile.modal"
27-
id="viewer-content"
27+
id="viewer"
2828
:class="{'icon-loading': !currentFile.loaded && !currentFile.failed}"
2929
:clear-view-delay="isTesting ? -1 : 5000 /* prevent cypress timeouts */"
3030
:dark="true"
@@ -37,6 +37,7 @@
3737
:style="{width: isSidebarShown ? `calc(100% - ${sidebarWidth}px)` : null}"
3838
:title="currentFile.basename"
3939
:view="currentFile.modal"
40+
class="viewer"
4041
@close="close"
4142
@previous="previous"
4243
@next="next">
@@ -58,54 +59,56 @@
5859
</ActionButton>
5960
</template>
6061

61-
<!-- PREVIOUS -->
62-
<component
63-
:is="previousFile.modal"
64-
v-if="previousFile && !previousFile.failed"
65-
:key="previousFile.fileid"
66-
ref="previous-content"
67-
v-bind="previousFile"
68-
:file-list="fileList"
69-
class="hidden-visually file-view"
70-
@error="previousFailed" />
71-
<Error
72-
v-else-if="previousFile"
73-
class="hidden-visually"
74-
:name="previousFile.basename" />
75-
76-
<!-- CURRENT -->
77-
<component
78-
:is="currentFile.modal"
79-
v-if="!currentFile.failed"
80-
:key="currentFile.fileid"
81-
ref="content"
82-
:active="true"
83-
:can-swipe.sync="canSwipe"
84-
v-bind="currentFile"
85-
:file-list="fileList"
86-
:is-full-screen="isFullscreen"
87-
:loaded.sync="currentFile.loaded"
88-
:is-sidebar-shown="isSidebarShown"
89-
class="file-view active"
90-
@error="currentFailed" />
91-
<Error
92-
v-else
93-
:name="currentFile.basename" />
94-
95-
<!-- NEXT -->
96-
<component
97-
:is="nextFile.modal"
98-
v-if="nextFile && !nextFile.failed"
99-
:key="nextFile.fileid"
100-
ref="next-content"
101-
v-bind="nextFile"
102-
:file-list="fileList"
103-
class="hidden-visually file-view"
104-
@error="nextFailed" />
105-
<Error
106-
v-else-if="nextFile"
107-
class="hidden-visually"
108-
:name="nextFile.basename" />
62+
<div class="viewer__content" @click.self.exact="close">
63+
<!-- PREVIOUS -->
64+
<component
65+
:is="previousFile.modal"
66+
v-if="previousFile && !previousFile.failed"
67+
:key="previousFile.fileid"
68+
ref="previous-content"
69+
v-bind="previousFile"
70+
:file-list="fileList"
71+
class="viewer__file--hidden viewer__file"
72+
@error="previousFailed" />
73+
<Error
74+
v-else-if="previousFile"
75+
class="hidden-visually"
76+
:name="previousFile.basename" />
77+
78+
<!-- CURRENT -->
79+
<component
80+
:is="currentFile.modal"
81+
v-if="!currentFile.failed"
82+
:key="currentFile.fileid"
83+
ref="content"
84+
:active="true"
85+
:can-swipe.sync="canSwipe"
86+
v-bind="currentFile"
87+
:file-list="fileList"
88+
:is-full-screen="isFullscreen"
89+
:loaded.sync="currentFile.loaded"
90+
:is-sidebar-shown="isSidebarShown"
91+
class="viewer__file viewer__file--active"
92+
@error="currentFailed" />
93+
<Error
94+
v-else
95+
:name="currentFile.basename" />
96+
97+
<!-- NEXT -->
98+
<component
99+
:is="nextFile.modal"
100+
v-if="nextFile && !nextFile.failed"
101+
:key="nextFile.fileid"
102+
ref="next-content"
103+
v-bind="nextFile"
104+
:file-list="fileList"
105+
class="viewer__file--hidden viewer__file"
106+
@error="nextFailed" />
107+
<Error
108+
v-else-if="nextFile"
109+
class="hidden-visually"
110+
:name="nextFile.basename" />
111+
</div>
109112
</Modal>
110113
</template>
111114

@@ -691,6 +694,7 @@ export default {
691694
692695
async showSidebar() {
693696
// Open the sidebar sharing tab
697+
// TODO: also hide figure, needs a proper method for it in server Sidebar
694698
await OCA.Files.Sidebar.open(this.currentFile.filename)
695699
this.showAppsSidebar()
696700
},
@@ -752,23 +756,50 @@ export default {
752756
}
753757
</script>
754758
755-
<style lang="scss">
756-
#viewer-content.modal-mask {
757-
transition: width ease 100ms;
758-
.modal-container {
759-
display: flex !important;
760-
border-radius: 0 !important;
759+
<style lang="scss" scoped>
760+
.viewer {
761+
&.modal-mask {
762+
transition: width ease 100ms;
763+
}
764+
765+
::v-deep .modal-container,
766+
&__content {
767+
// center views
768+
display: flex;
769+
align-items: center;
770+
justify-content: center;
771+
}
772+
773+
::v-deep .modal-container {
774+
border-radius: 0;
761775
// let the mime components manage their own background-color
762776
background-color: transparent;
763-
justify-content: center;
764-
align-items: center;
765-
// Override max-height & max-width
766-
width: 85% !important;
767-
height: 90% !important;
777+
}
778+
779+
&__content {
780+
width: 100%;
781+
height: 100%;
782+
cursor: pointer;
783+
}
784+
785+
&__file {
786+
transition: height 100ms ease,
787+
width 100ms ease;
788+
789+
// display on page but make it invisible
790+
&--hidden {
791+
position: absolute;
792+
z-index: -1;
793+
left: -10000px;
794+
}
768795
}
769796
}
770797
771-
.component-fade-enter-active, .component-fade-leave-active {
798+
</style>
799+
800+
<style lang="scss">
801+
.component-fade-enter-active,
802+
.component-fade-leave-active {
772803
transition: opacity .3s ease;
773804
}
774805
@@ -781,20 +812,12 @@ export default {
781812
background-image: url('../assets/menu-sidebar-white.svg');
782813
}
783814
784-
.file-view {
785-
transition: height 100ms ease,
786-
width 100ms ease;
787-
}
788-
789-
// Override vue componets scss
815+
// Override vue components scss
790816
.app-sidebar.app-sidebar--full {
791817
position: fixed !important;
818+
z-index: 2025 !important;
792819
top: 0 !important;
793820
height: 100% !important;
794-
z-index: 2025 !important;
795-
.thumbnailContainer {
796-
display: none !important;
797-
}
798821
}
799822
800823
// put autocomplete over full sidebar
@@ -803,4 +826,5 @@ export default {
803826
.ui-autocomplete {
804827
z-index: 2050 !important;
805828
}
829+
806830
</style>

0 commit comments

Comments
 (0)