From 16975ae45720945776155f026835cfdaf8491383 Mon Sep 17 00:00:00 2001 From: John Molakvoæ Date: Fri, 13 Oct 2023 16:49:54 +0200 Subject: feat(files): grid view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ --- apps/files/src/components/FileEntry.vue | 34 +- .../src/components/FileEntry/FileEntryActions.vue | 8 +- .../src/components/FileEntry/FileEntryName.vue | 5 +- .../src/components/FileEntry/FileEntryPreview.vue | 8 +- apps/files/src/components/FileEntryGrid.vue | 414 +++++++++++++++++++++ apps/files/src/components/FilesListTableFooter.vue | 13 +- apps/files/src/components/FilesListVirtual.vue | 108 +++++- apps/files/src/components/VirtualList.vue | 80 ++-- 8 files changed, 604 insertions(+), 66 deletions(-) create mode 100644 apps/files/src/components/FileEntryGrid.vue diff --git a/apps/files/src/components/FileEntry.vue b/apps/files/src/components/FileEntry.vue index 40a271aa972..adfaab8cc9a 100644 --- a/apps/files/src/components/FileEntry.vue +++ b/apps/files/src/components/FileEntry.vue @@ -71,7 +71,7 @@ :visible="visible" /> - - - - - - diff --git a/apps/files/src/components/FileEntry/FileEntryActions.vue b/apps/files/src/components/FileEntry/FileEntryActions.vue index e8af5c0fe16..040b59066ec 100644 --- a/apps/files/src/components/FileEntry/FileEntryActions.vue +++ b/apps/files/src/components/FileEntry/FileEntryActions.vue @@ -105,6 +105,10 @@ export default Vue.extend({ type: Boolean, default: false, }, + gridMode: { + type: Boolean, + default: false, + }, }, setup() { @@ -137,7 +141,7 @@ export default Vue.extend({ // Enabled action that are displayed inline enabledInlineActions() { - if (this.filesListWidth < 768) { + if (this.filesListWidth < 768 || this.gridMode) { return [] } return this.enabledActions.filter(action => action?.inline?.(this.source, this.currentView)) @@ -145,7 +149,7 @@ export default Vue.extend({ // Enabled action that are displayed inline with a custom render function enabledRenderActions() { - if (!this.visible) { + if (!this.visible || this.gridMode) { return [] } return this.enabledActions.filter(action => typeof action.renderInline === 'function') diff --git a/apps/files/src/components/FileEntry/FileEntryName.vue b/apps/files/src/components/FileEntry/FileEntryName.vue index d70eccec8a0..e54eacdbe9e 100644 --- a/apps/files/src/components/FileEntry/FileEntryName.vue +++ b/apps/files/src/components/FileEntry/FileEntryName.vue @@ -23,7 +23,6 @@
@@ -98,6 +97,10 @@ export default Vue.extend({ type: Object as PropType, required: true, }, + gridMode: { + type: Boolean, + default: false, + }, }, setup() { diff --git a/apps/files/src/components/FileEntry/FileEntryPreview.vue b/apps/files/src/components/FileEntry/FileEntryPreview.vue index 7766980b144..076319428e5 100644 --- a/apps/files/src/components/FileEntry/FileEntryPreview.vue +++ b/apps/files/src/components/FileEntry/FileEntryPreview.vue @@ -99,6 +99,10 @@ export default Vue.extend({ type: Boolean, default: false, }, + gridMode: { + type: Boolean, + default: false, + }, }, setup() { @@ -146,8 +150,8 @@ export default Vue.extend({ const url = new URL(window.location.origin + previewUrl) // Request tiny previews - url.searchParams.set('x', '32') - url.searchParams.set('y', '32') + url.searchParams.set('x', this.gridMode ? '128' : '32') + url.searchParams.set('y', this.gridMode ? '128' : '32') url.searchParams.set('mimeFallback', 'true') // Handle cropping diff --git a/apps/files/src/components/FileEntryGrid.vue b/apps/files/src/components/FileEntryGrid.vue new file mode 100644 index 00000000000..d8c45cb2ce8 --- /dev/null +++ b/apps/files/src/components/FileEntryGrid.vue @@ -0,0 +1,414 @@ + + + + + diff --git a/apps/files/src/components/FilesListTableFooter.vue b/apps/files/src/components/FilesListTableFooter.vue index 3e8f49deace..bca4604d57d 100644 --- a/apps/files/src/components/FilesListTableFooter.vue +++ b/apps/files/src/components/FilesListTableFooter.vue @@ -159,17 +159,16 @@ export default Vue.extend({ diff --git a/apps/files/src/components/FilesListVirtual.vue b/apps/files/src/components/FilesListVirtual.vue index 914cfa7ec4d..e4c9694eda7 100644 --- a/apps/files/src/components/FilesListVirtual.vue +++ b/apps/files/src/components/FilesListVirtual.vue @@ -31,7 +31,7 @@ :data-component="FileEntry" :data-key="'source'" :data-sources="nodes" - :item-height="56" + :grid-mode="false" :extra-props="{ isMtimeAvailable, isSizeAvailable, @@ -90,7 +90,7 @@ import Vue from 'vue' import { action as sidebarAction } from '../actions/sidebarAction.ts' import DragAndDropNotice from './DragAndDropNotice.vue' -import FileEntry from './FileEntry.vue' +import FileEntry from './FileEntryGrid.vue' import FilesListHeader from './FilesListHeader.vue' import FilesListTableFooter from './FilesListTableFooter.vue' import FilesListTableHeader from './FilesListTableHeader.vue' @@ -302,6 +302,14 @@ export default Vue.extend({ width: 100%; // Necessary for virtual scrolling absolute position: relative; + + /* Hover effect on tbody lines only */ + tr { + &:hover, + &:focus { + background-color: var(--color-background-dark); + } + } } // Before table and thead @@ -340,6 +348,7 @@ export default Vue.extend({ user-select: none; border-bottom: 1px solid var(--color-border); user-select: none; + height: var(--row-height); } td, th { @@ -485,8 +494,8 @@ export default Vue.extend({ // Folder overlay &-overlay { position: absolute; - max-height: 18px; - max-width: 18px; + max-height: calc(var(--icon-preview-size) * 0.5); + max-width: calc(var(--icon-preview-size) * 0.5); color: var(--color-main-background); // better alignment with the folder icon margin-top: 2px; @@ -533,6 +542,8 @@ export default Vue.extend({ .files-list__row-name-ext { color: var(--color-text-maxcontrast); + // always show the extension + overflow: visible; } } @@ -556,6 +567,7 @@ export default Vue.extend({ } .files-list__row-actions { + // take as much space as necessary width: auto; // Add margin to all cells after the actions @@ -596,3 +608,91 @@ export default Vue.extend({ } } + + diff --git a/apps/files/src/components/VirtualList.vue b/apps/files/src/components/VirtualList.vue index ef824d7ba91..6a415799034 100644 --- a/apps/files/src/components/VirtualList.vue +++ b/apps/files/src/components/VirtualList.vue @@ -11,7 +11,10 @@ - + @@ -32,16 +34,18 @@