Change media style

This commit is contained in:
kPherox 2019-05-22 16:02:31 +09:00
parent 8286602d62
commit 8221f5495f
No known key found for this signature in database
GPG Key ID: C04751C2BFA2F62D
2 changed files with 48 additions and 2 deletions

View File

@ -63,7 +63,7 @@ export default class Column extends Vue {
let doc: TimelineDoc = ipcRenderer.sendSync('get-timeline', this.id) let doc: TimelineDoc = ipcRenderer.sendSync('get-timeline', this.id)
this.name = doc.name this.name = doc.name
this.type = doc.type this.type = doc.type
// TODO: channeltimelineid
ipcRenderer.once(`timeline-${this.name}-${this.type}`, (e: Event, statuses: Status[], error?: Error) => { ipcRenderer.once(`timeline-${this.name}-${this.type}`, (e: Event, statuses: Status[], error?: Error) => {
if (error === undefined) { if (error === undefined) {
this.loadTL(statuses) this.loadTL(statuses)

View File

@ -15,6 +15,8 @@
v-if="media.type === 'image'" v-if="media.type === 'image'"
:src="media.preview_url" :src="media.preview_url"
@click="showImage(media.url, media.type)" @click="showImage(media.url, media.type)"
:title="media.description"
:style="mediaStyles(media)"
> >
</div> </div>
</div> </div>
@ -52,6 +54,29 @@ interface Preferences {
static?: boolean static?: boolean
} }
interface Attachment {
id: string
type: 'unknown' | 'image' | 'gifv' | 'video'
url: string
remote_url?: string
preview_url: string
text_url?: string
meta?: { original: MediaMeta, small: MediaMeta } & { focus?: { x: number, y: number } }
description?: string
blurhash?: string
}
interface MediaMeta {
width: number
height: number
size?: string
aspect?: number
frame_rate?: number
duration?: number
bitrate?: number
}
@Component({ @Component({
components: { components: {
ChangeToAlt, ChangeToAlt,
@ -66,7 +91,7 @@ export default class Toot extends Vue {
public isMoreAction: boolean = false public isMoreAction: boolean = false
get pref(): Preferences { public get pref(): Preferences {
return { return {
static: this.prefStatic static: this.prefStatic
} }
@ -75,6 +100,14 @@ export default class Toot extends Vue {
mounted() { mounted() {
console.log(this.status) console.log(this.status)
} }
public mediaStyles(media: Attachment): { [key: string]: string } {
if (media.meta === undefined || media.meta.focus === undefined) {
return {}
}
return { objectPosition: `${media.meta.focus.x}% ${media.meta.focus.y}%` }
}
} }
</script> </script>
@ -117,6 +150,19 @@ export default class Toot extends Vue {
} }
.toot-media { .toot-media {
grid-area: media; grid-area: media;
display: flex;
.media-item {
flex: 1;
& + .media-item {
border-left: var(--bg-color) solid 1px;
}
}
img {
object-fit: cover;
object-position: 0%;
height: 200px;
width: 100%;
}
} }
.toot-card { .toot-card {
grid-area: card; grid-area: card;