-
Notifications
You must be signed in to change notification settings - Fork 7
/
ProseImg.vue
57 lines (51 loc) · 958 Bytes
/
ProseImg.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<template>
<span class="image">
<nuxt-img
:src="$attrs.src"
:alt="$attrs.title"
:width="$attrs.width"
:height="$attrs.height"
:title="$attrs.src"
/>
<label>{{ $attrs.title || $attrs.alt || 'Image' }}{{ size }}</label>
</span>
</template>
<script>
/**
* The following attributes are written into the parsed HTML:
*
* - style="aspect-ratio=640/480"
* - data-width="640"
* - data-height="480"
*/
export default {
inheritAttrs: false,
computed: {
size () {
const { width, height } = this.$attrs
return width && height
? ` (${width}px x ${height}px)`
: ''
}
}
}
</script>
<style>
.image {
padding: 1rem;
border: 1px solid #EEE;
border-radius: 8px;
margin: .5rem 0;
}
.image img {
background: #EEE;
border-radius: 3px;
}
.image label {
display: block;
margin-top: .5rem;
margin-bottom: -.5rem;
text-align: center;
font-size: .8em;
}
</style>