Skip to content

Commit

Permalink
feat: Allow comparing images, videos, audio
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Dec 28, 2023
1 parent 27cb725 commit 0a49829
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 62 deletions.
1 change: 1 addition & 0 deletions src/models/audios.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ export default {
'audio/webm',
],
component: Audios,
canCompare: true,
}
1 change: 1 addition & 0 deletions src/models/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,5 @@ export default {
...enabledMimes,
],
component: Images,
canCompare: true,
}
1 change: 1 addition & 0 deletions src/models/videos.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ export default {
'video/x-matroska': 'video/webm',
},
component: Videos,
canCompare: true,
}
134 changes: 72 additions & 62 deletions src/views/Viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,65 +113,67 @@

<div class="viewer__content" :class="contentClass" @click.self.exact="close">
<!-- COMPARE FILE -->
<component :is="comparisonFile.modal"
v-if="comparisonFile && !comparisonFile.failed && showComparison"
:key="comparisonFile | uniqueKey"
ref="comparison-content"
v-bind="comparisonFile"
:active="true"
:can-swipe="false"
:can-zoom="false"
:editing="false"
:is-full-screen="isFullscreen"
:is-sidebar-shown="isSidebarShown"
:loaded.sync="comparisonFile.loaded"
class="viewer__file viewer__file--active"
@error="comparisonFailed" />

<!-- PREVIOUS -->
<component :is="previousFile.modal"
v-if="previousFile && !previousFile.failed"
:key="previousFile | uniqueKey"
ref="previous-content"
v-bind="previousFile"
:file-list="fileList"
class="viewer__file--hidden viewer__file"
@error="previousFailed" />
<Error v-else-if="previousFile"
class="hidden-visually"
:name="previousFile.basename" />

<!-- CURRENT -->
<component :is="currentFile.modal"
v-if="!currentFile.failed"
:key="currentFile | uniqueKey"
ref="content"
v-bind="currentFile"
:active="true"
:can-swipe.sync="canSwipe"
:can-zoom="canZoom"
:editing.sync="editing"
:file-list="fileList"
:is-full-screen="isFullscreen"
:is-sidebar-shown="isSidebarShown"
:loaded.sync="currentFile.loaded"
class="viewer__file viewer__file--active"
@error="currentFailed" />
<Error v-else
:name="currentFile.basename" />

<!-- NEXT -->
<component :is="nextFile.modal"
v-if="nextFile && !nextFile.failed"
:key="nextFile | uniqueKey"
ref="next-content"
v-bind="nextFile"
:file-list="fileList"
class="viewer__file--hidden viewer__file"
@error="nextFailed" />
<Error v-else-if="nextFile"
class="hidden-visually"
:name="nextFile.basename" />
<div v-if="comparisonFile && !comparisonFile.failed && showComparison" class="viewer__content--component">
<component :is="comparisonFile.modal"
:key="comparisonFile | uniqueKey"
ref="comparison-content"
v-bind="comparisonFile"
:active="true"
:can-swipe="false"
:can-zoom="true"
:editing="false"
:is-full-screen="isFullscreen"
:is-sidebar-shown="isSidebarShown"
:loaded.sync="comparisonFile.loaded"
class="viewer__file viewer__file--active"
@error="comparisonFailed" />
</div>
<div class="viewer__content--component">
<!-- PREVIOUS -->
<component :is="previousFile.modal"
v-if="previousFile && !previousFile.failed"
:key="previousFile | uniqueKey"
ref="previous-content"
v-bind="previousFile"
:file-list="fileList"
class="viewer__file--hidden viewer__file"
@error="previousFailed" />
<Error v-else-if="previousFile"
class="hidden-visually"
:name="previousFile.basename" />

<!-- CURRENT -->
<component :is="currentFile.modal"
v-if="!currentFile.failed"
:key="currentFile | uniqueKey"
ref="content"
v-bind="currentFile"
:active="true"
:can-swipe.sync="canSwipe"
:can-zoom="canZoom"
:editing.sync="editing"
:file-list="fileList"
:is-full-screen="isFullscreen"
:is-sidebar-shown="isSidebarShown"
:loaded.sync="currentFile.loaded"
class="viewer__file viewer__file--active"
@error="currentFailed" />
<Error v-else
:name="currentFile.basename" />

<!-- NEXT -->
<component :is="nextFile.modal"
v-if="nextFile && !nextFile.failed"
:key="nextFile | uniqueKey"
ref="next-content"
v-bind="nextFile"
:file-list="fileList"
class="viewer__file--hidden viewer__file"
@error="nextFailed" />
<Error v-else-if="nextFile"
class="hidden-visually"
:name="nextFile.basename" />
</div>
</div>
</NcModal>
</template>
Expand Down Expand Up @@ -685,7 +687,7 @@ export default {

// store current position
this.currentIndex = this.fileList.findIndex(file => file.basename === fileInfo.basename)
} else if (group && this.el === null) {
} else if (group && this.el === null && false) {

Check failure on line 690 in src/views/Viewer.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Unexpected constant condition
const mimes = this.mimeGroups[group]
? this.mimeGroups[group]
: [mime]
Expand Down Expand Up @@ -1215,8 +1217,16 @@ export default {
cursor: pointer;
}

.viewer__content--component {
width: 100%;
align-self: stretch;
display: flex;
align-content: center;
justify-content: center;
}

&--split {
.viewer__file--active {
.viewer__content--component {
width: 50%;
}
}
Expand All @@ -1225,7 +1235,6 @@ export default {
.modal-container {
// Ensure some space at the bottom
top: var(--header-height);
bottom: var(--header-height);
height: auto;
// let the mime components manage their own background-color
background-color: transparent;
Expand All @@ -1236,6 +1245,7 @@ export default {
&__content {
// center views
display: flex;
align-self: center;
align-items: center;
justify-content: center;
width: 100%;
Expand Down

0 comments on commit 0a49829

Please sign in to comment.