MetaComponent is a component generator that can convert a single component definition into...
This is particularly useful for Design Systems and Pattern Libraries where a single template definition could be converted into multiple formats.
Try the MetaComponent REPL.
Some of its use-cases are:
It's often the case that governments and large organisations have
websites that have very different websites and components, and
these differences are often accidental or unnecessary.
An obvious solution would be to make a Design System or Pattern
Library where you'd publish components to unify HTML and CSS.
However one stumbling block is when there's also a divergence in
web component technology -- they use React, or Vue, Angular,
Handlebars, Jinja2, Twig, and many, many more.
It would be a lot of manual work to support all of those comonent
formats, and so Design Systems and Pattern Libraries typically
offer HTML/CSS, and maybe one additional format, and all of these
are written by hand.
Design Systems often solve one problem (standardising HTML/CSS)
while creating new technical barriers that may hinder adoption.
MetaComponent complements Design Systems Pattern Libraries by
generating components for many frameworks to make it easiser to
adopt.
npm i metacomponent
or yarn add metacomponent
.
See src/lib/testHelpers.ts
for example usage. It requires a DOM and we suggest you use JSDOM.
children
values (arbitrary childNodes) so you could just nest other components instead. Maybe we don't need this.MetaComponent 2.1.0 and later installs a metacomponent-watcher
script in node_modules/.bin/metacomponent-watcher
that takes two args in
and out
to watch a directory and output files. E.g.
node node_modules/.bin/metacomponent-watcher.js --in some_dir --out some_other_dir