Update code sample

This commit is contained in:
2023-10-13 17:07:58 +07:00
parent 272c64463a
commit 53c6727f2b
2 changed files with 16 additions and 4 deletions
@@ -25,7 +25,6 @@ export const Secondary: Story = {
args: {
size: 50,
maxRating: 5,
color: "beach",
defaultRating: 5,
messages: ["Worst", "Worse", "Normal", "Good", "Best"],
},
+16 -3
View File
@@ -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 (
<div style={containerStyle} className={className}>
<div style={containerStyle}>
<div style={starContainerStyle}>
{Array.from({ length: maxRating }, (_, i) => (
<span key={i}>