Package Exports
- mithril-materialized
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mithril-materialized) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
mithril-materialized
A materialize-css library for the Mithril framework (tested with v2.0.0-rc4 and higher, but presumably, it should work with v1.1.6 too), making it easier to use a Materialize theme in your application. The main focus of this library is on creating Mithril components for the more complicated Materialize components.
Supported components:
- Buttons
- Button
- FlatButton
- RoundButton
- SubmitButton
- Inputs
- TextInput
- TextArea
- AutoComplete
- UrlInput
- EmailInput
- NumberInput
- ColorInput
- RangeInput
- Chips
- Pickers
- DatePicker
- TimePicker
- Selections
- Select
- Options
- RadioButtons
- Switch
- Dropdown
- Collections
- Basic, Link and Avatar Collections
- Collapsible or accordion
- Others
- ModalPanel
- MaterialBox
- Carousel
- Pagination
- Parallax
- Additional
- Label
- HelperText
- Not from Materialize-CSS
Version history
v0.11.7 No breaking changes
Timelinetitle can now be a Vnode too.
v0.11.6 No breaking changes
Selectcontrol can now be disabled by adding the propertydisabled: trueto the control's properties.
v0.11.5 No breaking changes
MapEditorhas anonchangecallback to notify changes to the properties collection.MapEditorallows you to set the column width (keyClass) for the key and value column (keyValue).
v0.11.4 No breaking changes
- FIX
CodeBlockmissed importing ofcss.
v0.11.3 No breaking changes
- FIX
Timeline: Default date formatter did not add 1 to the months. See here. - FIX
MapEditorwhen dealing with number inputs and the number was 0, it did not work properly. - FIX
NumberInputwhen the number was 0, the label was not active (and overlaying the number).
v0.11.2 No breaking changes
- FIX Issue with
SecondaryContentinCollectioncomponent: when nohrefwas provided, it still created ahref=#!undefinedlink.
v0.11.1 No breaking changes
- Improved generics of
SelectandDropdowncomponent - FIX Issue with
placeholderinSelectcomponent: when no item was selected, it would not show the placeholder text.
v0.11.0 New component, Timeline
- Added a
Timelinecomponent to render vertical timelines. Collectionnow accepts other parameters, e.g. styles.- All
cssstyles are extracted into separatecssfiles, and imported in the component. This implies that you don't need to add the required CSS in your own application anymore (except formaterialisecss, of course). - Added documentation using
Typedoc. It can be found here.
v0.10.0 New component, MapEditor
- Added a new component,
MapEditor, to edit a map of key-value pairs. InputCheckboxcan now be disabled.- Attributes are better dealt with and no longer end up as unused attributes of elements.
- Fixed a bug for
TextInput, where sometimes theactiveclass was not added even if theinputelement had a value.
v0.9.10 Breaking changes
- Deprecated the use of all
contentClassproperties in favour of the mithril conventionclassName.
v0.9.9 Breaking changes
ModalPanel: it's description (i.e. the main content area of the modal) can be aVnode.Selectdoes not usecontentClassanymore, but instead uses the regular mithrilclassName(but notclass, since this is a reserved keyword in TypeScript).
v0.9.6 No breaking changes
- For a
Collectionwith secondary content, do not create a SPA route (with a #!) but leave the URL as is.
v0.9.5 No breaking changes
- FIX
Selectbug when numeric option IDs were used and ID === 0, option was never selected.
v0.9.4 No breaking changes
- FIX
Collectionwithout headers did no longer render.
v0.9.3 No breaking changes
Collectionwith links can now also contain a header.Collectionwith no items and only a header will now just render the header
v0.9.0 Breaking changes
Collapsibleis now correctly spelled (used to beCollabsible, oops).- Added
Collection, to create a collection of items: supports basic, link and avatar collections.
v0.8.3 No breaking changes
FileInputcomponent can be disabled, and accepts file types.
v0.8.1 No breaking changes
- Closes issue #1: Select issue with id === 0
- MaterialBox can set height, passes attributes to wrapped image element
v0.8.0 No breaking changes
FileInputcomponent can specifyclassproperty on thedivwrapper (defaultcol s12) andcontentClassproperty on the file input element.
v0.7.0 Breaking changes for Dropdown component.
- New
FileInputcomponent to upload one or more files. Dropdownuses similar items asSelect, and usescheckedIdto select the item.Dropdownitems can now use an icon and dividers.Dropdowncan now have a helper text option and an icon prefix.
v0.6.4 Breaking changes, bug fix.
Selectdid not always return the proper id on selection changes with multiple elements.
v0.6.3 No breaking changes, bug fix.
Selectdid not update dynamically when checkedId changed.
v0.6.2 No breaking changes
Selectcan useM.FormSelectOptions.
v0.6.1 No breaking changes
Selectcan havedisabledoptions, andidis optional (in which case the label is used).Selectcan use a prefix icon.
v0.6.0 No breaking changes
Inputscan now useonkeyup,onkeydown, andonkeypressevents. They also return the value.- Additionally, they can use
readOnly,patternandautocomplete(does not always seem to work).
v0.5.0 No breaking changes
- NEW: Pagination control
- BUG FIX:
Input.onchangewould not fire if the input was cleared. - All options now derives from mithril's
Attributes. - Using
FactoryComponenttype
v0.4.4 No breaking changes
- Do not pass attributes through, e.g. if you had a
m(FlatButton, { onupdate }), theonupdatewas passed through to theHelperTexttoo.
v0.4.3 No breaking changes
- The validate method for inputs now also accepts the HTMLInputElement
- Removed a few left-over
console.logstatements.
v0.4.2 No breaking changes
- Added
requiredandaria-required="true"attributes when therequiredorisMandatoryproperty are set.
v0.4.1 No breaking changes
- Updated all components to use the mithril
domattribute instead of performing a document query. This has two advantages: first of all, performance, since we do not need to query for an element we already have. Second, when implementing custom elements that have anoncreatefunction. Using document.query... will lead to no results.
v0.4.0 No breaking changes
- New components: MaterialBox, Collapsible or accordion, and Carousel
v0.3.0 Breaking changes
- Buttons no longer use the
uiclass to specify additional properties likeonclick. Instead, you can leverage the mithril attributes directly. See the example,button-page. contentClasshas been removed in favour of the default mithrilclassorclassNameattribute.- The Icon function has been replaced by the
Iconcomponent. TheSmallIconandPrefixedIconhave been removed, as they can easily be created using theIconcomponent. - The
autofocusattribute for inputs now also works on updates (by calling the element.focus() method). - The code has been split over multiple files, so it is easier to only import the components that you need.
v0.2.2
- Validate function can return a custom validation message. Also, it is called in
onupdate, so the validation occurs also when you just attach the validate function conditionally.
v0.2.1
- Label field is optional for inputs.
- Added autofocus function|property to input fields.
- Added custom validation using the validate function|property to add valid/invalid label to an input.
- Removed dependency on materialize-css (it is expected that it is imported via the main app).
Usage instructions
See the documentation for examples on how to use this library in your own application. Please note that the library does not include mithril, nor the materialize-css JavaScript or CSS, so you have to include them yourself, as documented.
Build instructions
This repository consists of two packages, combined using lerna: the lib package that is published to npm, as well as an example project which uses this library to display the Mithril components that it contains.
To install the dependencies, you can use npm i, or, alternatively, use pnpm m i (assuming you have installed pnpm as alternative package manager using npm i -g pnpm) to perform a multi-repository install. Next, build everything using npm start and visit the documentation page on http://localhost:1234 in case port 1234 is not occupied already.
CSS
Although I've tried to limit the CSS adaptations to a minimum, I needed to tweak certain parts to make it look better. Here are the styles I've added.
.clear,
.clear-10,
.clear-15 {
clear: both;
/* overflow: hidden; Précaution pour IE 7 */
}
.clear-10 {
margin-bottom: 10px;
}
.clear-15 {
margin-bottom: 15px;
}
input[type='color']:not(.browser-default) {
margin: 0px 0 8px 0;
/** Copied from input[type=number] */
background-color: transparent;
border: none;
border-bottom: 1px solid #9e9e9e;
border-radius: 0;
outline: none;
height: 3rem;
width: 100%;
font-size: 16px;
padding: 0;
-webkit-box-shadow: none;
box-shadow: none;
-webkit-box-sizing: content-box;
box-sizing: content-box;
-webkit-transition: border 0.3s, -webkit-box-shadow 0.3s;
transition: border 0.3s, -webkit-box-shadow 0.3s;
transition: box-shadow 0.3s, border 0.3s;
transition: box-shadow 0.3s, border 0.3s, -webkit-box-shadow 0.3s;
}
.codeblock {
margin: 1.5rem 0 2.5rem 0;
}
.codeblock > div {
margin-bottom: 1rem;
}
.codeblock > label {
display: inline-block;
}
span.mandatory {
margin-left: 5px;
color: red;
}
label+.switch {
margin-top: 1rem;
}