Getting started
These are dependency-free UI components written in TypeScript and compiled to ES5, targeting browsers back to IE10. Each component ships as its own file, so load only what you use.
The classes are the same either way: Modal in a module, ML.Modal on a page that loads a script.
With a bundler
Section titled “With a bundler”The package ships ES modules (still ES5 syntax) and TypeScript declarations:
import { Modal } from '@mikewgd/myjs';
const modals = new Modal();modals.init();The helper functions the components are built from are exported too (see Helpers).
With a script tag
Section titled “With a script tag”Every component and utility is a classic script that defines a global, ML. No bundler needed.
<link rel="stylesheet" href="css/modal.css"><script src="js/modal.js"></script><script> var modals = new ML.Modal(); modals.init();</script>js/<name>.js/.min.jscontains one component or utility.js/ml.js/.min.jscontains all of them, andcss/myjs.cssthe styles of every component.- Several single-component scripts can be loaded on the same page; they share one
ML. MLholds the classes, and nothing else. The helper functions are in the module build only.
The CSS only provides structure (positioning, show/hide). Colors, borders and spacing are up to your page, so each demo here is styled by this site.
Components and utilities
Section titled “Components and utilities”A component has markup or CSS: a Modal, a Dropdown. A utility is behavior only: Ajax, Animate, Breakpoints.
Both are classes with the same shape: settings in the constructor, init() to start, destroy() to stop.
Browser support
Section titled “Browser support”Targets IE10 and newer. The output is ES5.