Currently I have a particular “rating” that I am getting from Xano that I want to show in Weweb in terms of stars. I have the full star icon, the empty star icon, and the half star icon. Now how do I get the star icons to talk to the rating? For example, if the rating is 4.5, I want to show 4 full stars and 1 half star. The ratings are out of 5, so only 5 stars should be displayed at any one time (whether its full, half or empty stars)
Also ran into this situation and it takes some time to replicate across pages
Please consider creating this “rating” block in the Inputs&Controls section as a drag&drop item
Other nocode platforms also have this one as an independent block (i.e Bubble)
Once done, you can register this component in your design system and reuse it anywhere you want. They will not be linked though, so if you update this component in your design system it will not update every place where you used it.
This will be solved by the upcoming reusable component system, stay tuned!
Thanks
Because in my case it is a little more complicated.
I have a database table called “user reviews”
These user reviews are linked to a given product
On the product page I need to show the average of the user reviews in the stars (just like an amazon review system) as well as the total count in front of the stars
And then every time a user makes a review, this table is updated
and in another section of the product page the user can submit the review that is pushed to this table
If you have any suggestion, it is much appreciated as I’ve been struggling with your example to show the average of the reviews I have
Do you already have the average rate or do you have to calculate it yourself ? The best would be to calculate it backend side, you can probably have a computed column on your reviews returning the average score. Once you have this information you can reuse the formula I already shared, you will have to replace “myRate” with the average rate you have.
Create a component variable that will hold the star states, an array of 5 false values.
Create a new state on the star (filled) where you check the variable at the current index Docs on States
Create a mouseover workflow on the star. Iterate the star states and change all variable indexes that are smaller or the same as current hover index.
Create a mouse leave workflow on the star, where you reset the component variable.
Create an onclick workflow on the star, that emits an onchange event with the index of the clicked star.
Now you can also implement pre-filled stars from a value in your database as well, by using component inputs.
You can also implement half stars much the same way (then you would make 10 alternating half stars the same way, using states)
I know this is a quite rough outline of how to do it, but spending some time learning how you can create a component inside WeWeb will be rewarding, as you can create anything you want later.
Yeah, this would indeed be a good approach, I was thinking with half stars in mind, so it seemed complex, but if the half stars aren’t a requirement, this should be a 10 min job.
You have half stars both in FA Solid and FA regular icon sets.
De exactly as above, but use 10 half stars instead, array of 10 false values, use states to flip every second icon. Now a 11 minute job