0.7.1 • Published 10 months ago

mithril-ui-form-rating-plugin v0.7.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

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

{ 
  "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"
  }
},

Or you can use the alternative syntax, so it is easier to switch between options and select. Just make sure that the options's id property is a number (or a number converted to a string, e.g. "42").

{
    "id": "hasIndDiff",
    "label": "Has individual differences?",
    "type": "rating",
    "options": [
      {
        "id": 1,
        "label": "None"
      },
      {
        "id": 2,
        "label": "Unknown"
      },
      {
        "id": 3,
        "label": "Yes"
      }
    ],
    "className": "col s12"
  },
0.7.1

10 months ago

0.7.0

10 months ago

0.6.1

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.4.10

2 years ago

0.4.9

2 years ago

0.4.8

2 years ago

0.4.11

2 years ago

0.4.5

2 years ago

0.4.4

2 years ago

0.4.7

2 years ago

0.4.6

2 years ago

0.4.3

2 years ago

0.4.2

2 years ago

0.4.1

2 years ago

0.4.0

3 years ago

0.3.3

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago