feat: add blurHash loading for list cards
Some checks failed
continuous-integration/drone/pr Build is failing
Some checks failed
continuous-integration/drone/pr Build is failing
This commit is contained in:
parent
daf3212902
commit
0e886ba76b
|
@ -2,16 +2,20 @@
|
||||||
<router-link
|
<router-link
|
||||||
:class="{
|
:class="{
|
||||||
'has-light-text': !colorIsDark(list.hexColor),
|
'has-light-text': !colorIsDark(list.hexColor),
|
||||||
'has-background': background !== null
|
'has-background': blurHashUrl !== ''
|
||||||
}"
|
}"
|
||||||
:style="{
|
:style="{
|
||||||
'background-color': list.hexColor,
|
'background-color': list.hexColor,
|
||||||
'background-image': background !== null ? `url(${background})` : false,
|
'background-image': blurHashUrl !== null ? `url(${blurHashUrl})` : false,
|
||||||
}"
|
}"
|
||||||
:to="{ name: 'list.index', params: { listId: list.id} }"
|
:to="{ name: 'list.index', params: { listId: list.id} }"
|
||||||
class="list-card"
|
class="list-card"
|
||||||
v-if="list !== null && (showArchived ? true : !list.isArchived)"
|
v-if="list !== null && (showArchived ? true : !list.isArchived)"
|
||||||
>
|
>
|
||||||
|
<div v-if="background !== null"
|
||||||
|
class="list-background"
|
||||||
|
:style="{'background-image': background !== null ? `url(${background})` : false}"></div>
|
||||||
|
<div class="list-content">
|
||||||
<div class="is-archived-container">
|
<div class="is-archived-container">
|
||||||
<span class="is-archived" v-if="list.isArchived">
|
<span class="is-archived" v-if="list.isArchived">
|
||||||
{{ $t('namespace.archived') }}
|
{{ $t('namespace.archived') }}
|
||||||
|
@ -24,17 +28,20 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="title">{{ list.title }}</div>
|
<div class="title">{{ list.title }}</div>
|
||||||
|
</div>
|
||||||
</router-link>
|
</router-link>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {ref, watch} from 'vue'
|
import {computed, ref, watch} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
import {useStore} from 'vuex'
|
||||||
|
|
||||||
import ListService from '@/services/list'
|
import ListService from '@/services/list'
|
||||||
|
import {getBlobFromBlurHash} from '@/helpers/getBlobFromBlurHash'
|
||||||
|
|
||||||
const background = ref(null)
|
const background = ref(null)
|
||||||
const backgroundLoading = ref(false)
|
const backgroundLoading = ref(false)
|
||||||
|
const blurHashUrl = ref('')
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
list: {
|
list: {
|
||||||
|
@ -54,6 +61,11 @@ async function loadBackground() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const blurHash = await getBlobFromBlurHash(props.list.backgroundBlurHash)
|
||||||
|
if (blurHash) {
|
||||||
|
blurHashUrl.value = window.URL.createObjectURL(blurHash)
|
||||||
|
}
|
||||||
|
|
||||||
backgroundLoading.value = true
|
backgroundLoading.value = true
|
||||||
|
|
||||||
const listService = new ListService()
|
const listService = new ListService()
|
||||||
|
@ -83,14 +95,34 @@ function toggleFavoriteList(list) {
|
||||||
height: $list-height;
|
height: $list-height;
|
||||||
background: var(--white);
|
background: var(--white);
|
||||||
margin: 0 $list-spacing $list-spacing 0;
|
margin: 0 $list-spacing $list-spacing 0;
|
||||||
padding: 1rem;
|
|
||||||
border-radius: $radius;
|
border-radius: $radius;
|
||||||
box-shadow: var(--shadow-sm);
|
box-shadow: var(--shadow-sm);
|
||||||
transition: box-shadow $transition;
|
transition: box-shadow $transition;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
display: flex;
|
&.has-light-text .title {
|
||||||
justify-content: space-between;
|
color: var(--light);
|
||||||
flex-wrap: wrap;
|
}
|
||||||
|
|
||||||
|
&.has-background, .list-background {
|
||||||
|
background-size: cover;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.has-background .list-content .title {
|
||||||
|
text-shadow: 0 0 10px var(--black), 1px 1px 5px var(--grey-700), -1px -1px 5px var(--grey-700);
|
||||||
|
color: var(--white);
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-background {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
box-shadow: var(--shadow-md);
|
box-shadow: var(--shadow-md);
|
||||||
|
@ -138,6 +170,15 @@ function toggleFavoriteList(list) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.list-content {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
padding: 1rem;
|
||||||
|
position: absolute;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
.is-archived-container {
|
.is-archived-container {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
@ -165,21 +206,6 @@ function toggleFavoriteList(list) {
|
||||||
-webkit-box-orient: vertical;
|
-webkit-box-orient: vertical;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.has-light-text .title {
|
|
||||||
color: var(--light);
|
|
||||||
}
|
|
||||||
|
|
||||||
&.has-background {
|
|
||||||
background-size: cover;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-position: center;
|
|
||||||
|
|
||||||
.title {
|
|
||||||
text-shadow: 0 0 10px var(--black), 1px 1px 5px var(--grey-700), -1px -1px 5px var(--grey-700);
|
|
||||||
color: var(--white);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.favorite {
|
.favorite {
|
||||||
transition: opacity $transition, color $transition;
|
transition: opacity $transition, color $transition;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
|
@ -202,5 +228,7 @@ function toggleFavoriteList(list) {
|
||||||
&:hover .favorite {
|
&:hover .favorite {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
Reference in New Issue
Block a user