From 1218c69a375ec4195acdd80a3427dadb6d100d72 Mon Sep 17 00:00:00 2001 From: Karol Rzotki Date: Mon, 29 Jul 2024 14:57:40 +0200 Subject: [PATCH] revert rating changes --- src/components/rating/Rating.stories.mdx | 30 ------------------------ src/components/rating/Rating.tsx | 20 ++++++++-------- 2 files changed, 10 insertions(+), 40 deletions(-) diff --git a/src/components/rating/Rating.stories.mdx b/src/components/rating/Rating.stories.mdx index 8eeb04ec1..a2ece89f5 100644 --- a/src/components/rating/Rating.stories.mdx +++ b/src/components/rating/Rating.stories.mdx @@ -13,49 +13,19 @@ import RatingA11y from './stories/Rating.a11y.mdx'; size: { table: {defaultValue: {summary: RATING_SIZE.XS}}, }, - rate: { - table: { - defaultValue: { - summary: 0, - }, - }, - }, - metricSize: { - table: { - defaultValue: { - summary: 5, - }, - }, - }, - 'aria-label': { - table: { - defaultValue: { - summary: 'current rate', - }, - }, - }, onMouseLeave: { table: { category: 'Events', - defaultValue: { - summary: '() => undefined', - }, }, }, onStarMouseEnter: { table: { category: 'Events', - defaultValue: { - summary: '() => undefined', - }, }, }, onChange: { table: { category: 'Events', - defaultValue: { - summary: '() => undefined', - }, }, }, }} diff --git a/src/components/rating/Rating.tsx b/src/components/rating/Rating.tsx index a7c36e730..b780b53b8 100644 --- a/src/components/rating/Rating.tsx +++ b/src/components/rating/Rating.tsx @@ -60,17 +60,17 @@ export type RatingPropsType = { /* eslint-disable react/default-props-match-prop-types */ // legacy files without proper flow checks can suffer from this -const defaultProps: RatingPropsType = { - onChange: () => undefined, - onStarMouseEnter: () => undefined, - onMouseLeave: () => undefined, - metricSize: 5, - rate: 0, - 'aria-label': 'current rate', -}; - class Rating extends React.Component { - constructor(props = defaultProps) { + static defaultProps = { + onChange: () => undefined, + onStarMouseEnter: () => undefined, + onMouseLeave: () => undefined, + metricSize: 5, + rate: 0, + 'aria-label': 'current rate', + }; + + constructor(props: RatingPropsType) { super(props); this.createStarsOnChangeFunctions(this.props.metricSize); this.createStarsMouseEnterFunctions(this.props.metricSize);