
Security News
/Research
Popular node-ipc npm Package Infected with Credential Stealer
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.
@astro-bryceguy/rating
Advanced tools
Astro component that uses star icons to display the rating of a product, post, comment, etc.
This component is old and deprecated, you can find a better version of this component here: astro-headless-ui
A component that uses stars to display a rating for reviews, products, comments, etc
inline, flip, and heartsicon, active, half, inactive props to the theme propInstall:
npm i @astro-bryceguy/rating
Add to astro config:
export default defineConfig({
vite: {
ssr: {
external: ["svgo"],
},
},
});
Built in tailwindcss themes:
If your using a built in theme that uses tailwind, add the package to your tailwindcss config so it picks up the classes
{
content: ['./node_modules/@astro-bryceguy/**/*.js']
}
Define default icon svgs:
If these icons are not added the default style of the icon will load in as a black box and there will be console errors
Download the icons folder above and put inside your projects src folder if using the default icons
The default icon names are star-active, star-half, and star-inactive take advantage of the local icons feature in astro-icon to serve a local icon svg by default
src/
icons/
star-active.svg
star-half.svg
star-inactive.svg
components
layouts
pages
Read more about how icons work using astro-icon
Default Styling:
<Rating max="5" rate="2.5"/>
Use astro-icons to customize the icons
//Using tailwindcss classes to style
<Rating
rate="4.5"
max="9"
theme={
container: {
style: "display:flex;align-items:center;color:#F9A8D4;"
},
icon: {
style: "height:1rem;width:1rem;"
},
active: {
name: "line-md:heart-filled"
},
half: {
name: "line-md:heart-filled-half"
},
inactive: {
name: "line-md:heart"
}
}
/>
<container>
<slot name="before-active"/>
{ active stars }
<slot name="before-half"/>
{ half star }
<slot name="before-inactive"/>
{ inactive stars }
<slot />
</container>
maxType: string | number
Default: 5
Max number of stars to display
rateType: string | number
Default: 0
A number less than max, represents number of activated stars
themeType: string | object
Themes: inline, flip, hearts
Theme objects allow you to customize your elements with astro-json-element props and attributes
interface Theme = {
container?: {};
icon?: {};
active?: {};
half?: {};
inactive?: {};
}
containerType: astro-json-element
Define what attributes/props the rating container will have
iconDefine what attribute all icons will have, Overwritten by theme props active, half, inactive
activeType: astro-icon
Attributes/props to apply to all active star icons, overwrites icon attrs
halfType: astro-icon
Attributes/props to apply to all half star icons, overwrites icon attrs
inactiveType: astro-icon
Attributes/props to apply to all inactive star icons, overwrites icon attrs
...attrsAll other props will be spread to the ratings container
<Rating
rate="3"
max="5"
theme={{
container: {
class: "flex items-center py-2 px-3 rounded-md bg-neutral-50 border border-blue-300"
},
icon: {
class: "text-blue-300 w-4 h-4"
},
active: {
name: "mdi:star"
},
half: {
name: "mdi:star-half-full"
},
inactive: {
name: "mdi:star-outline"
}
}}
/>
<div class="flex flex-col items-end gap-1 py-1 px-2 bg-neutral-50">
<Rating
rate="7.5"
max="10"
theme={{
container: {
class: "flex flex-row-reverse items-center"
},
icon: {
class: "text-yellow-300 w-4 h-4"
},
half: {
style: "transform:scale(-1, 1);"
}
}}
/>
<span class="leading-none text-xs text-blue-300">873</span>
</div>
<div class="flex flex-row-reverse items-center gap-1 py-1 px-2 rounded-md border">
<Rating
rate="2.5"
max="5"
theme={{
container: {
class: "flex items-center"
},
icon: {
class: "text-yellow-300 w-4 h-4",
},
active: {
name: "mdi:star"
},
half: {
name: "mdi:star-half-full"
},
inactive: {
name: "mdi:star-outline"
}
}}
/>
<span class="leading-none text-xs text-blue-300">(72)</span>
</div>
<div class="flex flex-col items-center py-1 px-2 rounded-md border border-pink-300 text-pink-300">
<span class="mb-1 leading-none text-sm">Healthy!</span>
<Rating
rate="2.5"
max="3"
theme="hearts"
/>
</div>
FAQs
Astro component that uses star icons to display the rating of a product, post, comment, etc.
We found that @astro-bryceguy/rating demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
/Research
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.

Security News
TeamPCP and BreachForums are promoting a Shai-Hulud supply chain attack contest with a $1,000 prize for the biggest package compromise.

Security News
Packagist urges PHP projects to update Composer after a GitHub token format change exposed some GitHub Actions tokens in CI logs.