enhance(client): tweak medialist style
This commit is contained in:
parent
f9a2e98831
commit
ac7537278c
1 changed files with 56 additions and 76 deletions
|
@ -1,11 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="hoawjimk">
|
<div>
|
||||||
<XBanner v-for="media in mediaList.filter(media => !previewable(media))" :key="media.id" :media="media"/>
|
<XBanner v-for="media in mediaList.filter(media => !previewable(media))" :key="media.id" :media="media"/>
|
||||||
<div v-if="mediaList.filter(media => previewable(media)).length > 0" class="gird-container">
|
<div v-if="mediaList.filter(media => previewable(media)).length > 0" :class="$style.container">
|
||||||
<div ref="gallery" :data-count="mediaList.filter(media => previewable(media)).length">
|
<div ref="gallery" :class="[$style.medias, count <= 4 ? $style['n' + count] : $style.nMany]">
|
||||||
<template v-for="media in mediaList.filter(media => previewable(media))">
|
<template v-for="media in mediaList.filter(media => previewable(media))">
|
||||||
<XVideo v-if="media.type.startsWith('video')" :key="media.id" :video="media"/>
|
<XVideo v-if="media.type.startsWith('video')" :key="media.id" :class="$style.media" :video="media"/>
|
||||||
<XImage v-else-if="media.type.startsWith('image')" :key="media.id" class="image" :data-id="media.id" :image="media" :raw="raw"/>
|
<XImage v-else-if="media.type.startsWith('image')" :key="media.id" :class="$style.media" class="image" :data-id="media.id" :image="media" :raw="raw"/>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -32,6 +32,7 @@ const props = defineProps<{
|
||||||
|
|
||||||
const gallery = ref(null);
|
const gallery = ref(null);
|
||||||
const pswpZIndex = os.claimZIndex('middle');
|
const pswpZIndex = os.claimZIndex('middle');
|
||||||
|
const count = $computed(() => props.mediaList.filter(media => previewable(media)).length);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
const lightbox = new PhotoSwipeLightbox({
|
const lightbox = new PhotoSwipeLightbox({
|
||||||
|
@ -122,82 +123,61 @@ const previewable = (file: misskey.entities.DriveFile): boolean => {
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" module>
|
||||||
.hoawjimk {
|
.container {
|
||||||
> .gird-container {
|
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
|
|
||||||
&:before {
|
|
||||||
content: '';
|
|
||||||
display: block;
|
|
||||||
padding-top: 56.25% // 16:9;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
> div {
|
.medias {
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-gap: 8px;
|
grid-gap: 8px;
|
||||||
|
|
||||||
> * {
|
&.n1 {
|
||||||
overflow: hidden;
|
aspect-ratio: 16/9;
|
||||||
border-radius: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&[data-count="1"] {
|
|
||||||
grid-template-rows: 1fr;
|
grid-template-rows: 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
&[data-count="2"] {
|
&.n2 {
|
||||||
|
aspect-ratio: 16/9;
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: 1fr 1fr;
|
||||||
grid-template-rows: 1fr;
|
grid-template-rows: 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
&[data-count="3"] {
|
&.n3 {
|
||||||
|
aspect-ratio: 16/9;
|
||||||
grid-template-columns: 1fr 0.5fr;
|
grid-template-columns: 1fr 0.5fr;
|
||||||
grid-template-rows: 1fr 1fr;
|
grid-template-rows: 1fr 1fr;
|
||||||
|
|
||||||
> *:nth-child(1) {
|
> .media:nth-child(1) {
|
||||||
grid-row: 1 / 3;
|
grid-row: 1 / 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
> *:nth-child(3) {
|
> .media:nth-child(3) {
|
||||||
grid-column: 2 / 3;
|
grid-column: 2 / 3;
|
||||||
grid-row: 2 / 3;
|
grid-row: 2 / 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&[data-count="4"] {
|
&.n4 {
|
||||||
|
aspect-ratio: 16/9;
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: 1fr 1fr;
|
||||||
grid-template-rows: 1fr 1fr;
|
grid-template-rows: 1fr 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
> *:nth-child(1) {
|
&.nMany {
|
||||||
grid-column: 1 / 2;
|
grid-template-columns: 1fr 1fr;
|
||||||
grid-row: 1 / 2;
|
|
||||||
|
> .media {
|
||||||
|
aspect-ratio: 16/9;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
> *:nth-child(2) {
|
.media {
|
||||||
grid-column: 2 / 3;
|
overflow: hidden; // clipにするとバグる
|
||||||
grid-row: 1 / 2;
|
border-radius: 8px;
|
||||||
}
|
|
||||||
|
|
||||||
> *:nth-child(3) {
|
|
||||||
grid-column: 1 / 2;
|
|
||||||
grid-row: 2 / 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
> *:nth-child(4) {
|
|
||||||
grid-column: 2 / 3;
|
|
||||||
grid-row: 2 / 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue