Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ernane/svelte-star-rating

Package Overview
Dependencies
Maintainers
0
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ernane/svelte-star-rating

Simple component to assign scores based on stars.

  • 1.1.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
158
increased by14.49%
Maintainers
0
Weekly downloads
 
Created
Source

✨ Svelte Star Rating ✨

Project   |    Installation   |    Features   |    Use   

preview star rating

💻 Project

Simple Svelte component, with no dependencies, for implementing and capturing assessments through a simple and intuitive interface that will take you to the stars.

See this demo!!

📦 Installation

$ npm install @ernane/svelte-star-rating # => or yarn

⚠️ if using SvelteKit or Sapper, it is advised to install as a development dependency:

$ npm install @ernane/svelte-star-rating --save-dev # => or yarn

📁 Features

This package will add a svelte component that may or may not receive a configuration object with the following attributes shown below.

  • ⚙️ General Settings
AttributeData TypeRequiredDefault
readOnlyboolfalsefalse
countStarsintegerfalse5
scorefloatfalse0.0
showScoreboolfalsetrue
scoreFormatfunctionfalseprecent
nameStringfalse""

In addition, we have two other nested attributes that specify distinct settings.

  • 📏 Range
AttributeData TypeRequiredDefault
minintegerfalse0
maxintegerfalse5
stepfloatfalse0.001
  • ⭐ Setting of the Stars:
AttributeData TypeRequiredDefault
sizeintegerfalse30
fillColorStringfalse#F9ED4F
strokeColorStringfalse#BB8511
unfilledColorStringfalse#FFF
strokeUnfilledColorStringfalse#000

In the end, the configuration object will be similar to the one shown below.

const config = {
  readOnly: false,
  countStars: 5,
  range: {
    min: 0, 
    max: 5, 
    step: 0.001
  },
  score: 0.0,
  showScore: true,
  scoreFormat: function(){ return `(${this.score.toFixed(0)}/${this.countStars})` },
  name: "",
  starConfig: {
    size: 30,
    fillColor: '#F9ED4F',
    strokeColor: "#BB8511",
    unfilledColor: '#FFF',
    strokeUnfilledColor: '#000'
  }
}
  • 🎯 Events

In addition, it is also possible to observe events of the component itself that will be executed in an internal element from a defined action. Below are the available events.

TypeTargetRequiredDefault
changeinput.sliderfalsenull

💡 Use

  • Import the component

    import StarRating from "@ernane/svelte-star-rating";
    
  • Create the configuration object

    const config = { ... }
    

    **As shown in the previous section

  • Finally, use it! 🎉

    <StarRating {config}/>
    

If you would like to implement or improve any feature feel free to submit a pull request. I would love to receive!


Developed with ❤ by Ernane Ferreira. 👋🏻

Keywords

FAQs

Package last updated on 08 Aug 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc