Merge branch 'feat-1.3.0' of https://github.com/vueComponent/ant-design-vue into feat-1.3.0
commit
c4f08e49e2
|
@ -0,0 +1,167 @@
|
||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`renders ./components/comment/demo/basic.md correctly 1`] = `
|
||||||
|
<div class="ant-comment">
|
||||||
|
<div class="ant-comment-inner">
|
||||||
|
<div class="ant-comment-avatar"><span class="ant-avatar ant-avatar-circle ant-avatar-image"><img src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png" alt="Han Solo"></span></div>
|
||||||
|
<div class="ant-comment-content">
|
||||||
|
<div class="ant-comment-content-author"><span class="ant-comment-content-author-name"><a>Han Solo</a></span><span class="ant-comment-content-author-time"><span class="">a few seconds ago</span></span></div>
|
||||||
|
<div class="ant-comment-content-detail">
|
||||||
|
<p>We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.</p>
|
||||||
|
</div>
|
||||||
|
<ul class="ant-comment-actions">
|
||||||
|
<li><span><i class="anticon anticon-like"><svg viewBox="64 64 896 896" data-icon="like" width="1em" height="1em" fill="currentColor" aria-hidden="true" class=""><path d="M885.9 533.7c16.8-22.2 26.1-49.4 26.1-77.7 0-44.9-25.1-87.4-65.5-111.1a67.67 67.67 0 0 0-34.3-9.3H572.4l6-122.9c1.4-29.7-9.1-57.9-29.5-79.4A106.62 106.62 0 0 0 471 99.9c-52 0-98 35-111.8 85.1l-85.9 311H144c-17.7 0-32 14.3-32 32v364c0 17.7 14.3 32 32 32h601.3c9.2 0 18.2-1.8 26.5-5.4 47.6-20.3 78.3-66.8 78.3-118.4 0-12.6-1.8-25-5.4-37 16.8-22.2 26.1-49.4 26.1-77.7 0-12.6-1.8-25-5.4-37 16.8-22.2 26.1-49.4 26.1-77.7-.2-12.6-2-25.1-5.6-37.1zM184 852V568h81v284h-81zm636.4-353l-21.9 19 13.9 25.4a56.2 56.2 0 0 1 6.9 27.3c0 16.5-7.2 32.2-19.6 43l-21.9 19 13.9 25.4a56.2 56.2 0 0 1 6.9 27.3c0 16.5-7.2 32.2-19.6 43l-21.9 19 13.9 25.4a56.2 56.2 0 0 1 6.9 27.3c0 22.4-13.2 42.6-33.6 51.8H329V564.8l99.5-360.5a44.1 44.1 0 0 1 42.2-32.3c7.6 0 15.1 2.2 21.1 6.7 9.9 7.4 15.2 18.6 14.6 30.5l-9.6 198.4h314.4C829 418.5 840 436.9 840 456c0 16.5-7.2 32.1-19.6 43z"></path></svg></i> <span style="cursor: 'auto';">
|
||||||
|
0
|
||||||
|
</span></span></li>
|
||||||
|
<li> </li>
|
||||||
|
<li><span><i class="anticon anticon-dislike"><svg viewBox="64 64 896 896" data-icon="dislike" width="1em" height="1em" fill="currentColor" aria-hidden="true" class=""><path d="M885.9 490.3c3.6-12 5.4-24.4 5.4-37 0-28.3-9.3-55.5-26.1-77.7 3.6-12 5.4-24.4 5.4-37 0-28.3-9.3-55.5-26.1-77.7 3.6-12 5.4-24.4 5.4-37 0-51.6-30.7-98.1-78.3-118.4a66.1 66.1 0 0 0-26.5-5.4H144c-17.7 0-32 14.3-32 32v364c0 17.7 14.3 32 32 32h129.3l85.8 310.8C372.9 889 418.9 924 470.9 924c29.7 0 57.4-11.8 77.9-33.4 20.5-21.5 31-49.7 29.5-79.4l-6-122.9h239.9c12.1 0 23.9-3.2 34.3-9.3 40.4-23.5 65.5-66.1 65.5-111 0-28.3-9.3-55.5-26.1-77.7zM184 456V172h81v284h-81zm627.2 160.4H496.8l9.6 198.4c.6 11.9-4.7 23.1-14.6 30.5-6.1 4.5-13.6 6.8-21.1 6.7a44.28 44.28 0 0 1-42.2-32.3L329 459.2V172h415.4a56.85 56.85 0 0 1 33.6 51.8c0 9.7-2.3 18.9-6.9 27.3l-13.9 25.4 21.9 19a56.76 56.76 0 0 1 19.6 43c0 9.7-2.3 18.9-6.9 27.3l-13.9 25.4 21.9 19a56.76 56.76 0 0 1 19.6 43c0 9.7-2.3 18.9-6.9 27.3l-14 25.5 21.9 19a56.76 56.76 0 0 1 19.6 43c0 19.1-11 37.5-28.8 48.4z"></path></svg></i> <span style="cursor: 'auto';">
|
||||||
|
0
|
||||||
|
</span></span></li>
|
||||||
|
<li> </li>
|
||||||
|
<li><span>Reply to</span></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`renders ./components/comment/demo/editor.md correctly 1`] = `
|
||||||
|
<div>
|
||||||
|
<!---->
|
||||||
|
<div class="ant-comment">
|
||||||
|
<div class="ant-comment-inner">
|
||||||
|
<div class="ant-comment-avatar"><span class="ant-avatar ant-avatar-circle ant-avatar-image"><img src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png" alt="Han Solo"></span></div>
|
||||||
|
<div class="ant-comment-content">
|
||||||
|
<div class="ant-comment-content-author"></div>
|
||||||
|
<div class="ant-comment-content-detail">
|
||||||
|
<div>
|
||||||
|
<div class="ant-row ant-form-item">
|
||||||
|
<div class="ant-form-item-control-wrapper">
|
||||||
|
<div class="ant-form-item-control"><span class="ant-form-item-children"><textarea value="" rows="4" class="ant-input"></textarea></span>
|
||||||
|
<!---->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="ant-row ant-form-item">
|
||||||
|
<div class="ant-form-item-control-wrapper">
|
||||||
|
<div class="ant-form-item-control"><span class="ant-form-item-children"><button type="submit" class="ant-btn ant-btn-primary"><span>Add Comment</span></button></span>
|
||||||
|
<!---->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`renders ./components/comment/demo/list.md correctly 1`] = `
|
||||||
|
<div class="comment-list ant-list ant-list-split">
|
||||||
|
<div class="ant-list-header">2 replies</div>
|
||||||
|
<div class="ant-spin-nested-loading">
|
||||||
|
<div class="ant-spin-container">
|
||||||
|
<div class="ant-list-item">
|
||||||
|
<div class="ant-list-item-content ant-list-item-content-single">
|
||||||
|
<div class="ant-comment">
|
||||||
|
<div class="ant-comment-inner">
|
||||||
|
<div class="ant-comment-avatar"><img src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"></div>
|
||||||
|
<div class="ant-comment-content">
|
||||||
|
<div class="ant-comment-content-author"><span class="ant-comment-content-author-name">Han Solo</span></div>
|
||||||
|
<div class="ant-comment-content-detail">
|
||||||
|
<p>We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.</p>
|
||||||
|
</div>
|
||||||
|
<ul class="ant-comment-actions">
|
||||||
|
<li><span>Reply to</span></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="ant-list-item">
|
||||||
|
<div class="ant-list-item-content ant-list-item-content-single">
|
||||||
|
<div class="ant-comment">
|
||||||
|
<div class="ant-comment-inner">
|
||||||
|
<div class="ant-comment-avatar"><img src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"></div>
|
||||||
|
<div class="ant-comment-content">
|
||||||
|
<div class="ant-comment-content-author"><span class="ant-comment-content-author-name">Han Solo</span></div>
|
||||||
|
<div class="ant-comment-content-detail">
|
||||||
|
<p>We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.</p>
|
||||||
|
</div>
|
||||||
|
<ul class="ant-comment-actions">
|
||||||
|
<li><span>Reply to</span></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`renders ./components/comment/demo/nested.md correctly 1`] = `
|
||||||
|
<div class="ant-comment">
|
||||||
|
<div class="ant-comment-inner">
|
||||||
|
<div class="ant-comment-avatar"><span class="ant-avatar ant-avatar-circle ant-avatar-image"><img src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png" alt="Han Solo"></span></div>
|
||||||
|
<div class="ant-comment-content">
|
||||||
|
<div class="ant-comment-content-author"><span class="ant-comment-content-author-name"><a>Han Solo</a></span></div>
|
||||||
|
<div class="ant-comment-content-detail">
|
||||||
|
<p>We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure).</p>
|
||||||
|
</div>
|
||||||
|
<ul class="ant-comment-actions">
|
||||||
|
<li><span>Reply to</span></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="ant-comment-nested">
|
||||||
|
<div class="ant-comment">
|
||||||
|
<div class="ant-comment-inner">
|
||||||
|
<div class="ant-comment-avatar"><span class="ant-avatar ant-avatar-circle ant-avatar-image"><img src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png" alt="Han Solo"></span></div>
|
||||||
|
<div class="ant-comment-content">
|
||||||
|
<div class="ant-comment-content-author"><span class="ant-comment-content-author-name"><a>Han Solo</a></span></div>
|
||||||
|
<div class="ant-comment-content-detail">
|
||||||
|
<p>We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure).</p>
|
||||||
|
</div>
|
||||||
|
<ul class="ant-comment-actions">
|
||||||
|
<li><span>Reply to</span></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="ant-comment-nested">
|
||||||
|
<div class="ant-comment">
|
||||||
|
<div class="ant-comment-inner">
|
||||||
|
<div class="ant-comment-avatar"><span class="ant-avatar ant-avatar-circle ant-avatar-image"><img src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png" alt="Han Solo"></span></div>
|
||||||
|
<div class="ant-comment-content">
|
||||||
|
<div class="ant-comment-content-author"><span class="ant-comment-content-author-name"><a>Han Solo</a></span></div>
|
||||||
|
<div class="ant-comment-content-detail">
|
||||||
|
<p>We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure).</p>
|
||||||
|
</div>
|
||||||
|
<ul class="ant-comment-actions">
|
||||||
|
<li><span>Reply to</span></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="ant-comment">
|
||||||
|
<div class="ant-comment-inner">
|
||||||
|
<div class="ant-comment-avatar"><span class="ant-avatar ant-avatar-circle ant-avatar-image"><img src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png" alt="Han Solo"></span></div>
|
||||||
|
<div class="ant-comment-content">
|
||||||
|
<div class="ant-comment-content-author"><span class="ant-comment-content-author-name"><a>Han Solo</a></span></div>
|
||||||
|
<div class="ant-comment-content-detail">
|
||||||
|
<p>We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure).</p>
|
||||||
|
</div>
|
||||||
|
<ul class="ant-comment-actions">
|
||||||
|
<li><span>Reply to</span></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
|
@ -0,0 +1,3 @@
|
||||||
|
import demoTest from '../../../tests/shared/demoTest'
|
||||||
|
|
||||||
|
demoTest('comment')
|
|
@ -0,0 +1,78 @@
|
||||||
|
<cn>
|
||||||
|
#### 基本评论
|
||||||
|
一个基本的评论组件,带有作者、头像、时间和操作。
|
||||||
|
</cn>
|
||||||
|
|
||||||
|
<us>
|
||||||
|
#### Basic comment
|
||||||
|
A basic comment with author, avatar, time and actions.
|
||||||
|
</us>
|
||||||
|
|
||||||
|
```html
|
||||||
|
<template>
|
||||||
|
<a-comment>
|
||||||
|
<template slot="actions">
|
||||||
|
<span>
|
||||||
|
<a-tooltip title="Like">
|
||||||
|
<a-icon
|
||||||
|
type="like"
|
||||||
|
:theme="action === 'liked' ? 'filled' : 'outlined'"
|
||||||
|
@click="like"
|
||||||
|
/>
|
||||||
|
</a-tooltip>
|
||||||
|
<span style="paddingLeft: '8px';cursor: 'auto'">
|
||||||
|
{{likes}}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<a-tooltip title="Dislike">
|
||||||
|
<a-icon
|
||||||
|
type="dislike"
|
||||||
|
:theme="action === 'disliked' ? 'filled' : 'outlined'"
|
||||||
|
@click="dislike"
|
||||||
|
/>
|
||||||
|
</a-tooltip>
|
||||||
|
<span style="paddingLeft: '8px';cursor: 'auto'">
|
||||||
|
{{dislikes}}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<span>Reply to</span>
|
||||||
|
</template>
|
||||||
|
<a slot="author">Han Solo</a>
|
||||||
|
<a-avatar
|
||||||
|
src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"
|
||||||
|
alt="Han Solo"
|
||||||
|
slot="avatar"
|
||||||
|
/>
|
||||||
|
<p slot="content">We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.</p>
|
||||||
|
<a-tooltip slot="datetime" :title="moment().format('YYYY-MM-DD HH:mm:ss')">
|
||||||
|
<span>{{moment().fromNow()}}</span>
|
||||||
|
</a-tooltip>
|
||||||
|
</a-comment>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import moment from 'moment'
|
||||||
|
export default {
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
likes: 0,
|
||||||
|
dislikes: 0,
|
||||||
|
action: null,
|
||||||
|
moment,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
like() {
|
||||||
|
this.likes = 1
|
||||||
|
this.dislikes = 0
|
||||||
|
this.action = 'liked'
|
||||||
|
},
|
||||||
|
dislike() {
|
||||||
|
this.likes = 0
|
||||||
|
this.dislikes = 1
|
||||||
|
this.action = 'disliked'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
```
|
|
@ -0,0 +1,93 @@
|
||||||
|
<cn>
|
||||||
|
#### 回复框
|
||||||
|
评论编辑器组件提供了相同样式的封装以支持自定义评论编辑器。
|
||||||
|
</cn>
|
||||||
|
|
||||||
|
<us>
|
||||||
|
#### Reply Editor
|
||||||
|
Comment can be used as editor, user can customize the editor component.
|
||||||
|
</us>
|
||||||
|
|
||||||
|
```html
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<a-list
|
||||||
|
v-if="comments.length"
|
||||||
|
:dataSource="comments"
|
||||||
|
:header="`${comments.length} ${comments.length > 1 ? 'replies' : 'reply'}`"
|
||||||
|
itemLayout="horizontal"
|
||||||
|
>
|
||||||
|
<a-list-item slot="renderItem" slot-scope="item, index">
|
||||||
|
<a-comment
|
||||||
|
:author="item.author"
|
||||||
|
:avatar="item.avatar"
|
||||||
|
:content="item.content"
|
||||||
|
:datetime="item.datetime"
|
||||||
|
>
|
||||||
|
</a-comment>
|
||||||
|
</a-list-item>
|
||||||
|
</a-list>
|
||||||
|
<a-comment>
|
||||||
|
<a-avatar
|
||||||
|
slot="avatar"
|
||||||
|
src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"
|
||||||
|
alt="Han Solo"
|
||||||
|
/>
|
||||||
|
<div slot="content">
|
||||||
|
<a-form-item>
|
||||||
|
<a-textarea rows=4 @change="handleChange" :value="value" ></a-textarea>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item>
|
||||||
|
<a-button
|
||||||
|
htmlType="submit"
|
||||||
|
:loading="submitting"
|
||||||
|
@click="handleSubmit"
|
||||||
|
type="primary"
|
||||||
|
>
|
||||||
|
Add Comment
|
||||||
|
</a-button>
|
||||||
|
</a-form-item>
|
||||||
|
</div>
|
||||||
|
</a-comment>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import moment from 'moment'
|
||||||
|
export default {
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
comments: [],
|
||||||
|
submitting: false,
|
||||||
|
value: '',
|
||||||
|
moment,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleSubmit() {
|
||||||
|
if (!this.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.submitting = true
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.submitting = false
|
||||||
|
this.comments = [
|
||||||
|
{
|
||||||
|
author: 'Han Solo',
|
||||||
|
avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
|
||||||
|
content: this.value,
|
||||||
|
datetime: moment().fromNow(),
|
||||||
|
},
|
||||||
|
...this.comments,
|
||||||
|
]
|
||||||
|
this.value = ''
|
||||||
|
}, 1000)
|
||||||
|
},
|
||||||
|
handleChange(e) {
|
||||||
|
this.value = e.target.value
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
```
|
|
@ -0,0 +1,52 @@
|
||||||
|
<script>
|
||||||
|
import Basic from './basic'
|
||||||
|
import Editor from './editor'
|
||||||
|
import List from './list'
|
||||||
|
import Nested from './nested'
|
||||||
|
import CN from '../index.zh-CN.md'
|
||||||
|
import US from '../index.en-US.md'
|
||||||
|
|
||||||
|
const md = {
|
||||||
|
cn: `# Comment评论
|
||||||
|
对网站内容的反馈、评价和讨论。
|
||||||
|
|
||||||
|
## 何时使用
|
||||||
|
|
||||||
|
评论组件可用于对事物的讨论,例如页面、博客文章、问题等等。`,
|
||||||
|
us: `# Comment
|
||||||
|
A comment displays user feedback and discussion to website content.
|
||||||
|
|
||||||
|
## When To Use
|
||||||
|
|
||||||
|
Comments can be used to enable discussions on an entity such as a page, blog post, issue or other.`,
|
||||||
|
}
|
||||||
|
export default {
|
||||||
|
category: 'Components',
|
||||||
|
type: 'Data Display',
|
||||||
|
zhType: '数据展示',
|
||||||
|
title: 'Comment',
|
||||||
|
subtitle: '评论',
|
||||||
|
cols: 1,
|
||||||
|
render () {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<md cn={md.cn} us={md.us}/>
|
||||||
|
<Basic/>
|
||||||
|
<br/>
|
||||||
|
<List/>
|
||||||
|
<br/>
|
||||||
|
<Nested/>
|
||||||
|
<br/>
|
||||||
|
<Editor/>
|
||||||
|
<br/>
|
||||||
|
<api>
|
||||||
|
<template slot='cn'>
|
||||||
|
<CN/>
|
||||||
|
</template>
|
||||||
|
<US/>
|
||||||
|
</api>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -0,0 +1,61 @@
|
||||||
|
<cn>
|
||||||
|
#### 配合 List 组件
|
||||||
|
配合 List 组件展现评论列表。
|
||||||
|
</cn>
|
||||||
|
|
||||||
|
<us>
|
||||||
|
#### Usage with list
|
||||||
|
Displaying a series of comments using the `antd` List Component.
|
||||||
|
</us>
|
||||||
|
|
||||||
|
```html
|
||||||
|
<template>
|
||||||
|
<a-list
|
||||||
|
class="comment-list"
|
||||||
|
:header="`${data.length} replies`"
|
||||||
|
itemLayout="horizontal"
|
||||||
|
:dataSource="data"
|
||||||
|
>
|
||||||
|
<a-list-item slot="renderItem" slot-scope="item, index">
|
||||||
|
<a-comment
|
||||||
|
:author="item.author"
|
||||||
|
:avatar="item.avatar"
|
||||||
|
>
|
||||||
|
<template slot="actions">
|
||||||
|
<span v-for="action in item.actions">{{action}}</span>
|
||||||
|
</template>
|
||||||
|
<p slot="content">{{item.content}}</p>
|
||||||
|
<a-tooltip slot="dateTime" :title="item.datetime.format('YYYY-MM-DD HH:mm:ss')">
|
||||||
|
<span>{{item.datetime.fromNow()}}</span>
|
||||||
|
</a-tooltip>
|
||||||
|
</a-comment>
|
||||||
|
</a-list-item>
|
||||||
|
</a-list>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import moment from 'moment'
|
||||||
|
export default {
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
actions: ['Reply to'],
|
||||||
|
author: 'Han Solo',
|
||||||
|
avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
|
||||||
|
content: 'We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.',
|
||||||
|
datetime: moment().subtract(1, 'days'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
actions: ['Reply to'],
|
||||||
|
author: 'Han Solo',
|
||||||
|
avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
|
||||||
|
content: 'We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.',
|
||||||
|
datetime: moment().subtract(2, 'days'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
moment,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
```
|
|
@ -0,0 +1,74 @@
|
||||||
|
<cn>
|
||||||
|
#### 嵌套评论
|
||||||
|
评论可以嵌套。
|
||||||
|
</cn>
|
||||||
|
|
||||||
|
<us>
|
||||||
|
#### Nested comments
|
||||||
|
Comments can be nested.
|
||||||
|
</us>
|
||||||
|
|
||||||
|
```html
|
||||||
|
<template>
|
||||||
|
<a-comment>
|
||||||
|
<template slot="actions">
|
||||||
|
<span>Reply to</span>
|
||||||
|
</template>
|
||||||
|
<template slot="author">
|
||||||
|
<a>Han Solo</a>
|
||||||
|
</template>
|
||||||
|
<template slot="avatar">
|
||||||
|
<a-avatar
|
||||||
|
src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"
|
||||||
|
alt="Han Solo"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<p slot="content">We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure).</p>
|
||||||
|
<a-comment>
|
||||||
|
<template slot="actions">
|
||||||
|
<span>Reply to</span>
|
||||||
|
</template>
|
||||||
|
<template slot="author">
|
||||||
|
<a>Han Solo</a>
|
||||||
|
</template>
|
||||||
|
<template slot="avatar">
|
||||||
|
<a-avatar
|
||||||
|
src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"
|
||||||
|
alt="Han Solo"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<p slot="content">We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure).</p>
|
||||||
|
<a-comment>
|
||||||
|
<template slot="actions">
|
||||||
|
<span>Reply to</span>
|
||||||
|
</template>
|
||||||
|
<template slot="author">
|
||||||
|
<a>Han Solo</a>
|
||||||
|
</template>
|
||||||
|
<template slot="avatar">
|
||||||
|
<a-avatar
|
||||||
|
src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"
|
||||||
|
alt="Han Solo"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<p slot="content">We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure).</p>
|
||||||
|
</a-comment>
|
||||||
|
<a-comment>
|
||||||
|
<template slot="actions">
|
||||||
|
<span>Reply to</span>
|
||||||
|
</template>
|
||||||
|
<template slot="author">
|
||||||
|
<a>Han Solo</a>
|
||||||
|
</template>
|
||||||
|
<template slot="avatar">
|
||||||
|
<a-avatar
|
||||||
|
src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"
|
||||||
|
alt="Han Solo"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<p slot="content">We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure).</p>
|
||||||
|
</a-comment>
|
||||||
|
</a-comment>
|
||||||
|
</a-comment>
|
||||||
|
</template>
|
||||||
|
```
|
|
@ -0,0 +1,10 @@
|
||||||
|
## API
|
||||||
|
|
||||||
|
| Property | Description | Type | Default |
|
||||||
|
| -------- | ----------- | ---- | ------- |
|
||||||
|
| actions | List of action items rendered below the comment content | Array | slot | - |
|
||||||
|
| author | The element to display as the comment author | string\|slot | - |
|
||||||
|
| avatar | The element to display as the comment avatar - generally an antd `Avatar` or src | string\|slot | - |
|
||||||
|
| children | Nested comments should be provided as children of the Comment | slot | - |
|
||||||
|
| content | The main content of the comment | string\|slot | - |
|
||||||
|
| datetime | A datetime element containing the time to be displayed | string\|slot | - |
|
|
@ -0,0 +1,96 @@
|
||||||
|
import PropsTypes from '../_util/vue-types'
|
||||||
|
import { initDefaultProps, getComponentFromProp } from '../_util/props-util'
|
||||||
|
import classNames from 'classnames'
|
||||||
|
|
||||||
|
export const CommentProps = {
|
||||||
|
actions: PropsTypes.array,
|
||||||
|
/** The element to display as the comment author. */
|
||||||
|
author: PropsTypes.any,
|
||||||
|
/** The element to display as the comment avatar - generally an antd Avatar */
|
||||||
|
avatar: PropsTypes.any,
|
||||||
|
/** The main content of the comment */
|
||||||
|
content: PropsTypes.any,
|
||||||
|
/** Comment prefix defaults to '.ant-comment' */
|
||||||
|
prefixCls: PropsTypes.string,
|
||||||
|
/** A datetime element containing the time to be displayed */
|
||||||
|
datetime: PropsTypes.any,
|
||||||
|
}
|
||||||
|
|
||||||
|
const Comment = {
|
||||||
|
name: 'AComment',
|
||||||
|
props: initDefaultProps(CommentProps, {
|
||||||
|
prefixCls: 'ant-comment',
|
||||||
|
}),
|
||||||
|
methods: {
|
||||||
|
getAction (actions) {
|
||||||
|
if (!actions || !actions.length) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
const actionList = actions.map((action, index) => <li key={`action-${index}`}>{action}</li>)
|
||||||
|
return actionList
|
||||||
|
},
|
||||||
|
renderNested (children) {
|
||||||
|
const { prefixCls } = this.$props
|
||||||
|
|
||||||
|
return <div class={classNames(`${prefixCls}-nested`)}>{children}</div>
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const {
|
||||||
|
prefixCls,
|
||||||
|
} = this.$props
|
||||||
|
|
||||||
|
const actions = this.$props.actions || getComponentFromProp(this, 'actions')
|
||||||
|
const author = this.$props.author || getComponentFromProp(this, 'author')
|
||||||
|
const avatar = this.$props.avatar || getComponentFromProp(this, 'avatar')
|
||||||
|
const content = this.$props.content || getComponentFromProp(this, 'content')
|
||||||
|
const datetime = this.$props.datetime || getComponentFromProp(this, 'datetime')
|
||||||
|
|
||||||
|
const avatarDom = (
|
||||||
|
<div class={`${prefixCls}-avatar`}>
|
||||||
|
{typeof avatar === 'string' ? <img src={avatar} /> : avatar}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
|
||||||
|
const actionDom =
|
||||||
|
actions && actions.length ? (
|
||||||
|
<ul class={`${prefixCls}-actions`}>{this.getAction(actions)}</ul>
|
||||||
|
) : null
|
||||||
|
|
||||||
|
const authorContent = (
|
||||||
|
<div class={`${prefixCls}-content-author`}>
|
||||||
|
{author && <span class={`${prefixCls}-content-author-name`}>{author}</span>}
|
||||||
|
{datetime && <span class={`${prefixCls}-content-author-time`}>{datetime}</span>}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
|
||||||
|
const contentDom = (
|
||||||
|
<div class={`${prefixCls}-content`}>
|
||||||
|
{authorContent}
|
||||||
|
<div class={`${prefixCls}-content-detail`}>{content}</div>
|
||||||
|
{actionDom}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
|
||||||
|
const comment = (
|
||||||
|
<div class={`${prefixCls}-inner`}>
|
||||||
|
{avatarDom}
|
||||||
|
{contentDom}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
const children = this.$slots.default
|
||||||
|
return (
|
||||||
|
<div class={classNames(prefixCls)}>
|
||||||
|
{comment}
|
||||||
|
{children ? this.renderNested(children) : null}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
Comment.install = function (Vue) {
|
||||||
|
Vue.component(Comment.name, Comment)
|
||||||
|
}
|
||||||
|
export default Comment
|
|
@ -0,0 +1,10 @@
|
||||||
|
## API
|
||||||
|
|
||||||
|
| Property | Description | Type | Default |
|
||||||
|
| -------- | ----------- | ---- | ------- |
|
||||||
|
| actions | 在评论内容下面呈现的操作项列表 | Array|slot | - |
|
||||||
|
| author | 要显示为注释作者的元素 | string\|slot | - |
|
||||||
|
| avatar | 要显示为评论头像的元素 - 通常是 antd `Avatar` 或者src | string\|slot | - |
|
||||||
|
| children | 嵌套注释应作为注释的子项提供 | slot | - |
|
||||||
|
| content | 评论的主要内容 | string\|slot | - |
|
||||||
|
| datetime | 展示时间描述 | string\|slot | - |
|
|
@ -0,0 +1,2 @@
|
||||||
|
import '../../style/index.less'
|
||||||
|
import './index.less'
|
|
@ -0,0 +1,93 @@
|
||||||
|
@import '../../style/themes/default';
|
||||||
|
@import '../../style/mixins/index';
|
||||||
|
|
||||||
|
@comment-prefix-cls: ~'@{ant-prefix}-comment';
|
||||||
|
|
||||||
|
.@{comment-prefix-cls} {
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
&-inner {
|
||||||
|
padding: @comment-padding-base;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-avatar {
|
||||||
|
flex-shrink: 0;
|
||||||
|
position: relative;
|
||||||
|
margin-right: 12px;
|
||||||
|
cursor: pointer;
|
||||||
|
img {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-content {
|
||||||
|
position: relative;
|
||||||
|
font-size: 14px;
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-width: 1px;
|
||||||
|
word-wrap: break-word;
|
||||||
|
|
||||||
|
&-author {
|
||||||
|
margin-bottom: 4px;
|
||||||
|
font-size: 14px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-start;
|
||||||
|
& > a,
|
||||||
|
& > span {
|
||||||
|
height: 18px;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 18px;
|
||||||
|
padding-right: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-name {
|
||||||
|
transition: color 0.3s;
|
||||||
|
font-size: 14px;
|
||||||
|
color: @comment-author-name-color;
|
||||||
|
> * {
|
||||||
|
color: @comment-author-name-color;
|
||||||
|
&:hover {
|
||||||
|
color: @comment-author-name-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-time {
|
||||||
|
cursor: auto;
|
||||||
|
color: @comment-author-time-color;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-detail p {
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-actions {
|
||||||
|
margin-top: 12px;
|
||||||
|
padding-left: 0;
|
||||||
|
> li {
|
||||||
|
display: inline-block;
|
||||||
|
color: @comment-action-color;
|
||||||
|
> span {
|
||||||
|
padding-right: 10px;
|
||||||
|
transition: color 0.3s;
|
||||||
|
font-size: 12px;
|
||||||
|
color: @comment-action-color;
|
||||||
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
&:hover {
|
||||||
|
color: @comment-action-hover-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-nested {
|
||||||
|
margin-left: @comment-nest-indent;
|
||||||
|
}
|
||||||
|
}
|
|
@ -124,6 +124,8 @@ import { default as Drawer } from './drawer'
|
||||||
|
|
||||||
import { default as Skeleton } from './skeleton'
|
import { default as Skeleton } from './skeleton'
|
||||||
|
|
||||||
|
import { default as Comment } from './comment'
|
||||||
|
|
||||||
const components = [
|
const components = [
|
||||||
Affix,
|
Affix,
|
||||||
Anchor,
|
Anchor,
|
||||||
|
@ -177,6 +179,7 @@ const components = [
|
||||||
Upload,
|
Upload,
|
||||||
Drawer,
|
Drawer,
|
||||||
Skeleton,
|
Skeleton,
|
||||||
|
Comment,
|
||||||
]
|
]
|
||||||
|
|
||||||
const install = function (Vue) {
|
const install = function (Vue) {
|
||||||
|
@ -255,6 +258,7 @@ export {
|
||||||
Upload,
|
Upload,
|
||||||
Drawer,
|
Drawer,
|
||||||
Skeleton,
|
Skeleton,
|
||||||
|
Comment,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
|
@ -51,3 +51,4 @@ import './carousel/style'
|
||||||
import './tree-select/style'
|
import './tree-select/style'
|
||||||
import './drawer/style'
|
import './drawer/style'
|
||||||
import './skeleton/style'
|
import './skeleton/style'
|
||||||
|
import './comment/style'
|
||||||
|
|
|
@ -402,6 +402,15 @@
|
||||||
@card-actions-background: @background-color-light;
|
@card-actions-background: @background-color-light;
|
||||||
@card-shadow: 0 2px 8px rgba(0, 0, 0, .09);
|
@card-shadow: 0 2px 8px rgba(0, 0, 0, .09);
|
||||||
|
|
||||||
|
// Comment
|
||||||
|
// ---
|
||||||
|
@comment-padding-base: 16px 0;
|
||||||
|
@comment-nest-indent: 44px;
|
||||||
|
@comment-author-name-color: @text-color-secondary;
|
||||||
|
@comment-author-time-color: #ccc;
|
||||||
|
@comment-action-color: @text-color-secondary;
|
||||||
|
@comment-action-hover-color: #595959;
|
||||||
|
|
||||||
// Tabs
|
// Tabs
|
||||||
// ---
|
// ---
|
||||||
@tabs-card-head-background: @background-color-light;
|
@tabs-card-head-background: @background-color-light;
|
||||||
|
|
|
@ -56,6 +56,7 @@ import {
|
||||||
// version,
|
// version,
|
||||||
Drawer,
|
Drawer,
|
||||||
Skeleton,
|
Skeleton,
|
||||||
|
Comment,
|
||||||
} from 'ant-design-vue'
|
} from 'ant-design-vue'
|
||||||
|
|
||||||
Vue.prototype.$message = message
|
Vue.prototype.$message = message
|
||||||
|
@ -119,6 +120,7 @@ Vue.use(Timeline)
|
||||||
Vue.use(Tooltip)
|
Vue.use(Tooltip)
|
||||||
Vue.use(Upload)
|
Vue.use(Upload)
|
||||||
Vue.use(Skeleton)
|
Vue.use(Skeleton)
|
||||||
|
Vue.use(Comment)
|
||||||
|
|
||||||
/* v1.1.2 registration methods */
|
/* v1.1.2 registration methods */
|
||||||
// Vue.component(Affix.name, Affix) // a-affix
|
// Vue.component(Affix.name, Affix) // a-affix
|
||||||
|
|
|
@ -11,6 +11,12 @@ export default {
|
||||||
type: 'Data Display',
|
type: 'Data Display',
|
||||||
title: 'Badge',
|
title: 'Badge',
|
||||||
},
|
},
|
||||||
|
comment: {
|
||||||
|
category: 'Components',
|
||||||
|
subtitle: '评论',
|
||||||
|
type: 'Data Display',
|
||||||
|
title: 'Comment',
|
||||||
|
},
|
||||||
breadcrumb: {
|
breadcrumb: {
|
||||||
category: 'Components',
|
category: 'Components',
|
||||||
subtitle: '面包屑',
|
subtitle: '面包屑',
|
||||||
|
|
|
@ -423,4 +423,12 @@ export default [
|
||||||
path: 'skeleton-cn',
|
path: 'skeleton-cn',
|
||||||
component: () => import('../components/skeleton/demo/index.vue'),
|
component: () => import('../components/skeleton/demo/index.vue'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'comment',
|
||||||
|
component: () => import('../components/comment/demo/index.vue'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'comment-cn',
|
||||||
|
component: () => import('../components/comment/demo/index.vue'),
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue