Skip to content
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 style #9571

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"docx-preview": "^0.3.3",
"file-type": "^19.6.0",
"luxon": "^3.4.4",
"megashark-lib": "git+https://github.com/Scille/megashark-lib.git#2d7a87d9ed89a12fd8f7ab43ccf37238d35ef954",
"megashark-lib": "git+https://github.com/Scille/megashark-lib.git#4295321ad104962ced72a10d6cb85bc4e749e59f",
"monaco-editor": "^0.52.0",
"native-file-system-adapter": "^3.0.1",
"pdfjs-dist": "^4.8.69",
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/files/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type {
WorkspaceHistoryFileModel,
WorkspaceHistoryFolderModel,
} from '@/components/files/types';
export { getFilesFromDrop, selectFolder } from '@/components/files/utils';
export { copyPathLinkToClipboard, getFilesFromDrop, selectFolder } from '@/components/files/utils';
export type { FileImportTuple, FolderSelectionOptions } from '@/components/files/utils';
export {
FileAggregateDoneItem,
Expand Down
46 changes: 44 additions & 2 deletions client/src/components/files/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS

import FolderSelectionModal from '@/components/files/FolderSelectionModal.vue';
import { FsPath, Path, WorkspaceHandle } from '@/parsec';
import { FsPath, Path, WorkspaceHandle, getPathLink } from '@/parsec';
import { Information, InformationLevel, InformationManager, PresentationMode } from '@/services/informationManager';
import { modalController } from '@ionic/vue';
import { MsModalResult, Translatable } from 'megashark-lib';
import { Clipboard, MsModalResult, Translatable } from 'megashark-lib';

export interface FileImportTuple {
file: File;
Expand All @@ -20,6 +21,47 @@ export interface FolderSelectionOptions {
okButtonLabel?: Translatable;
}

export async function copyPathLinkToClipboard(
path: FsPath,
workspaceHandle: WorkspaceHandle,
informationManager: InformationManager,
): Promise<void> {
if (!workspaceHandle) {
window.electronAPI.log('error', 'Failed to retrieve workspace handle');
return;
}

const result = await getPathLink(workspaceHandle, path);

if (result.ok) {
if (!(await Clipboard.writeText(result.value))) {
informationManager.present(
new Information({
message: 'FoldersPage.linkNotCopiedToClipboard',
level: InformationLevel.Error,
}),
PresentationMode.Toast,
);
} else {
informationManager.present(
new Information({
message: 'FoldersPage.linkCopiedToClipboard',
level: InformationLevel.Info,
}),
PresentationMode.Toast,
);
}
} else {
informationManager.present(
new Information({
message: 'FoldersPage.getLinkError',
level: InformationLevel.Error,
}),
PresentationMode.Toast,
);
}
}

export async function getFilesFromDrop(event: DragEvent, path: FsPath): Promise<FileImportTuple[]> {
if (event.dataTransfer) {
const entries: FileSystemEntry[] = [];
Expand Down
13 changes: 10 additions & 3 deletions client/src/components/viewers/FileViewerBackground.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,19 @@ defineProps<{
.file-viewer-background {
height: 100%;
width: 100%;
max-height: 37.5rem;
max-width: 75rem;
padding: 2rem;
display: flex;

img {
height: 100%;
margin: auto;
width: 100%;
object-fit: cover;
border-radius: var(--parsec-radius-12);
overflow: hidden;
box-shadow: var(--parsec-shadow-light);
object-fit: cover;
}

&-icon {
Expand All @@ -37,8 +44,8 @@ defineProps<{
left: 50%;
transform: translate(-50%, -50%);
font-size: 7vw;
max-width: 8rem;
max-height: 8rem;
max-width: 5rem;
max-height: 5rem;
min-width: 3rem;
min-height: 3rem;
padding: 1vw;
Expand Down
30 changes: 20 additions & 10 deletions client/src/components/viewers/controls/FileControls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,33 @@

<style scoped lang="scss">
.file-controls {
padding: 0.5rem 1rem;
margin: 0 1rem 1rem 1rem;
padding: 0.75rem 1.5rem;
display: flex;
gap: 0.5em;
width: fit-content;
background: var(--parsec-color-light-primary-100);
border-radius: 5em;
box-shadow: var(--parsec-shadow-light);
border-bottom: 1px solid var(--parsec-color-light-secondary-medium);
justify-content: center;
align-items: center;
gap: 1.5rem;
width: 100%;
background: var(--parsec-color-light-secondary-white);
border-radius: var(--parsec-radius-8);
box-shadow: var(--parsec-shadow-soft);
--inner-padding-end: 0;
border-top: 1px solid var(--parsec-color-light-secondary-medium);
position: relative;
z-index: 200;
min-height: 3.75rem;
transition: all 0.2s ease-in-out;

& > *:not(:last-child)::after {
content: '';
display: block;
width: 2px;
height: 2em;
background: var(--parsec-color-light-primary-200);
opacity: 0.5;
height: 1rem;
background: var(--parsec-color-light-secondary-disabled);
}

&:hover {
box-shadow: var(--parsec-shadow-light);
}
}
</style>
105 changes: 65 additions & 40 deletions client/src/components/viewers/controls/FileControlsButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,28 @@

<template>
<ion-button
class="file-controls-button button-medium"
size="default"
class="file-controls-button-container button-medium"
fill="clear"
>
<ion-icon
class="file-controls-button-icon"
v-if="icon"
slot="start"
:icon="icon"
/>
<ms-image
class="file-controls-button-icon"
v-if="!icon && image"
:image="image"
/>
<span
class="file-controls-button-label"
v-if="label"
>
{{ $msTranslate(label) }}
</span>
<div class="file-controls-button">
<ion-icon
class="file-controls-button-icon"
v-if="icon"
slot="start"
:icon="icon"
/>
<ms-image
class="file-controls-button-icon"
v-if="!icon && image"
:image="image"
/>
<span
class="file-controls-button-label"
v-if="label"
>
{{ $msTranslate(label) }}
</span>
</div>
</ion-button>
</template>

Expand All @@ -37,36 +39,59 @@ defineProps<{
</script>

<style lang="scss" scoped>
.file-controls-button {
--background: none !important;
--background-hover: none !important;
margin-inline: 0px;
margin-top: 0px;
margin-bottom: 0px;
--padding-top: 0;
--padding-end: 0;
--padding-bottom: 0;
--padding-start: 0;
height: 3em;
width: fit-content;
border-radius: 100%;
color: var(--parsec-color-light-primary-600);
opacity: 0.6;
scale: 1;
.file-controls-button-container {
--background: none;
--background-hover: none;
border-radius: var(--parsec-radius-6);
min-height: 0;
transition: all 0.2s ease-in-out;
height: fit-content;

&::part(native) {
margin: 0;
padding: 0;
}

.file-controls-button {
display: flex;
align-items: center;
gap: 0.5em;
height: 100%;
width: 100%;
color: var(--parsec-color-light-secondary-text);
padding: 0.25rem;

&-icon {
font-size: 1.25rem;
width: 1.25rem;
height: 1.25rem;
display: flex;
flex-grow: 1;
--fill-color: var(--parsec-color-light-secondary-text);
}
}

&.button-disabled {
opacity: 0.3;
}

&:hover {
scale: 1.1;
opacity: 1;
background: var(--parsec-color-light-secondary-background);
box-shadow: var(--parsec-shadow-soft);
color: var(--parsec-color-light-primary-400);

.file-controls-button-icon {
color: var(--parsec-color-light-primary-400);
--fill-color: var(--parsec-color-light-primary-400);
}

.file-controls-button-label {
color: var(--parsec-color-light-primary-400);
}
}

&-icon,
&-label {
margin-inline: 0.625rem;
&:active {
box-shadow: none;
}
}
</style>
79 changes: 10 additions & 69 deletions client/src/components/viewers/controls/FileControlsDropdown.vue
Original file line number Diff line number Diff line change
@@ -1,37 +1,20 @@
<!-- Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS -->

<template>
<ion-button
class="file-controls-dropdown button-medium"
size="default"
<file-controls-button
@click="openPopover($event)"
>
<span
class="file-controls-dropdown-label"
v-if="title"
>
{{ $msTranslate(title) }}
</span>
<ion-icon
class="file-controls-dropdown-icon"
:class="{ 'popover-is-open': isPopoverOpen }"
v-if="icon"
:icon="icon"
/>
<ms-image
class="file-controls-dropdown-icon"
:class="{ 'popover-is-open': isPopoverOpen }"
v-if="!icon && image"
:image="image"
/>
</ion-button>
class="file-controls-dropdown"
:class="{ 'dropdown-active': isPopoverOpen }"
:icon="icon || image"
:label="title"
/>
</template>

<script setup lang="ts">
import { FileControlsDropdownPopover, FileControlsDropdownItemContent } from '@/components/viewers';
import { FileControlsDropdownPopover, FileControlsDropdownItemContent, FileControlsButton } from '@/components/viewers';
import { Ref, ref } from 'vue';
import { IonButton, IonIcon, popoverController } from '@ionic/vue';
import { MsImage, Translatable } from 'megashark-lib';
import { popoverController } from '@ionic/vue';
import { Translatable } from 'megashark-lib';

const isPopoverOpen = ref(false);
const selectedOption: Ref<FileControlsDropdownItemContent | undefined> = ref(undefined);
Expand Down Expand Up @@ -72,46 +55,4 @@ async function onDidDismissPopover(popover: any): Promise<void> {
}
</script>

<style lang="scss" scoped>
ion-icon {
transition: transform ease-out 300ms;
font-size: 1.125rem;

&.popover-is-open {
transform: rotate(180deg);
}
}

.file-controls-dropdown {
--background: none !important;
--background-hover: none !important;
margin-inline: 0px;
margin-top: 0px;
margin-bottom: 0px;
--padding-top: 0;
--padding-end: 0;
--padding-bottom: 0;
--padding-start: 0;
height: 3em;
width: fit-content;
border-radius: 100%;
color: var(--parsec-color-light-primary-600);
opacity: 0.6;
scale: 1;
transition: all 0.2s ease-in-out;

&.button-disabled {
opacity: 0.3;
}

&:hover {
scale: 1.1;
opacity: 1;
}

&-icon,
&-label {
margin-inline: 0.625rem;
}
}
</style>
<style lang="scss" scoped></style>
Loading
Loading