Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(comp:rate): add color prop for rate #1420

Merged
merged 2 commits into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/components/rate/docs/Api.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
| `disabled` | 禁用状态 | `boolean` | `false` | - | 使用 `control` 时,此配置无效 |
| `icon` | 自定义图标 | `string \| #icon={disabled, focused, index}` | `'star-filled'` | ✅ | - |
| `size` | 设置大小 | `'sm' \| 'md' \| 'lg'` | `'md'` | ✅ | - |
| `color` | 高亮图标的颜色 | `string` | undefined | - | - |
| `tooltips` | 悬浮提示信息数组 | `string[]` | `[]` | - | - |
| `onChange` | 值发生改变时的回调 | `(value: number) => void` | - | - | - |
3 changes: 2 additions & 1 deletion packages/components/rate/src/Rate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export default defineComponent({
const itemValue = convertNumber(hoverValue.value ?? accessor.value)
const itemPrefixCls = `${mergedPrefixCls.value}-item`

const { tooltips } = props
const { tooltips, color } = props
const children = []
for (let index = 0; index < count; index++) {
children.push(
Expand All @@ -137,6 +137,7 @@ export default defineComponent({
index={index}
prefixCls={itemPrefixCls}
tooltip={tooltips[index]}
color={color}
value={itemValue}
onClick={handleItemClick}
onMouseMove={handleItemMouseMove}
Expand Down
4 changes: 2 additions & 2 deletions packages/components/rate/src/RateItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ export default defineComponent({
})

return () => {
const { count, disabled, index, prefixCls, tooltip, value } = props
const { count, disabled, index, prefixCls, tooltip, value, color } = props

const iconNode = slots.default!()
const itemNode = (
<li ref={liRef} class={classes.value}>
<li ref={liRef} class={classes.value} style={`color: ${color}`}>
<span
aria-checked={value > index}
aria-posinset={index + 1}
Expand Down
5 changes: 5 additions & 0 deletions packages/components/rate/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export const rateProps = {
default: (): string[] => [],
},
size: String as PropType<FormSize>,
color: {
type: String,
default: undefined,
},

// events
'onUpdate:value': [Function, Array] as PropType<MaybeArray<(value: number) => void>>,
Expand Down Expand Up @@ -75,6 +79,7 @@ export const rateItemProps = {
type: Number,
required: true,
},
color: String,

// events
onClick: {
Expand Down