Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
京东前端
nutui-react
提交
a67dee05
N
nutui-react
项目概览
京东前端
/
nutui-react
通知
0
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
nutui-react
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a67dee05
编写于
3月 08, 2023
作者:
H
hanyuxinting
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: rate组件适配icons
上级
018744eb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
54 addition
and
42 deletion
+54
-42
src/packages/rate/demo.tsx
src/packages/rate/demo.tsx
+1
-1
src/packages/rate/rate.scss
src/packages/rate/rate.scss
+12
-1
src/packages/rate/rate.tsx
src/packages/rate/rate.tsx
+41
-40
未找到文件。
src/packages/rate/demo.tsx
浏览文件 @
a67dee05
...
...
@@ -52,8 +52,8 @@ const RateDemo = () => {
<
Cell
>
<
Rate
modelValue
=
{
3
}
/>
</
Cell
>
<
h2
>
{
translated
.
halfStar
}
</
h2
>
<
h2
>
{
translated
.
halfStar
}
</
h2
>
<
Cell
>
<
Rate
allowHalf
modelValue
=
"3.5"
/>
</
Cell
>
...
...
src/packages/rate/rate.scss
浏览文件 @
a67dee05
...
...
@@ -2,21 +2,32 @@
.nut-rate
{
display
:
flex
;
&
-item
{
display
:
flex
;
flex-shrink
:
0
;
position
:
relative
;
&
__half
{
position
:
absolute
;
height
:
100%
;
width
:
50%
!
important
;
left
:
0
;
top
:
0
;
overflow
:
hidden
;
}
&
__icon
{
color
:
$rate-icon-color
;
cursor
:
pointer
;
&
--disabled
{
color
:
$rate-icon-void-color
;
}
&
.nut-rate-item__icon.nut-rate-item__icon--half
{
position
:
absolute
;
width
:
50%
!
important
;
//
width: 50% !important;
left
:
0
;
top
:
0
;
overflow
:
hidden
;
...
...
src/packages/rate/rate.tsx
浏览文件 @
a67dee05
import
React
,
{
FunctionComponent
,
useEffect
,
useState
}
from
'
react
'
import
classNames
from
'
classnames
'
import
{
StarFillN
}
from
'
@nutui/icons-react
'
import
bem
from
'
@/utils/bem
'
import
Icon
from
'
@/packages/icon
'
import
{
BasicComponent
,
ComponentDefaults
}
from
'
@/utils/typings
'
...
...
@@ -12,8 +12,7 @@ export interface RateProps extends BasicComponent {
iconSize
:
string
|
number
activeColor
:
string
voidColor
:
string
checkedIcon
:
string
uncheckedIcon
:
string
checkedIcon
:
React
.
ReactNode
disabled
:
boolean
readonly
:
boolean
allowHalf
:
boolean
...
...
@@ -29,8 +28,7 @@ const defaultProps = {
iconSize
:
18
,
activeColor
:
''
,
voidColor
:
''
,
checkedIcon
:
'
star-fill-n
'
,
uncheckedIcon
:
'
star-n
'
,
checkedIcon
:
null
,
disabled
:
false
,
readonly
:
false
,
allowHalf
:
false
,
...
...
@@ -47,14 +45,11 @@ export const Rate: FunctionComponent<Partial<RateProps>> = (props) => {
activeColor
,
voidColor
,
checkedIcon
,
uncheckedIcon
,
disabled
,
readonly
,
allowHalf
,
spacing
,
onChange
,
iconClassPrefix
,
iconFontClassName
,
}
=
{
...
defaultProps
,
...
props
,
...
...
@@ -109,38 +104,44 @@ export const Rate: FunctionComponent<Partial<RateProps>> = (props) => {
onClick
=
{
(
event
)
=>
onClick
(
event
,
n
)
}
style
=
{
{
marginRight
:
pxCheck
(
spacing
)
}
}
>
<
Icon
classPrefix
=
{
iconClassPrefix
}
fontClassName
=
{
iconFontClassName
}
size
=
{
iconSize
}
className
=
{
classNames
(
bi
(
'
icon
'
),
{
[
bi
(
'
icon--disabled
'
)]:
disabled
||
n
>
score
,
})
}
name
=
{
n
<=
score
?
checkedIcon
:
uncheckedIcon
}
color
=
{
n
<=
score
?
activeColor
:
voidColor
}
/>
{
allowHalf
&&
score
>
n
-
1
&&
(
<
Icon
classPrefix
=
{
iconClassPrefix
}
fontClassName
=
{
iconFontClassName
}
className
=
{
`
${
bi
(
'
icon
'
)}
${
bi
(
'
icon--half
'
)}
`
}
color
=
{
n
<=
score
?
activeColor
:
voidColor
}
size
=
{
iconSize
}
name
=
{
checkedIcon
}
/>
)
}
{
allowHalf
&&
score
<
n
-
1
&&
(
<
Icon
classPrefix
=
{
iconClassPrefix
}
fontClassName
=
{
iconFontClassName
}
className
=
{
`
${
bi
(
'
icon
'
)}
${
bi
(
'
icon--disabled
'
)}
${
bi
(
'
icon--half
'
)}
`
}
color
=
{
voidColor
}
size
=
{
iconSize
}
name
=
{
uncheckedIcon
}
/>
)
}
<>
{
checkedIcon
||
(
<
StarFillN
width
=
{
iconSize
}
height
=
{
iconSize
}
color
=
{
n
<=
score
?
activeColor
:
voidColor
}
className
=
{
classNames
(
bi
(
'
icon
'
),
{
[
bi
(
'
icon--disabled
'
)]:
disabled
||
n
>
score
,
})
}
/>
)
}
{
(
allowHalf
&&
score
>
n
-
1
&&
(
<
div
className
=
{
`
${
bi
(
'
half
'
)}
`
}
>
{
checkedIcon
||
(
<
StarFillN
width
=
{
iconSize
}
height
=
{
iconSize
}
color
=
{
n
<=
score
?
activeColor
:
voidColor
}
className
=
{
`
${
bi
(
'
icon
'
)}
${
bi
(
'
icon--half
'
)}
`
}
/>
)
}
</
div
>
))
||
(
allowHalf
&&
score
<
n
-
1
&&
(
<
div
>
{
checkedIcon
||
(
<
StarFillN
width
=
{
iconSize
}
height
=
{
iconSize
}
color
=
{
voidColor
}
className
=
{
`
${
bi
(
'
icon
'
)}
${
bi
(
'
icon--disabled
'
)}
${
bi
(
'
icon--half
'
)}
`
}
/>
)
}
</
div
>
))
}
</>
</
div
>
)
})
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录