|
15 | 15 |
|
16 | 16 | <script>
|
17 | 17 | const slots = [
|
18 |
| - 'title', |
19 |
| - 'subtitle', |
20 |
| - 'supportingText', |
21 |
| - 'media', |
22 |
| - 'actions', |
23 |
| - 'menu' |
| 18 | + 'title', |
| 19 | + 'subtitle', |
| 20 | + 'supportingText', |
| 21 | + 'media', |
| 22 | + 'actions', |
| 23 | + 'menu' |
24 | 24 | ]
|
25 | 25 |
|
26 | 26 | export default {
|
27 |
| - computed: { |
28 |
| - isActionsURL() { |
29 |
| - if (typeof this.actions === 'string') { |
30 |
| - return this.actions.match(/^(https?:)?\/\//) !== null |
31 |
| - } |
| 27 | + computed: { |
| 28 | + isActionsURL() { |
| 29 | + if (typeof this.actions === 'string') { |
| 30 | + return this.actions.match(/^(https?:)?\/\//) !== null |
| 31 | + } |
32 | 32 |
|
33 |
| - return false |
34 |
| - }, |
35 |
| - supportingText() { |
36 |
| - return this.post.body |
37 |
| - }, |
38 |
| - subtitle() { |
39 |
| - const formattedDate = new Date(this.post.created_at) |
40 |
| - .toString() |
41 |
| - .split(' ') |
42 |
| - .slice(0, 5) |
43 |
| - .join(' ') |
| 33 | + return false |
| 34 | + }, |
| 35 | + supportingText() { |
| 36 | + return this.post.body |
| 37 | + }, |
| 38 | + subtitle() { |
| 39 | + const formattedDate = new Date(this.post.created_at) |
| 40 | + .toString() |
| 41 | + .split(' ') |
| 42 | + .slice(0, 5) |
| 43 | + .join(' ') |
44 | 44 |
|
45 |
| - return ` |
46 |
| - <span class="post-timestamp">${formattedDate}</span> |
47 |
| - <span class="post-id">${this.post._id}</span> |
48 |
| - ` |
49 |
| - } |
50 |
| - }, |
51 |
| - props: { |
52 |
| - title: { |
53 |
| - type: String, |
54 |
| - default: true |
55 |
| - }, |
56 |
| - menu: { |
57 |
| - default: true |
58 |
| - }, |
59 |
| - actions: { |
60 |
| - type: String, |
61 |
| - default: true |
62 |
| - }, |
63 |
| - actionsTarget: { |
64 |
| - default: '_self', |
65 |
| - type: String |
66 |
| - }, |
67 |
| - actionsText: String, |
68 |
| - media: { |
69 |
| - default: true, |
70 |
| - type: String |
| 45 | + return ` |
| 46 | + <span class="post-timestamp">${formattedDate}</span> |
| 47 | + <span class="post-id">${this.post._id}</span> |
| 48 | + ` |
| 49 | + } |
71 | 50 | },
|
72 |
| - subtitle: { |
73 |
| - default: true, |
74 |
| - type: String |
| 51 | + props: { |
| 52 | + title: { |
| 53 | + type: String, |
| 54 | + default: true |
| 55 | + }, |
| 56 | + menu: { |
| 57 | + default: true |
| 58 | + }, |
| 59 | + actions: { |
| 60 | + type: String, |
| 61 | + default: true |
| 62 | + }, |
| 63 | + actionsTarget: { |
| 64 | + default: '_self', |
| 65 | + type: String |
| 66 | + }, |
| 67 | + actionsText: String, |
| 68 | + media: { |
| 69 | + default: true, |
| 70 | + type: String |
| 71 | + }, |
| 72 | + subtitle: { |
| 73 | + default: true, |
| 74 | + type: String |
| 75 | + }, |
| 76 | + supportingText: { |
| 77 | + default: true, |
| 78 | + type: String |
| 79 | + }, |
| 80 | + post: { |
| 81 | + default: true |
| 82 | + } |
75 | 83 | },
|
76 |
| - supportingText: { |
77 |
| - default: true, |
78 |
| - type: String |
| 84 | + compiled() { |
| 85 | + slots.forEach((slot, pos) => { |
| 86 | + if (this[slot] === true) { |
| 87 | + const el = this.$el.children[pos] |
| 88 | + if (!el || !el.attributes.getNamedItem('slot')) { |
| 89 | + this[slot] = '' |
| 90 | + } |
| 91 | + } |
| 92 | + }) |
79 | 93 | },
|
80 |
| - post: { |
81 |
| - default: true |
82 |
| - } |
83 |
| - }, |
84 |
| - compiled() { |
85 |
| - slots.forEach((slot, pos) => { |
86 |
| - if (this[slot] === true) { |
87 |
| - const el = this.$el.children[pos] |
88 |
| - if (!el || !el.attributes.getNamedItem('slot')) { |
89 |
| - this[slot] = '' |
| 94 | + methods: { |
| 95 | + triggerMenuEvent() { |
| 96 | + this.$dispatch(this.menu) |
| 97 | + }, |
| 98 | + triggerActionsEvent() { |
| 99 | + this.$dispatch(this.actions) |
90 | 100 | }
|
91 |
| - } |
92 |
| - }) |
93 |
| - // el = @$el.children[pos]?.attributes.getNamedItem 'slot' |
94 |
| - }, |
95 |
| - methods: { |
96 |
| - triggerMenuEvent() { |
97 |
| - this.$dispatch(this.menu) |
98 |
| - }, |
99 |
| - triggerActionsEvent() { |
100 |
| - this.$dispatch(this.actions) |
101 | 101 | }
|
102 |
| - } |
103 | 102 | }
|
104 | 103 | </script>
|
105 | 104 |
|
|
0 commit comments