Here’s a tricky one that I believe can probably be solved with some short but elegant code.
I’m trying to add a progress bar to each collection item within a collection list. The length of this progress bar should be determined by a numeric value that is contained in the CMS.
e.g. Attendance in the CMS = 0 (Bar should be non-existent)
e.g. Attendance in the CMS = 5 (Bar should be full, if the max amount is also 5)
I have added an HTML Embed with custom code to size the progress bar, however, all the collection items seem to use the first item’s value to size the progress bar and they all look the same size.
Here is my custom code:
If you want a star rating, and the value is always between 0 and 5, then you can use Sygnal’s WFU library to add a ratings element easily;
You just drop an Html Embed in, and paste this
<div wfu="rating" wfu-rating="5.0"></div>
Replace the rating value with your CMS field.
Wrap it in a div, and size how you like. The stars are SVGs so they won’t pixellate.
If you’re looking for actual progress bars, that’s a slightly different thing in that there is a current value, a maximum value, etc. HTML 5 offers that but I prefer a CSS calc() approach. Both are detailed here;
Thanks so much for all of this! I tried your method but it was a little complex for me so I ended up using the solution below which turned out to be easy to implement, I really appreciate the effort though, and wish I had the technical background to fully understand your solution.
Thanks so so so much!! This is such a simple solution, I ended up using the CSS Cacl() as you mentioned and it worked splendidly! And Thanks for the speedy response
Hi @WillSayer that’s absolutely fine I’m glad to see you have been able to solve your request. The solution I have provided use plain JS mean doesn’t require any external library and for simple task like that loading library is IMO overkill. On you web you have developer in team so I thought he will know how to use it. Anyway, now I understand that at this point no-code is better solution.
Good luck