Commit ed76f833 authored by Evan You's avatar Evan You

tweak comment collapse styling

parent 096e7f5c
...@@ -3,13 +3,15 @@ ...@@ -3,13 +3,15 @@
<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>
<div class="toggle" :class="{ open }" v-if="comment.kids && comment.kids.length">
<a @click="open = !open">{{
open
? '[-]'
: '[+] ' + pluralize(comment.kids.length) + ' collapsed'
}}</a>
</div>
<ul class="comment-children" v-show="open"> <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>
...@@ -31,9 +33,7 @@ export default { ...@@ -31,9 +33,7 @@ export default {
} }
}, },
methods: { methods: {
pluralize (n) { pluralize: n => n + (n === 1 ? ' reply' : ' replies')
return n + (n === 1 ? ' reply' : ' replies')
}
} }
} }
</script> </script>
...@@ -41,19 +41,16 @@ export default { ...@@ -41,19 +41,16 @@ export default {
<style lang="stylus"> <style lang="stylus">
.comment-children .comment-children
.comment-children .comment-children
margin-left 1em margin-left 1.5em
.comment .comment
border-top 1px solid #eee border-top 1px solid #eee
position relative position relative
.expand .by, .text, .toggle
cursor pointer
.by, .text
font-size .9em font-size .9em
padding 1em 0 margin 1em 0
.by .by
color #999 color #999
padding-bottom 0
a a
color #999 color #999
text-decoration underline text-decoration underline
...@@ -61,4 +58,15 @@ export default { ...@@ -61,4 +58,15 @@ export default {
overflow-wrap break-word overflow-wrap break-word
a:hover a:hover
color #ff6600 color #ff6600
.toggle
background-color #fffbf2
padding .3em .5em
border-radius 4px
a
color #999
cursor pointer
&.open
padding 0
background-color transparent
margin-bottom -0.5em
</style> </style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment