Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wanjj_1210
ant-design
提交
192e188f
A
ant-design
项目概览
wanjj_1210
/
ant-design
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
ant-design
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
192e188f
编写于
12月 28, 2018
作者:
Z
zombiej
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rate support 'tooltips'
close #13973
上级
990ab883
变更
9
展开全部
隐藏空白更改
内联
并排
Showing
9 changed file
with
2224 addition
and
2002 deletion
+2224
-2002
components/config-provider/__tests__/__snapshots__/index.test.js.snap
...onfig-provider/__tests__/__snapshots__/index.test.js.snap
+653
-608
components/form/__tests__/__snapshots__/demo.test.js.snap
components/form/__tests__/__snapshots__/demo.test.js.snap
+215
-200
components/rate/__tests__/__snapshots__/demo.test.js.snap
components/rate/__tests__/__snapshots__/demo.test.js.snap
+1312
-1177
components/rate/demo/text.md
components/rate/demo/text.md
+4
-2
components/rate/index.en-US.md
components/rate/index.en-US.md
+1
-0
components/rate/index.tsx
components/rate/index.tsx
+28
-7
components/rate/index.zh-CN.md
components/rate/index.zh-CN.md
+1
-0
components/rate/style/index.less
components/rate/style/index.less
+9
-7
package.json
package.json
+1
-1
未找到文件。
components/config-provider/__tests__/__snapshots__/index.test.js.snap
浏览文件 @
192e188f
此差异已折叠。
点击以展开。
components/form/__tests__/__snapshots__/demo.test.js.snap
浏览文件 @
192e188f
此差异已折叠。
点击以展开。
components/rate/__tests__/__snapshots__/demo.test.js.snap
浏览文件 @
192e188f
此差异已折叠。
点击以展开。
components/rate/demo/text.md
浏览文件 @
192e188f
...
...
@@ -16,6 +16,8 @@ Add copywriting in rate components.
````
jsx
import
{
Rate
}
from
'
antd
'
;
const
desc
=
[
'
terrible
'
,
'
bad
'
,
'
normal
'
,
'
good
'
,
'
wonderful
'
];
class
Rater
extends
React
.
Component
{
state
=
{
value
:
3
,
...
...
@@ -29,8 +31,8 @@ class Rater extends React.Component {
const
{
value
}
=
this
.
state
;
return
(
<
span
>
<
Rate
onChange
=
{
this
.
handleChange
}
value
=
{
value
}
/>
{
value
&&
<
span
className
=
"ant-rate-text"
>
{
value
}
stars
</
span
>
}
<
Rate
tooltips
=
{
desc
}
onChange
=
{
this
.
handleChange
}
value
=
{
value
}
/>
{
value
?
<
span
className
=
"ant-rate-text"
>
{
desc
[
value
-
1
]
}
</
span
>
:
''
}
</
span
>
);
}
...
...
components/rate/index.en-US.md
浏览文件 @
192e188f
...
...
@@ -24,6 +24,7 @@ Rate component.
| defaultValue | default value | number | 0 |
| disabled | read only, unable to interact | boolean | false |
| style | custom style object of rate | object | - |
| tooltips | Customize tooltip by each character | string
\[
] | - |
| value | current value | number | - |
| onBlur | callback when component lose focus | Function() | - |
| onChange | callback when select value | Function(value: number) | - |
...
...
components/rate/index.tsx
浏览文件 @
192e188f
import
*
as
React
from
'
react
'
;
import
*
as
PropTypes
from
'
prop-types
'
;
import
RcRate
from
'
rc-rate
'
;
import
omit
from
'
omit.js
'
;
import
Icon
from
'
../icon
'
;
import
Tooltip
from
'
../tooltip
'
;
import
{
ConfigConsumer
,
ConfigConsumerProps
}
from
'
../config-provider
'
;
export
interface
RateProps
{
...
...
@@ -12,6 +14,7 @@ export interface RateProps {
allowHalf
?:
boolean
;
allowClear
?:
boolean
;
disabled
?:
boolean
;
tooltips
?:
Array
<
string
>
;
onChange
?:
(
value
:
number
)
=>
any
;
onHoverChange
?:
(
value
:
number
)
=>
any
;
character
?:
React
.
ReactNode
;
...
...
@@ -19,6 +22,10 @@ export interface RateProps {
style
?:
React
.
CSSProperties
;
}
interface
RateNodeProps
{
index
:
number
;
}
export
default
class
Rate
extends
React
.
Component
<
RateProps
,
any
>
{
static
propTypes
=
{
prefixCls
:
PropTypes
.
string
,
...
...
@@ -43,13 +50,27 @@ export default class Rate extends React.Component<RateProps, any> {
this
.
rcRate
=
node
;
};
renderRate
=
({
getPrefixCls
}:
ConfigConsumerProps
)
=>
(
<
RcRate
ref
=
{
this
.
saveRate
}
{
...
this
.
props
}
prefixCls
=
{
getPrefixCls
(
'
rate
'
,
this
.
props
.
prefixCls
)
}
/>
);
characterRender
=
(
node
:
React
.
ReactNode
,
{
index
}:
RateNodeProps
)
=>
{
const
{
tooltips
}
=
this
.
props
;
if
(
!
tooltips
)
return
node
;
return
<
Tooltip
title
=
{
tooltips
[
index
]
}
>
{
node
}
</
Tooltip
>;
};
renderRate
=
({
getPrefixCls
}:
ConfigConsumerProps
)
=>
{
const
{
prefixCls
,
...
restProps
}
=
this
.
props
;
const
rateProps
=
omit
(
restProps
,
[
'
tooltips
'
]);
return
(
<
RcRate
ref
=
{
this
.
saveRate
}
characterRender
=
{
this
.
characterRender
}
{
...
rateProps
}
prefixCls
=
{
getPrefixCls
(
'
rate
'
,
prefixCls
)
}
/>
);
};
render
()
{
return
<
ConfigConsumer
>
{
this
.
renderRate
}
</
ConfigConsumer
>;
...
...
components/rate/index.zh-CN.md
浏览文件 @
192e188f
...
...
@@ -25,6 +25,7 @@ title: Rate
| defaultValue | 默认值 | number | 0 |
| disabled | 只读,无法进行交互 | boolean | false |
| style | 自定义样式对象 | object | - |
| tooltips | 自定义每项的提示信息 | string
\[
] | - |
| value | 当前数,受控值 | number | - |
| onBlur | 失去焦点时的回调 | Function() | - |
| onChange | 选择时的回调 | Function(value: number) | - |
...
...
components/rate/style/index.less
浏览文件 @
192e188f
...
...
@@ -31,8 +31,15 @@
color: inherit;
cursor: pointer;
&:focus {
outline: 0;
> div {
&:focus {
outline: 0;
}
&:hover,
&:focus {
transform: scale(1.1);
}
}
&-first,
...
...
@@ -45,11 +52,6 @@
}
}
&:hover,
&:focus {
transform: scale(1.1);
}
&-first {
position: absolute;
left: 0;
...
...
package.json
浏览文件 @
192e188f
...
...
@@ -69,7 +69,7 @@
"
rc-notification
"
:
"
~3.3.0
"
,
"
rc-pagination
"
:
"
~1.17.7
"
,
"
rc-progress
"
:
"
~2.2.6
"
,
"
rc-rate
"
:
"
~2.
4.2
"
,
"
rc-rate
"
:
"
~2.
5.0
"
,
"
rc-select
"
:
"
^8.6.7
"
,
"
rc-slider
"
:
"
~8.6.3
"
,
"
rc-steps
"
:
"
~3.3.0
"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录