0.0.4 • Published 2 years ago

kuttin_rating-stencil-component v0.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Built With Stencil

A rating Web component

This is an example project showing how to build a rating Web component by using Stencil, a Web component compiler created by the Ionic Team.

The project defines a star rating component like the following:

npm.io

It allows you to set your rating value, to capture the event of assigning a new rating value, and to programmatically access the current rating value.

To know more about the component and how it works, check out the article Creating Web Components with Stencil.

Using the component

Copy the content of dist/rating-stencil-component folder into a local folder named my-rating.

Create an HTML page in a local folder and put the script tags shown below in its head section:

<script type="module" src="my-rating/rating-stencil-component.esm.js"></script>
<script nomodule src="my-rating/rating-stencil-component.js"></script><script>

Now you can use the component in your HTML by inserting the tag <my-rating></my-rating>

The following are the attributes of my-rating element:

AttributeDescriptionDefault value
max-valueThe maximum number of stars for the component5
valueThe rating value currently shown0

You can also handle the ratingUpdated custom event, that is an event fired when the value of the component changes.

Exploring the project

To explore the component project, download it into your local folder and run:

npm install
npm start

To build the component for production, run:

npm run build

Check out our Stencil docs for more details.