react-feather#Star TypeScript Examples
The following examples show how to use
react-feather#Star.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: rating.tsx From samuelkraft-next with MIT License | 6 votes |
Rating = ({ value, max = 5 }: RatingProps) => {
/* Calculate how much of the stars should be "filled" */
const percentage = Math.round((value / max) * 100)
return (
<div className={styles.container}>
{/* Create an array based on the max rating, render a star for each */}
{Array.from(Array(max).keys()).map((_, i) => (
<Star key={String(i)} className={styles.star} />
))}
{/* Render a div overlayed on top of the stars that are not filled */}
<div className={styles.overlay} style={{ width: `${100 - percentage}%` }} />
</div>
)
}
Example #2
Source File: repo.tsx From samuelkraft-next with MIT License | 6 votes |
Repo = ({ id, html_url: htmlUrl, name, description, stargazers_count: stargazersCount, forks_count: forksCount }: RepoProps) => {
return (
<a href={htmlUrl} key={id} className={styles.repo}>
<header className={styles.header}>
<h3 className={styles.title}>{name}</h3>
<div className={styles.stats}>
<p className={styles.stat}>
<Star />
{stargazersCount}
</p>
<span className={styles.separator}>·</span>
<p className={styles.stat}>
<GitBranch />
{forksCount}
</p>
</div>
</header>
<p className={styles.description}>{description}</p>
</a>
)
}
Example #3
Source File: rating.tsx From samuelkraft-next with MIT License | 5 votes |
Rating = ({ rating }: { rating: number }): JSX.Element => ( <div className={styles.rating}> {Array.from(Array(MAX_RATING).keys()).map((_, i) => ( <Star className={i < rating ? styles.filledStar : styles.star} key={String(i)} /> ))} </div> )