Skip to content

Commit 9bb9268

Browse files
committed
Show reply only for a selected comment
1 parent 6a554d4 commit 9bb9268

File tree

3 files changed

+56
-15
lines changed

3 files changed

+56
-15
lines changed

src/assets/iconReply.svg

Lines changed: 2 additions & 2 deletions
Loading

src/components/tipRecords/TipComment.vue

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,31 @@
1919
:comment="{ tipId, id }"
2020
@click.native.stop
2121
/>
22-
<span
22+
<div
2323
class="comments-count"
2424
:title="$t('components.tipRecords.TipComment.Replies')"
2525
>
26-
<img src="../../assets/iconReply.svg">
27-
&nbsp;<span>{{ children.length }}</span>
28-
</span>
26+
<ButtonPlain @click.stop="$emit('reply')">
27+
<IconReply />
28+
</ButtonPlain>
29+
<span>&nbsp;{{ children.length }}</span>
30+
</div>
2931
</div>
3032
</div>
3133
</template>
3234

3335
<script>
3436
import TipInput from '../TipInput.vue';
3537
import AuthorAndDate from './AuthorAndDate.vue';
38+
import ButtonPlain from '../ButtonPlain.vue';
39+
import IconReply from '../../assets/iconReply.svg?icon-component';
3640
3741
export default {
3842
components: {
3943
TipInput,
4044
AuthorAndDate,
45+
ButtonPlain,
46+
IconReply,
4147
},
4248
inheritAttrs: false,
4349
props: {
@@ -102,8 +108,23 @@ export default {
102108
padding-top: 0.5rem;
103109
}
104110
105-
.comments-count > * {
106-
vertical-align: middle;
111+
.comments-count {
112+
span {
113+
vertical-align: middle;
114+
}
115+
116+
.button-plain {
117+
color: $search_nav_border_color;
118+
transition: color 0.3s;
119+
120+
&:hover {
121+
color: $standard_font_color;
122+
}
123+
124+
svg {
125+
height: 14px;
126+
}
127+
}
107128
}
108129
109130
> :not(:first-child) {

src/components/tipRecords/TipCommentList.vue

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,23 @@
55
:key="comment.id"
66
class="tree"
77
>
8-
<TipComment v-bind="comment" />
8+
<TipComment
9+
v-bind="comment"
10+
@reply="openReply = comment.id"
11+
/>
912
<TipComment
1013
v-for="childComment in sort(comment.children || [], true)"
1114
:key="childComment.id"
1215
v-bind="childComment"
16+
@reply="openReply = comment.id"
1317
/>
14-
<SendComment
15-
:tip-id="comment.tipId"
16-
:parent-id="comment.id"
17-
/>
18+
<Transition name="fade">
19+
<SendComment
20+
v-if="openReply === comment.id"
21+
:tip-id="comment.tipId"
22+
:parent-id="comment.id"
23+
/>
24+
</Transition>
1825
</div>
1926
</div>
2027
</template>
@@ -31,6 +38,7 @@ export default {
3138
props: {
3239
comments: { type: Array, required: true },
3340
},
41+
data: () => ({ openReply: null }),
3442
methods: {
3543
sort: (array, isAsc) => array.slice().sort((a, b) => {
3644
const values = [a, b].map((e) => Date.parse(e.createdAt));
@@ -66,14 +74,26 @@ export default {
6674
border-radius: 0;
6775
}
6876
69-
+ .tip-comment,
70-
+ .tip-comment + .send-comment {
77+
+ .tip-comment {
7178
padding-left: 3rem;
7279
7380
@include smallest {
7481
padding-left: 1.5rem;
7582
}
7683
}
7784
}
85+
86+
.send-comment {
87+
&.fade-enter-active,
88+
&.fade-leave-active {
89+
transition: all 0.3s ease;
90+
}
91+
92+
&.fade-enter,
93+
&.fade-leave-to {
94+
opacity: 0;
95+
transform: scaleY(0);
96+
}
97+
}
7898
}
7999
</style>

0 commit comments

Comments
 (0)