Skip to content

Commit a98a0eb

Browse files
authored
Merge pull request #46307 from nextcloud/artonge/feat/improve_grid_view
2 parents 5d2d582 + d30d7de commit a98a0eb

File tree

7 files changed

+98
-63
lines changed

7 files changed

+98
-63
lines changed

apps/files/src/components/FileEntry.vue

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,10 @@ export default defineComponent({
121121
],
122122
123123
props: {
124-
isMtimeAvailable: {
125-
type: Boolean,
126-
default: false,
127-
},
128124
isSizeAvailable: {
129125
type: Boolean,
130126
default: false,
131127
},
132-
compact: {
133-
type: Boolean,
134-
default: false,
135-
},
136128
},
137129
138130
setup() {
@@ -204,23 +196,7 @@ export default defineComponent({
204196
color: `color-mix(in srgb, var(--color-main-text) ${ratio}%, var(--color-text-maxcontrast))`,
205197
}
206198
},
207-
mtimeOpacity() {
208-
const maxOpacityTime = 31 * 24 * 60 * 60 * 1000 // 31 days
209199
210-
const mtime = this.source.mtime?.getTime?.()
211-
if (!mtime) {
212-
return {}
213-
}
214-
215-
// 1 = today, 0 = 31 days ago
216-
const ratio = Math.round(Math.min(100, 100 * (maxOpacityTime - (Date.now() - mtime)) / maxOpacityTime))
217-
if (ratio < 0) {
218-
return {}
219-
}
220-
return {
221-
color: `color-mix(in srgb, var(--color-main-text) ${ratio}%, var(--color-text-maxcontrast))`,
222-
}
223-
},
224200
mtimeTitle() {
225201
if (this.source.mtime) {
226202
return moment(this.source.mtime).format('LLL')

apps/files/src/components/FileEntryGrid.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@
4646
@click.native="execDefaultAction" />
4747
</td>
4848

49+
<!-- Mtime -->
50+
<td v-if="!compact && isMtimeAvailable"
51+
:style="mtimeOpacity"
52+
class="files-list__row-mtime"
53+
data-cy-files-list-row-mtime
54+
@click="openDetailsIfAvailable">
55+
<NcDateTime v-if="source.mtime" :timestamp="source.mtime" :ignore-seconds="true" />
56+
</td>
57+
4958
<!-- Actions -->
5059
<FileEntryActions ref="actions"
5160
:class="`files-list__row-actions-${uniqueId}`"
@@ -60,6 +69,8 @@
6069
<script lang="ts">
6170
import { defineComponent } from 'vue'
6271
72+
import NcDateTime from '@nextcloud/vue/dist/Components/NcDateTime.js'
73+
6374
import { useNavigation } from '../composables/useNavigation'
6475
import { useActionsMenuStore } from '../store/actionsmenu.ts'
6576
import { useDragAndDropStore } from '../store/dragging.ts'
@@ -80,6 +91,7 @@ export default defineComponent({
8091
FileEntryCheckbox,
8192
FileEntryName,
8293
FileEntryPreview,
94+
NcDateTime,
8395
},
8496
8597
mixins: [

apps/files/src/components/FileEntryMixin.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ export default defineComponent({
3737
type: Number,
3838
default: 0,
3939
},
40+
isMtimeAvailable: {
41+
type: Boolean,
42+
default: false,
43+
},
44+
compact: {
45+
type: Boolean,
46+
default: false,
47+
},
4048
},
4149

4250
data() {
@@ -148,8 +156,22 @@ export default defineComponent({
148156
},
149157
},
150158

151-
isRenaming() {
152-
return this.renamingStore.renamingNode === this.source
159+
mtimeOpacity() {
160+
const maxOpacityTime = 31 * 24 * 60 * 60 * 1000 // 31 days
161+
162+
const mtime = this.source.mtime?.getTime?.()
163+
if (!mtime) {
164+
return {}
165+
}
166+
167+
// 1 = today, 0 = 31 days ago
168+
const ratio = Math.round(Math.min(100, 100 * (maxOpacityTime - (Date.now() - mtime)) / maxOpacityTime))
169+
if (ratio < 0) {
170+
return {}
171+
}
172+
return {
173+
color: `color-mix(in srgb, var(--color-main-text) ${ratio}%, var(--color-text-maxcontrast))`,
174+
}
153175
},
154176
},
155177

apps/files/src/components/FilesListVirtual.vue

Lines changed: 55 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ export default defineComponent({
316316
317317
--checkbox-padding: calc((var(--row-height) - var(--checkbox-size)) / 2);
318318
--checkbox-size: 24px;
319-
--clickable-area: 44px;
319+
--clickable-area: var(--default-clickable-area);
320320
--icon-preview-size: 32px;
321321
322322
overflow: auto;
@@ -687,39 +687,56 @@ export default defineComponent({
687687
// Grid mode
688688
tbody.files-list__tbody.files-list__tbody--grid {
689689
--half-clickable-area: calc(var(--clickable-area) / 2);
690-
--row-width: 160px;
691-
// We use half of the clickable area as visual balance margin
692-
--row-height: calc(var(--row-width) - var(--half-clickable-area));
693-
--icon-preview-size: calc(var(--row-width) - var(--clickable-area));
690+
--item-padding: 16px;
691+
--icon-preview-size: 208px;
692+
--name-height: 32px;
693+
--mtime-height: 16px;
694+
--row-width: calc(var(--icon-preview-size));
695+
--row-height: calc(var(--icon-preview-size) + var(--name-height) + var(--mtime-height));
694696
--checkbox-padding: 0px;
695697
696698
display: grid;
697699
grid-template-columns: repeat(auto-fill, var(--row-width));
698-
grid-gap: 15px;
699-
row-gap: 15px;
700+
gap: 22px;
700701
701702
align-content: center;
702703
align-items: center;
703704
justify-content: space-around;
704705
justify-items: center;
706+
margin: 16px;
707+
width: calc(100% - 32px);
705708
706709
tr {
710+
display: flex;
711+
flex-direction: column;
707712
width: var(--row-width);
708-
height: calc(var(--row-height) + var(--clickable-area));
713+
height: var(--row-height);
709714
border: none;
710-
border-radius: var(--border-radius);
715+
padding: var(--item-padding);
716+
box-sizing: content-box
711717
}
712718
713719
// Checkbox in the top left
714720
.files-list__row-checkbox {
715721
position: absolute;
716722
z-index: 9;
717-
top: 0;
718-
left: 0;
723+
top: calc(var(--item-padding)/2);
724+
left: calc(var(--item-padding)/2);
719725
overflow: hidden;
720-
width: var(--clickable-area);
721-
height: var(--clickable-area);
722-
border-radius: var(--half-clickable-area);
726+
--checkbox-container-size: 44px;
727+
width: var(--checkbox-container-size);
728+
height: var(--checkbox-container-size);
729+
730+
// Add a background to the checkbox so we do not see the image through it.
731+
.checkbox-radio-switch__content::after {
732+
content: '';
733+
width: 16px;
734+
height: 16px;
735+
position: absolute;
736+
left: 14px;
737+
z-index: -1;
738+
background: var(--color-main-background);
739+
}
723740
}
724741
725742
// Star icon in the top right
@@ -735,36 +752,44 @@ tbody.files-list__tbody.files-list__tbody--grid {
735752
}
736753
737754
.files-list__row-name {
738-
display: grid;
739-
justify-content: stretch;
740-
width: 100%;
741-
height: 100%;
742-
grid-auto-rows: var(--row-height) var(--clickable-area);
755+
display: flex;
756+
flex-direction: column;
757+
width: var(--icon-preview-size);
758+
height: calc(var(--icon-preview-size) + var(--name-height));
759+
// Ensure that the name outline is visible.
760+
overflow: visible;
743761
744762
span.files-list__row-icon {
745-
width: 100%;
746-
height: 100%;
747-
// Visual balance, we use half of the clickable area
748-
// as a margin around the preview
749-
padding-top: var(--half-clickable-area);
763+
width: var(--icon-preview-size);
764+
height: var(--icon-preview-size);
765+
}
766+
767+
.files-list__row-icon-preview {
768+
border-radius: 0;
750769
}
751770
752771
a.files-list__row-name-link {
753-
// Minus action menu
754-
width: calc(100% - var(--clickable-area));
755-
height: var(--clickable-area);
772+
height: var(--name-height);
756773
}
757774
758775
.files-list__row-name-text {
759776
margin: 0;
760-
padding-right: 0;
777+
// Ensure that the outline is not too close to the text.
778+
margin-left: -4px;
779+
padding: 0px 4px;
761780
}
762781
}
763782
783+
.files-list__row-mtime {
784+
width: var(--icon-preview-size);
785+
height: var(--mtime-height);
786+
font-size: calc(var(--default-font-size) - 4px);
787+
}
788+
764789
.files-list__row-actions {
765790
position: absolute;
766-
right: 0;
767-
bottom: 0;
791+
right: calc(var(--half-clickable-area) / 2);
792+
bottom: calc(var(--mtime-height) / 2);
768793
width: var(--clickable-area);
769794
height: var(--clickable-area);
770795
}

apps/files/src/components/VirtualList.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ export default Vue.extend({
127127
128128
itemHeight() {
129129
// Align with css in FilesListVirtual
130-
// 138px + 44px (name) + 15px (grid gap)
131-
return this.gridMode ? (138 + 44 + 15) : 55
130+
// 208px + 32px (name) + 16px (mtime) + 16px (padding) + 22px (grid gap)
131+
return this.gridMode ? (208 + 32 + 16 + 16 + 22) : 55
132132
},
133133
// Grid mode only
134134
itemWidth() {
135-
// 160px + 15px grid gap
136-
return 160 + 15
135+
// 208px + 16px padding + 22px grid gap
136+
return 208 + 16 + 22
137137
},
138138
139139
rowCount() {

dist/files-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)