Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sample
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周韬
node-sample
Commits
2cf78bd2
Commit
2cf78bd2
authored
Aug 11, 2016
by
Evan You
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add comment collapse
parent
f411fced
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
1 deletion
+19
-1
Comment.vue
src/components/Comment.vue
+19
-1
No files found.
src/components/Comment.vue
View file @
2cf78bd2
...
@@ -3,9 +3,14 @@
...
@@ -3,9 +3,14 @@
<div
class=
"by"
>
<div
class=
"by"
>
<router-link
:to=
"'/user/' + comment.by"
>
{{
comment
.
by
}}
</router-link>
<router-link
:to=
"'/user/' + comment.by"
>
{{
comment
.
by
}}
</router-link>
{{
comment
.
time
|
timeAgo
}}
ago
{{
comment
.
time
|
timeAgo
}}
ago
<span
v-if=
"comment.kids && comment.kids.length"
>
|
<a
class=
"expand"
@
click=
"open = !open"
>
{{
(
open
?
'collapse '
:
'expand '
)
+
pluralize
(
comment
.
kids
.
length
)
}}
</a>
</span>
</div>
</div>
<div
class=
"text"
v-html=
"comment.text"
></div>
<div
class=
"text"
v-html=
"comment.text"
></div>
<ul
class=
"comment-children"
>
<ul
class=
"comment-children"
v-show=
"open"
>
<comment
v-for=
"id in comment.kids"
:id=
"id"
></comment>
<comment
v-for=
"id in comment.kids"
:id=
"id"
></comment>
</ul>
</ul>
</li>
</li>
...
@@ -15,6 +20,11 @@
...
@@ -15,6 +20,11 @@
export
default
{
export
default
{
name
:
'comment'
,
name
:
'comment'
,
props
:
[
'id'
],
props
:
[
'id'
],
data
()
{
return
{
open
:
true
}
},
computed
:
{
computed
:
{
comment
()
{
comment
()
{
return
this
.
$store
.
state
.
items
[
this
.
id
]
return
this
.
$store
.
state
.
items
[
this
.
id
]
...
@@ -24,6 +34,11 @@ export default {
...
@@ -24,6 +34,11 @@ export default {
this
.
$store
.
dispatch
(
'FETCH_ITEMS'
,
{
this
.
$store
.
dispatch
(
'FETCH_ITEMS'
,
{
ids
:
[
this
.
id
]
ids
:
[
this
.
id
]
})
})
},
methods
:
{
pluralize
(
n
)
{
return
n
+
(
n
===
1
?
' reply'
:
' replies'
)
}
}
}
}
}
</
script
>
</
script
>
...
@@ -35,6 +50,9 @@ export default {
...
@@ -35,6 +50,9 @@ export default {
.comment
.comment
border-top 1px solid #eee
border-top 1px solid #eee
position relative
.expand
cursor pointer
.by, .text
.by, .text
font-size .9em
font-size .9em
padding 1em 0
padding 1em 0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment