Skip to content
Snippets Groups Projects
Commit ac753727 authored by syuilo's avatar syuilo
Browse files

enhance(client): tweak medialist style

parent f9a2e988
No related branches found
No related tags found
No related merge requests found
<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<{ ...@@ -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,83 +123,62 @@ const previewable = (file: misskey.entities.DriveFile): boolean => { ...@@ -122,83 +123,62 @@ 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 { .medias {
content: ''; display: grid;
display: block; grid-gap: 8px;
padding-top: 56.25% // 16:9;
&.n1 {
aspect-ratio: 16/9;
grid-template-rows: 1fr;
}
&.n2 {
aspect-ratio: 16/9;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr;
}
&.n3 {
aspect-ratio: 16/9;
grid-template-columns: 1fr 0.5fr;
grid-template-rows: 1fr 1fr;
> .media:nth-child(1) {
grid-row: 1 / 3;
} }
> div { > .media:nth-child(3) {
position: absolute; grid-column: 2 / 3;
top: 0; grid-row: 2 / 3;
right: 0; }
bottom: 0; }
left: 0;
display: grid;
grid-gap: 8px;
> * {
overflow: hidden;
border-radius: 6px;
}
&[data-count="1"] {
grid-template-rows: 1fr;
}
&[data-count="2"] {
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr;
}
&[data-count="3"] {
grid-template-columns: 1fr 0.5fr;
grid-template-rows: 1fr 1fr;
> *:nth-child(1) {
grid-row: 1 / 3;
}
> *:nth-child(3) { &.n4 {
grid-column: 2 / 3; aspect-ratio: 16/9;
grid-row: 2 / 3; grid-template-columns: 1fr 1fr;
} grid-template-rows: 1fr 1fr;
} }
&[data-count="4"] { &.nMany {
grid-template-columns: 1fr 1fr; grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr 1fr;
} > .media {
aspect-ratio: 16/9;
> *:nth-child(1) {
grid-column: 1 / 2;
grid-row: 1 / 2;
}
> *:nth-child(2) {
grid-column: 2 / 3;
grid-row: 1 / 2;
}
> *:nth-child(3) {
grid-column: 1 / 2;
grid-row: 2 / 3;
}
> *:nth-child(4) {
grid-column: 2 / 3;
grid-row: 2 / 3;
}
} }
} }
} }
.media {
overflow: hidden; // clipにするとバグる
border-radius: 8px;
}
</style> </style>
<style lang="scss"> <style lang="scss">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment