Atomic web development - Combining the power of npm, Browserify, Rework and more to build small, fully encapsulated client side modules
Typed Web Component
(if that makes sense)
calendar
, a pinterest wall
and a todo list
, they could all be visual grids in the DOM, that support pagination, filtering, searching, sorting and dozens of other features. But a todo item
looks different from a pinterest card
looks different from a calendar day
. So I came up with example code i'd like to write...
var container=document.body, arr=require('data.json'), grid=require('typegrid'), elem=require('arrElem'); var API=grid(container, arr, elem);
grid
knows it's css/htmljs
and so does the elem
.grid(...)
, where one elem(...)
per item in the array is added.
var calendarAPI = grid(container, array, dayComponent), pinterestAPI = grid(container, array, pictureComponent), todoAPI = grid(container, array, todoComponent);
machinepacks
(but maybe there are alternative and better specs)
var componentAPI = componentName({
container : `domNodeOrSelector`, // maybe it should always be a dom node
options : {/* configuration options */},
data : `modelOrStreamOrEventEmitter`, // to initialize or update stuff
children : [ // this is optional, because maybe the component can use defaults if not provided
{ '__title' : titleComponent },
{ '__list' : listComponent },
{ '__sidebar : sidebarComponent }
]
});
This does say nothing about the Interface
that is returned from a call to any component, like componentName(..)
, titleComponent(..)
, listComponent(..)
or sidebarComponent(..)
.
But I imagine, that it should be possible to somehow formally define an Interface
, so that I can easily write a component that I can inject into an existing component to change it.
Maybe node machines are nice for defining those interfaces, but maybe there are alternatives :-)
What do you guys think of that?
menuComponent
or articleComponent
if i need too, or just build a new website component (by forking the existing one and changing it completely... The goal is to start with simple components and slowly build more complex ones over time