mithril-ui-form-rating-plugin

Plugin to add a rating component to Mithril-UI-Form.

Usage no npm install needed!

<script type="module">
  import mithrilUiFormRatingPlugin from 'https://cdn.skypack.dev/mithril-ui-form-rating-plugin';
</script>

README

A rating plugin for Mithril-ui-form

Mithril-ui-form is a declarative framwork to create forms using the front-end Mithril framework and mithril-materialized components using the materialize-css design theme.

A simple rating control, i.e. a horizontal list of radio buttons, with optional labels for each item.

Include rating control

import { ratingPlugin } from "mithril-ui-form-rating-plugin";

...

registerPlugin("rating", ratingPlugin);

Optional CSS style

Please include the following CSS style to make it look good.

.muf-rating {
  width: 100%;
  padding: 0.5rem 0;
  display: flex;
  justify-content: flex-start;
  align-items: flex-end;
}
.muf-rating > .label {
  width: 50%;
}
.muf-rating > .radios {
  width: 50%;
  display: flex;
  justify-content: space-evenly;
  align-items: flex-end;
}
.muf-rating > .radios > label {
  display: inline-block;
  padding: 0 0.1rem 1rem 0.1rem;
  text-align: center;
}
.muf-rating > .radios > label > input[type='radio'] {
  opacity: 1; /* only needed when using materialize-css */
}

Example usage

Example
{ 
  "id": "my_rating", 
  "type": "rating",
  "label": "What do you think of this plugin?",
  "description": "_Please, be honest!_",
  "min": 0,
  "max": 5,
  "ratings": {
    "0": "extremely<br>bad",
    "5": "super<br>good"
  }
},