diff --git a/README.md b/README.md index 066af61..5c41104 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,7 @@ ReactDOM.render( | character | ReactNode \| (props) => ReactNode | ★ | The each character of rate | | disabled | boolean | false | | | direction | string | `ltr` | The direction of rate | +| starsSpacing | string | 0 | defines the spacing between stars | ## Test Case diff --git a/assets/index.less b/assets/index.less index 62ca71c..cabaec4 100644 --- a/assets/index.less +++ b/assets/index.less @@ -45,6 +45,10 @@ float: right; } + &:last-child { + margin-right: 0; + } + &-first, &-second { transition: all .3s; diff --git a/docs/examples/characterRender.tsx b/docs/examples/characterRender.tsx index bd02561..ab732ca 100644 --- a/docs/examples/characterRender.tsx +++ b/docs/examples/characterRender.tsx @@ -9,6 +9,7 @@ export default () => (
( {node} diff --git a/src/Rate.tsx b/src/Rate.tsx index c2492ae..df14846 100644 --- a/src/Rate.tsx +++ b/src/Rate.tsx @@ -13,6 +13,7 @@ export interface RateProps extends Pick void; onHoverChange?: (value: number) => void; @@ -39,6 +40,7 @@ class Rate extends React.Component { allowHalf: false, allowClear: true, style: {}, + starsStyle: {}, prefixCls: 'rc-rate', onChange: noop, character: '★', @@ -249,6 +251,7 @@ class Rate extends React.Component { characterRender, tabIndex, direction, + starsSpacing, } = this.props; const { value, hoverValue, focused } = this.state; const stars = []; @@ -266,6 +269,7 @@ class Rate extends React.Component { onClick={this.onClick} onHover={this.onHover} key={index} + spacing={starsSpacing} character={character} characterRender={characterRender} focused={focused} diff --git a/src/Star.tsx b/src/Star.tsx index df61d3e..b0ff785 100644 --- a/src/Star.tsx +++ b/src/Star.tsx @@ -3,6 +3,7 @@ import React from 'react'; export interface StarProps { value?: number; index?: number; + spacing?: string; prefixCls?: string; allowHalf?: boolean; disabled?: boolean; @@ -57,10 +58,10 @@ export default class Star extends React.Component { render() { const { onHover, onClick, onKeyDown } = this; - const { disabled, prefixCls, character, characterRender, index, count, value } = this.props; + const { disabled, prefixCls, character, characterRender, index, count, spacing, value } = this.props; const characterNode = typeof character === 'function' ? character(this.props) : character; let start: React.ReactNode = ( -
  • +