From 53c6727f2b5ce9bc693e2b7c2e9e8b1aad163faf Mon Sep 17 00:00:00 2001 From: Loi Phan Date: Fri, 13 Oct 2023 17:07:58 +0700 Subject: [PATCH] Update code sample --- .../src/stories/StarRating.stories.ts | 1 - sample/story-book/src/stories/StarRating.tsx | 19 ++++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/sample/story-book/src/stories/StarRating.stories.ts b/sample/story-book/src/stories/StarRating.stories.ts index 3aa6922..38d811f 100644 --- a/sample/story-book/src/stories/StarRating.stories.ts +++ b/sample/story-book/src/stories/StarRating.stories.ts @@ -25,7 +25,6 @@ export const Secondary: Story = { args: { size: 50, maxRating: 5, - color: "beach", defaultRating: 5, messages: ["Worst", "Worse", "Normal", "Good", "Best"], }, diff --git a/sample/story-book/src/stories/StarRating.tsx b/sample/story-book/src/stories/StarRating.tsx index bf241a4..9d52637 100644 --- a/sample/story-book/src/stories/StarRating.tsx +++ b/sample/story-book/src/stories/StarRating.tsx @@ -11,11 +11,25 @@ const starContainerStyle = { }; interface IStarRating { + /** + * The max of star for rating + */ maxRating?: number; + /** + * The color of star + */ color?: string; + /** + * The size of star + */ size?: number; - className?: string; + /** + * The array of message for each star (The length of array must equal with amount of star) + */ messages?: string[]; + /** + * The default rating + */ defaultRating?: number; } @@ -23,7 +37,6 @@ export const StarRating = ({ maxRating = 5, color = "#fcc419", size = 48, - className = "", messages = [], defaultRating = 0, }: IStarRating) => { @@ -42,7 +55,7 @@ export const StarRating = ({ }; return ( -
+
{Array.from({ length: maxRating }, (_, i) => (