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,15 +27,19 @@
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"
> >
<template #before>
<!-- Show dynamic top matter, name of the view -->
<div class="recycler-before" ref="recyclerbefore" v-if="!topMatterType && list.length > 0">
{{ getViewName() }}
</div>
</template>
<template v-slot="{ item }">
<div v-if="item.type === 0" class="head-row" <div v-if="item.type === 0" class="head-row"
:class="{ :class="{ 'selected': item.selected}"
'first': item.id === 1 && !topMatterType,
'selected': item.selected,
}"
> >
<CheckCircle :size="18" class="select" @click="selectHead(item)" /> <CheckCircle :size="18" class="select" @click="selectHead(item)" />
@ -69,6 +73,7 @@
@clickImg="clickPhoto" /> @clickImg="clickPhoto" />
</div> </div>
</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) { switch (this.$route.name) {
case 'folders': case 'folders': return TopMatterType.FOLDER;
this.topMatterType = TopMatterType.FOLDER; case 'tags': return this.$route.params.name ? TopMatterType.TAG : TopMatterType.NONE;
break; case 'people': return this.$route.params.name ? TopMatterType.FACE : TopMatterType.NONE;
case 'tags': default: return TopMatterType.NONE;
this.topMatterType = this.$route.params.name ? TopMatterType.TAG : TopMatterType.NONE; }
break; })();
case 'people': }
this.topMatterType = this.$route.params.name ? TopMatterType.FACE : TopMatterType.NONE;
break; /** Get view name for dynamic top matter */
default: getViewName() {
this.topMatterType = TopMatterType.NONE; switch (this.$route.name) {
break; case 'timeline': return 'Your Photos';
case 'favorites': return 'Favorites';
case 'people': return 'People';
case 'videos': return 'Videos';
case 'archive': return 'Archive';
case 'thisday': return 'On this day';
case 'tags': return 'Tags';
default: return '';
} }
} }
@ -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>