1.1.7 ā€¢ Published 1 month ago

@ernane/svelte-star-rating v1.1.7

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

šŸ’» 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!


1.1.7

1 month ago

1.1.6

1 month ago

1.1.5

5 months ago

1.1.1

9 months ago

1.1.4

9 months ago

1.1.3

9 months ago

1.1.2

1 year ago

1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago