Skip to content

Commit

Permalink
feat(API): Remove RatingControl iconNode props
Browse files Browse the repository at this point in the history
  • Loading branch information
myxvisual committed Jun 20, 2017
1 parent cf36477 commit b76472d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
8 changes: 1 addition & 7 deletions src/RatingControl/index.doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@
"isRequired": false,
"type": "string"
},
{
"name": "iconNode",
"documentation": "Control show custom `React.ReactNode`.",
"isRequired": false,
"type": "ReactNode"
},
{
"name": "iconStyle",
"documentation": "Control custom `Icon Style`.",
Expand Down Expand Up @@ -181,7 +175,7 @@
},
{
"name": "renderRatings",
"initializerText": " (notRated = true) => {\n const { maxRating, iconNode, icon, iconStyle, iconRatedStyle, isReadOnly, iconPadding } = this.props;\n const { currRating } = this.state;\n const { theme } = this.context;\n const ratio = currRating / maxRating;\n const fontSize = iconStyle ? (+Number(iconStyle.fontSize) || 24) : 24;\n const width = fontSize * maxRating + iconPadding * (maxRating - 1);\n const offset = Math.floor(currRating) * (fontSize + iconPadding) + (currRating % 1) * fontSize;\n const lastIndex = maxRating - 1;\n\n const normalRatings = (\n <div\n style={{\n ...this.styles.ratingsGroup,\n ...(notRated ? void 0 : {\n clipPath: `polygon(0% 0%, ${offset}px 0%, ${offset}px 100%, 0% 100%)`,\n color: theme.accent,\n position: \"absolute\",\n top: 0,\n left: 0\n } as React.CSSProperties)\n }}\n >\n {Array(maxRating).fill(0).map((zero, index) => (\n iconNode || (\n <Icon\n key={`${index}`}\n style={{\n fontSize: 24,\n paddingRight: index === lastIndex ? 0 : iconPadding,\n ...iconStyle,\n ...(notRated ? void 0 : iconRatedStyle)\n }}\n onClick={isReadOnly ? void 0 : e => {\n this.handleRationClick(e, index);\n }}\n >\n {icon}\n </Icon>\n )\n ))}\n </div>\n );\n return normalRatings;\n }",
"initializerText": " (notRated = true) => {\n const { maxRating, icon, iconStyle, iconRatedStyle, isReadOnly, iconPadding } = this.props;\n const { currRating } = this.state;\n const { theme } = this.context;\n const ratio = currRating / maxRating;\n const fontSize = iconStyle ? (+Number(iconStyle.fontSize) || 24) : 24;\n const width = fontSize * maxRating + iconPadding * (maxRating - 1);\n const offset = Math.floor(currRating) * (fontSize + iconPadding) + (currRating % 1) * fontSize;\n const lastIndex = maxRating - 1;\n\n const normalRatings = (\n <div\n style={{\n ...this.styles.ratingsGroup,\n ...(notRated ? void 0 : {\n clipPath: `polygon(0% 0%, ${offset}px 0%, ${offset}px 100%, 0% 100%)`,\n color: theme.accent,\n position: \"absolute\",\n top: 0,\n left: 0\n } as React.CSSProperties)\n }}\n >\n {Array(maxRating).fill(0).map((zero, index) => (\n <Icon\n key={`${index}`}\n style={{\n fontSize: 24,\n paddingRight: index === lastIndex ? 0 : iconPadding,\n ...iconStyle,\n ...(notRated ? void 0 : iconRatedStyle)\n }}\n onClick={isReadOnly ? void 0 : e => {\n this.handleRationClick(e, index);\n }}\n >\n {icon}\n </Icon>\n ))}\n </div>\n );\n return normalRatings;\n }",
"documentation": "",
"type": "(notRated?: boolean) => Element"
},
Expand Down
11 changes: 2 additions & 9 deletions src/RatingControl/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ export interface DataProps {
* Control show custom `Icon`.
*/
icon?: string;
/**
* Control show custom `React.ReactNode`.
*/
iconNode?: React.ReactNode;
/**
* Control custom `Icon Style`.
*/
Expand Down Expand Up @@ -91,7 +87,7 @@ export class RatingControl extends React.Component<RatingControlProps, RatingCon
}

renderRatings = (notRated = true) => {
const { maxRating, iconNode, icon, iconStyle, iconRatedStyle, isReadOnly, iconPadding } = this.props;
const { maxRating, icon, iconStyle, iconRatedStyle, isReadOnly, iconPadding } = this.props;
const { currRating } = this.state;
const { theme } = this.context;
const ratio = currRating / maxRating;
Expand All @@ -114,8 +110,7 @@ export class RatingControl extends React.Component<RatingControlProps, RatingCon
}}
>
{Array(maxRating).fill(0).map((zero, index) => (
iconNode || (
<Icon
<Icon
key={`${index}`}
style={{
fontSize: 24,
Expand All @@ -129,7 +124,6 @@ export class RatingControl extends React.Component<RatingControlProps, RatingCon
>
{icon}
</Icon>
)
))}
</div>
);
Expand All @@ -141,7 +135,6 @@ export class RatingControl extends React.Component<RatingControlProps, RatingCon
defaultRating,
maxRating,
icon,
iconNode,
iconStyle,
iconRatedStyle,
onChangeRating,
Expand Down

0 comments on commit b76472d

Please sign in to comment.