-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ms-file-viewer-bottombar #8965
Ms-file-viewer-bottombar #8965
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!-- Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS --> | ||
|
||
<template> | ||
<ms-action-bar class="file-viewer-action-bar"> | ||
<ms-action-bar-button | ||
v-for="(action, key) in actions" | ||
:key="key" | ||
:icon="action.icon" | ||
@click="action.handler" | ||
:button-label="action.text" | ||
/> | ||
</ms-action-bar> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { MsActionBar, MsActionBarButton, Translatable } from 'megashark-lib'; | ||
|
||
// TODO: add a disabled state to the button (ex: max zoom level). | ||
// TODO: extract this interface to a separate file. | ||
interface FileViewerAction { | ||
icon?: string; | ||
text?: Translatable; | ||
handler: () => void; | ||
} | ||
|
||
defineProps<{ | ||
actions: Array<FileViewerAction>; | ||
}>(); | ||
</script> | ||
|
||
<style scoped> | ||
.file-viewer-action-bar { | ||
padding: 0.5rem 1rem; | ||
width: fit-content; | ||
background: var(--parsec-color-light-primary-100); | ||
border-radius: 5em; | ||
box-shadow: var(--parsec-shadow-light); | ||
} | ||
</style> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS | ||
|
||
import FileViewerActionBar from '@/components/viewers/FileViewerActionBar.vue'; | ||
|
||
export { FileViewerActionBar }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,80 @@ | ||
<!-- Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS --> | ||
|
||
<template> | ||
<audio | ||
controls | ||
v-if="src.length" | ||
:src="src" | ||
/> | ||
<file-viewer-wrapper> | ||
<template #viewer> | ||
<audio | ||
controls | ||
v-if="src.length" | ||
ref="audioElement" | ||
@play="updateMediaData" | ||
@playing="updateMediaData" | ||
@canplay="updateMediaData" | ||
@pause="updateMediaData" | ||
@volumechange="updateMediaData" | ||
:src="src" | ||
/> | ||
</template> | ||
<!-- Disabled till we add an illustration in the viewer --> | ||
<!-- <template #controls> | ||
<file-viewer-action-bar | ||
:actions="[ | ||
{ icon: paused ? play : pause, handler: togglePlayback }, | ||
{ icon: getVolumeIcon(), handler: toggleVolume }, | ||
]" | ||
/> | ||
</template> --> | ||
</file-viewer-wrapper> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
// import { play, pause, volumeHigh, volumeLow, volumeMedium, volumeMute } from 'ionicons/icons'; | ||
import { onMounted, ref } from 'vue'; | ||
import { FileViewerWrapper } from '@/views/viewers'; | ||
import { FileContentInfo } from '@/views/viewers/utils'; | ||
|
||
const props = defineProps<{ | ||
contentInfo: FileContentInfo; | ||
}>(); | ||
|
||
// const VOLUME_LEVELS = [0, 0.25, 0.5, 1]; | ||
|
||
const src = ref(''); | ||
const audioElement = ref(); | ||
const paused = ref(true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need this? You can access the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes we need this part: audioElement as ref don't trigger its "change" state when using media controls. |
||
const volume = ref(1); | ||
|
||
onMounted(async () => { | ||
src.value = URL.createObjectURL(new Blob([props.contentInfo.data], { type: props.contentInfo.mimeType })); | ||
}); | ||
|
||
// function togglePlayback(): void { | ||
// audioElement.value.paused ? audioElement.value.play() : audioElement.value.pause(); | ||
// } | ||
|
||
// function toggleVolume(): void { | ||
// audioElement.value.volume = VOLUME_LEVELS[(VOLUME_LEVELS.indexOf(audioElement.value.volume) + 1) % VOLUME_LEVELS.length]; | ||
// } | ||
|
||
function updateMediaData(event: Event): void { | ||
volume.value = (event.target as HTMLAudioElement).volume; | ||
paused.value = (event.target as HTMLAudioElement).paused; | ||
} | ||
|
||
// function getVolumeIcon(): string { | ||
// switch (volume.value) { | ||
// case 0: | ||
// return volumeMute; | ||
// case 0.25: | ||
// return volumeLow; | ||
// case 0.5: | ||
// return volumeMedium; | ||
// case 1: | ||
// return volumeHigh; | ||
// default: | ||
// return volumeMute; | ||
// } | ||
// } | ||
</script> | ||
|
||
<style scoped lang="scss"></style> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!-- Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS --> | ||
|
||
<template> | ||
<!-- file-viewer wrapper --> | ||
<div class="file-viewer-wrapper"> | ||
<slot name="viewer" /> | ||
</div> | ||
|
||
<!-- file-viewer bottombar --> | ||
<div class="file-viewer-bottombar"> | ||
<slot name="controls" /> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"></script> | ||
|
||
<style scoped lang="scss"> | ||
.file-viewer-wrapper { | ||
height: 100%; | ||
height: -webkit-fill-available; | ||
height: -moz-available; | ||
height: stretch; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
overflow: hidden; | ||
} | ||
|
||
.file-viewer-bottombar { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
gap: 1.5rem; | ||
} | ||
</style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll probably want a
disabled
attribute to prevent clicking in some cases (max zoom level reached for example).Also better to extract this interface to a separate file to be able to import it for typing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the action bar will change depending on the feature list we will make with Fabien on monday, I just add your suggestions as comment to keep it in mind in the next PR.