mirror of
https://github.com/Nezumi-2711/react-training.git
synced 2026-09-22 13:38:51 +00:00
Update code sample
This commit is contained in:
@@ -25,7 +25,6 @@ export const Secondary: Story = {
|
|||||||
args: {
|
args: {
|
||||||
size: 50,
|
size: 50,
|
||||||
maxRating: 5,
|
maxRating: 5,
|
||||||
color: "beach",
|
|
||||||
defaultRating: 5,
|
defaultRating: 5,
|
||||||
messages: ["Worst", "Worse", "Normal", "Good", "Best"],
|
messages: ["Worst", "Worse", "Normal", "Good", "Best"],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,11 +11,25 @@ const starContainerStyle = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
interface IStarRating {
|
interface IStarRating {
|
||||||
|
/**
|
||||||
|
* The max of star for rating
|
||||||
|
*/
|
||||||
maxRating?: number;
|
maxRating?: number;
|
||||||
|
/**
|
||||||
|
* The color of star
|
||||||
|
*/
|
||||||
color?: string;
|
color?: string;
|
||||||
|
/**
|
||||||
|
* The size of star
|
||||||
|
*/
|
||||||
size?: number;
|
size?: number;
|
||||||
className?: string;
|
/**
|
||||||
|
* The array of message for each star (The length of array must equal with amount of star)
|
||||||
|
*/
|
||||||
messages?: string[];
|
messages?: string[];
|
||||||
|
/**
|
||||||
|
* The default rating
|
||||||
|
*/
|
||||||
defaultRating?: number;
|
defaultRating?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,7 +37,6 @@ export const StarRating = ({
|
|||||||
maxRating = 5,
|
maxRating = 5,
|
||||||
color = "#fcc419",
|
color = "#fcc419",
|
||||||
size = 48,
|
size = 48,
|
||||||
className = "",
|
|
||||||
messages = [],
|
messages = [],
|
||||||
defaultRating = 0,
|
defaultRating = 0,
|
||||||
}: IStarRating) => {
|
}: IStarRating) => {
|
||||||
@@ -42,7 +55,7 @@ export const StarRating = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={containerStyle} className={className}>
|
<div style={containerStyle}>
|
||||||
<div style={starContainerStyle}>
|
<div style={starContainerStyle}>
|
||||||
{Array.from({ length: maxRating }, (_, i) => (
|
{Array.from({ length: maxRating }, (_, i) => (
|
||||||
<span key={i}>
|
<span key={i}>
|
||||||
|
|||||||
Reference in New Issue
Block a user