Add Polythene to your project with npm or yarn.
Essential:
mithril
polythene-mithril
Recommended:
polythene-css
Provides component CSS files and Material Design styles (typography and font); optionally activates CSS-in-JS more info
Optional:
npm install --save polythene-mithril polythene-css
import m from "mithril"
import { Button } from "polythene-mithril"
import "polythene-css"
m(Button, {
raised: true,
label: "Click"
})
import m from "mithril"
import { Button, Dialog } from "polythene-mithril"
import { addTypography } from "polythene-css"
addTypography()
const App = {
view: () => [
m(Button, {
raised: true,
label: "Show dialog",
events: {
onclick: () => Dialog.show({
/* note the Dialog component is below the other elements in the app */
title: "Hello",
body: "Click outside to close, or press ESCAPE",
backdrop: true
})
}
}),
m(Dialog),
]
}
m.mount(document.querySelector("#app"), App)
A "standalone" version of Polythene - useful for demonstration purposes - is available at:
https://unpkg.com/polythene-mithril/dist/polythene-mithril-standalone.js
Included:
- All components
- All component styles, plus Material Design styles (typography and font), from
polythene-css
subscribe
,unsubscribe
frompolythene-core
- Layout styles from
polythene-utilities
Not included:
- Mithril
Add to your HTML file:
<div id="root"></div>
<script src="https://unpkg.com/[email protected]/mithril.min.js"></script>
<script src="https://unpkg.com/polythene-mithril/dist/polythene-mithril-standalone.js"></script>
To be able to write es6, add babel-standalone
(not necessary for JSFiddle or flems):
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
/* global m, polythene */
const { Button } = polythene
const App = {
view: () =>
m(Button, {
raised: true,
label: "Button"
})
}
// Assuming a html element with id `root`
m.mount(document.getElementById("root"), App)
See: online flems