Add dynamic top matter

old-stable24
Varun Patil 2022-10-12 12:05:38 -07:00
parent 149cac3ffa
commit 190e273bc5
2 changed files with 88 additions and 77 deletions

View File

@ -51,20 +51,6 @@
</NcContent> </NcContent>
</template> </template>
<style scoped>
.outer {
padding: 0 0 0 44px;
height: 100%;
width: 100%;
}
@media (max-width: 768px) {
.outer {
padding-left: 5px;
}
}
</style>
<script lang="ts"> <script lang="ts">
import { Component, Mixins } from 'vue-property-decorator'; import { Component, Mixins } from 'vue-property-decorator';
import { import {
@ -121,6 +107,18 @@ export default class App extends Mixins(GlobalMixin, UserConfig) {
} }
</script> </script>
<style scoped lang="scss">
.outer {
padding: 0 0 0 44px;
height: 100%;
width: 100%;
}
@media (max-width: 768px) {
.outer { padding: 0px; }
}
</style>
<style lang="scss"> <style lang="scss">
body { body {
overflow: hidden; overflow: hidden;

View File

@ -27,48 +27,53 @@
key-field="id" key-field="id"
size-field="size" size-field="size"
type-field="type" type-field="type"
v-slot="{ item }"
@update="scrollChange" @update="scrollChange"
@resize="handleResizeWithDelay" @resize="handleResizeWithDelay"
> >
<div v-if="item.type === 0" class="head-row" <template #before>
:class="{ <!-- Show dynamic top matter, name of the view -->
'first': item.id === 1 && !topMatterType, <div class="recycler-before" ref="recyclerbefore" v-if="!topMatterType && list.length > 0">
'selected': item.selected, {{ getViewName() }}
}"
>
<CheckCircle :size="18" class="select" @click="selectHead(item)" />
<span class="name"
@click="selectHead(item)">
{{ item.name || getHeadName(item) }}
</span>
</div>
<div v-else
class="photo-row"
:style="{ height: rowHeight + 'px' }">
<div class="photo" v-for="(photo, index) in item.photos" :key="index">
<Folder v-if="photo.flag & c.FLAG_IS_FOLDER"
:data="photo"
:rowHeight="rowHeight"
:key="photo.fileid" />
<Tag v-else-if="photo.flag & c.FLAG_IS_TAG"
:data="photo"
:rowHeight="rowHeight"
:key="photo.fileid" />
<Photo v-else
:data="photo"
:rowHeight="rowHeight"
:day="item.day"
@select="selectPhoto"
@delete="deleteFromViewWithAnimation"
@clickImg="clickPhoto" />
</div> </div>
</div> </template>
<template v-slot="{ item }">
<div v-if="item.type === 0" class="head-row"
:class="{ 'selected': item.selected}"
>
<CheckCircle :size="18" class="select" @click="selectHead(item)" />
<span class="name"
@click="selectHead(item)">
{{ item.name || getHeadName(item) }}
</span>
</div>
<div v-else
class="photo-row"
:style="{ height: rowHeight + 'px' }">
<div class="photo" v-for="(photo, index) in item.photos" :key="index">
<Folder v-if="photo.flag & c.FLAG_IS_FOLDER"
:data="photo"
:rowHeight="rowHeight"
:key="photo.fileid" />
<Tag v-else-if="photo.flag & c.FLAG_IS_TAG"
:data="photo"
:rowHeight="rowHeight"
:key="photo.fileid" />
<Photo v-else
:data="photo"
:rowHeight="rowHeight"
:day="item.day"
@select="selectPhoto"
@delete="deleteFromViewWithAnimation"
@clickImg="clickPhoto" />
</div>
</div>
</template>
</RecycleScroller> </RecycleScroller>
<!-- Timeline scroller --> <!-- Timeline scroller -->
@ -370,19 +375,27 @@ export default class Timeline extends Mixins(GlobalMixin, UserConfig) {
/** Create top matter */ /** Create top matter */
setTopMatter() { setTopMatter() {
this.topMatterType = (() => {
switch (this.$route.name) {
case 'folders': return TopMatterType.FOLDER;
case 'tags': return this.$route.params.name ? TopMatterType.TAG : TopMatterType.NONE;
case 'people': return this.$route.params.name ? TopMatterType.FACE : TopMatterType.NONE;
default: return TopMatterType.NONE;
}
})();
}
/** Get view name for dynamic top matter */
getViewName() {
switch (this.$route.name) { switch (this.$route.name) {
case 'folders': case 'timeline': return 'Your Photos';
this.topMatterType = TopMatterType.FOLDER; case 'favorites': return 'Favorites';
break; case 'people': return 'People';
case 'tags': case 'videos': return 'Videos';
this.topMatterType = this.$route.params.name ? TopMatterType.TAG : TopMatterType.NONE; case 'archive': return 'Archive';
break; case 'thisday': return 'On this day';
case 'people': case 'tags': return 'Tags';
this.topMatterType = this.$route.params.name ? TopMatterType.FACE : TopMatterType.NONE; default: return '';
break;
default:
this.topMatterType = TopMatterType.NONE;
break;
} }
} }
@ -425,7 +438,6 @@ export default class Timeline extends Mixins(GlobalMixin, UserConfig) {
// Mobile devices // Mobile devices
if (window.innerWidth <= 768) { if (window.innerWidth <= 768) {
width -= 4;
this.isMobile = true; this.isMobile = true;
} else { } else {
width -= 40; width -= 40;
@ -768,9 +780,13 @@ export default class Timeline extends Mixins(GlobalMixin, UserConfig) {
const recycler: any = this.$refs.recycler; const recycler: any = this.$refs.recycler;
this.viewHeight = recycler.$refs.wrapper.clientHeight; this.viewHeight = recycler.$refs.wrapper.clientHeight;
// Static extra height at top
const rb = this.$refs.recyclerbefore as Element;
const extraHeight = rb?.clientHeight || 0;
// Compute timeline tick positions // Compute timeline tick positions
for (const tick of this.timelineTicks) { for (const tick of this.timelineTicks) {
tick.topC = (tick.topS + tick.top * this.rowHeight) * this.timelineHeight / this.viewHeight; tick.topC = (extraHeight + tick.topS + tick.top * this.rowHeight) * this.timelineHeight / this.viewHeight;
} }
// Do another pass to figure out which timeline points are visible // Do another pass to figure out which timeline points are visible
@ -1421,13 +1437,6 @@ export default class Timeline extends Mixins(GlobalMixin, UserConfig) {
font-size: 0.9em; font-size: 0.9em;
font-weight: 600; font-weight: 600;
@include phone {
&.first {
padding-left: 38px;
padding-top: 12px;
}
}
> .select { > .select {
position: absolute; position: absolute;
left: 5px; top: 50%; left: 5px; top: 50%;
@ -1580,11 +1589,15 @@ export default class Timeline extends Mixins(GlobalMixin, UserConfig) {
} }
} }
/** Static top matter */ /** Static and dynamic top matter */
.top-matter { .top-matter {
padding-top: 4px; padding-top: 4px;
@include phone { @include phone { padding-left: 40px; }
padding-left: 38px; }
} .recycler-before {
font-size: 1.2em;
padding-top: 13px;
padding-left: 8px;
@include phone { padding-left: 48px; }
} }
</style> </style>