🎨
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
<mk-images-viewer>
|
||||
<div class="image" ref="view" onclick={ click }><img ref="img" src={ image.url + '?thumbnail&size=512' } alt={ image.name } title={ image.name }/></div>
|
||||
<style>
|
||||
:scope
|
||||
display block
|
||||
overflow hidden
|
||||
border-radius 4px
|
||||
|
||||
> .image
|
||||
|
||||
> img
|
||||
display block
|
||||
max-height 256px
|
||||
max-width 100%
|
||||
margin 0 auto
|
||||
|
||||
</style>
|
||||
<script>
|
||||
this.images = this.opts.images;
|
||||
this.image = this.images[0];
|
||||
|
||||
this.click = () => {
|
||||
window.open(this.image.url);
|
||||
};
|
||||
</script>
|
||||
</mk-images-viewer>
|
78
src/web/app/mobile/tags/images.tag
Normal file
78
src/web/app/mobile/tags/images.tag
Normal file
@@ -0,0 +1,78 @@
|
||||
<mk-images>
|
||||
<virtual each={ image in images }>
|
||||
<mk-images-image image={ image }/>
|
||||
</virtual>
|
||||
<style>
|
||||
:scope
|
||||
display grid
|
||||
grid-gap 4px
|
||||
height 256px
|
||||
|
||||
@media (max-width 500px)
|
||||
height 192px
|
||||
</style>
|
||||
<script>
|
||||
this.images = this.opts.images;
|
||||
|
||||
this.on('mount', () => {
|
||||
if (this.images.length == 1) {
|
||||
this.root.style.gridTemplateRows = '1fr';
|
||||
|
||||
this.tags['mk-images-image'].root.style.gridColumn = '1 / 2';
|
||||
this.tags['mk-images-image'].root.style.gridRow = '1 / 2';
|
||||
} else if (this.images.length == 2) {
|
||||
this.root.style.gridTemplateColumns = '1fr 1fr';
|
||||
this.root.style.gridTemplateRows = '1fr';
|
||||
|
||||
this.tags['mk-images-image'][0].root.style.gridColumn = '1 / 2';
|
||||
this.tags['mk-images-image'][0].root.style.gridRow = '1 / 2';
|
||||
this.tags['mk-images-image'][1].root.style.gridColumn = '2 / 3';
|
||||
this.tags['mk-images-image'][1].root.style.gridRow = '1 / 2';
|
||||
} else if (this.images.length == 3) {
|
||||
this.root.style.gridTemplateColumns = '1fr 0.5fr';
|
||||
this.root.style.gridTemplateRows = '1fr 1fr';
|
||||
|
||||
this.tags['mk-images-image'][0].root.style.gridColumn = '1 / 2';
|
||||
this.tags['mk-images-image'][0].root.style.gridRow = '1 / 3';
|
||||
this.tags['mk-images-image'][1].root.style.gridColumn = '2 / 3';
|
||||
this.tags['mk-images-image'][1].root.style.gridRow = '1 / 2';
|
||||
this.tags['mk-images-image'][2].root.style.gridColumn = '2 / 3';
|
||||
this.tags['mk-images-image'][2].root.style.gridRow = '2 / 3';
|
||||
} else if (this.images.length == 4) {
|
||||
this.root.style.gridTemplateColumns = '1fr 1fr';
|
||||
this.root.style.gridTemplateRows = '1fr 1fr';
|
||||
|
||||
this.tags['mk-images-image'][0].root.style.gridColumn = '1 / 2';
|
||||
this.tags['mk-images-image'][0].root.style.gridRow = '1 / 2';
|
||||
this.tags['mk-images-image'][1].root.style.gridColumn = '2 / 3';
|
||||
this.tags['mk-images-image'][1].root.style.gridRow = '1 / 2';
|
||||
this.tags['mk-images-image'][2].root.style.gridColumn = '1 / 2';
|
||||
this.tags['mk-images-image'][2].root.style.gridRow = '2 / 3';
|
||||
this.tags['mk-images-image'][3].root.style.gridColumn = '2 / 3';
|
||||
this.tags['mk-images-image'][3].root.style.gridRow = '2 / 3';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</mk-images>
|
||||
|
||||
<mk-images-image>
|
||||
<a ref="view" href={ image.url } target="_blank" style={ 'background-image: url(' + image.url + '?thumbnail&size=512' } title={ image.name }></a>
|
||||
<style>
|
||||
:scope
|
||||
display block
|
||||
overflow hidden
|
||||
border-radius 4px
|
||||
|
||||
> a
|
||||
display block
|
||||
overflow hidden
|
||||
width 100%
|
||||
height 100%
|
||||
background-position center
|
||||
background-size cover
|
||||
|
||||
</style>
|
||||
<script>
|
||||
this.image = this.opts.image;
|
||||
</script>
|
||||
</mk-images-image>
|
@@ -25,7 +25,7 @@ require('./home-timeline.tag');
|
||||
require('./timeline.tag');
|
||||
require('./post-preview.tag');
|
||||
require('./sub-post-content.tag');
|
||||
require('./images-viewer.tag');
|
||||
require('./images.tag');
|
||||
require('./drive.tag');
|
||||
require('./drive-selector.tag');
|
||||
require('./drive-folder-selector.tag');
|
||||
|
@@ -34,7 +34,7 @@
|
||||
<div class="body">
|
||||
<div class="text" ref="text"></div>
|
||||
<div class="media" if={ p.media }>
|
||||
<virtual each={ file in p.media }><img src={ file.url + '?thumbnail&size=512' } alt={ file.name } title={ file.name }/></virtual>
|
||||
<mk-images images={ p.media }/>
|
||||
</div>
|
||||
<mk-poll if={ p.poll } post={ p }/>
|
||||
</div>
|
||||
|
@@ -2,7 +2,7 @@
|
||||
<div class="body"><a class="reply" if={ post.reply_id }>%fa:reply%</a><span ref="text"></span><a class="quote" if={ post.repost_id } href={ '/post:' + post.repost_id }>RP: ...</a></div>
|
||||
<details if={ post.media }>
|
||||
<summary>({ post.media.length }個のメディア)</summary>
|
||||
<mk-images-viewer images={ post.media }/>
|
||||
<mk-images images={ post.media }/>
|
||||
</details>
|
||||
<details if={ post.poll }>
|
||||
<summary>%i18n:mobile.tags.mk-sub-post-content.poll%</summary>
|
||||
|
@@ -172,7 +172,7 @@
|
||||
<a class="quote" if={ p.repost != null }>RP:</a>
|
||||
</div>
|
||||
<div class="media" if={ p.media }>
|
||||
<mk-images-viewer images={ p.media }/>
|
||||
<mk-images images={ p.media }/>
|
||||
</div>
|
||||
<mk-poll if={ p.poll } post={ p } ref="pollViewer"/>
|
||||
<span class="app" if={ p.app }>via <b>{ p.app.name }</b></span>
|
||||
|
Reference in New Issue
Block a user