sethbrasile [7:20 PM]
I’m planning on rebuilding ember-remodal
by building it out of standalone behavioral “primitives” as @locks and I (and @runspired to a limited extent) have discussed.
The idea behind it is based on Trek Glowacki’s talks on the Frontside podcasts, encouraging folks to start building and sharing primitives for “reuse in-the-small” and then building their larger “reuse in-the-large” libraries out of these primitives.
I started messing around with the concept, but I would like start some discussion if anyone is interested, as I hope this could inspire other libraries to do similarly. I don’t feel comfortable making API decisions here without community support, as I feel like some form of “standards” would be a good thing.
So, for instance the first primitive that I’m focusing on (because it seems the easiest/most intuitive) is an overlay
primitive titled ember-primitive-overlay
.
My first iteration of this primitive exposes two ways to open/close the overlay:
- via the
overlay
service:this.get('overlay').open()
- via the
primitive-overlay
component and toggling anisOpen
bool that is passed into the component
A small amount of css is included which creates the base functionality of an overlay, but does not style further:
display: none;
top: 0;
left: 0;
position: fixed;
height: 100%;
width: 100%;
}
.overlay[overlay-state="opened"] {
display: block;
}
And currently, use of the service-overlay in a template looks like this
<div {{action 'closeOverlay'}} class="overlay" overlay-state={{overlay.state}}></div>
Thoughts? 1
[7:24]
And I’m thinking the use of the primitive-overlay
component in a template could look something like this:
{{!-- block form could work too --}}
{{primitive-overlay
isOpen=isSomeOverlayOpen
closeOverlay=(action 'closeOverlay')
}}
(edited)
sethbrasile [7:45 PM]
Another discussion point I’d like to hit is performance: Is there a surefire way to structure a primitive that won’t negatively affect performance if there were _many_ instances alive at once? (edited)
sethbrasile [8:18 PM]
One more discussion point: How should primitives be released? As standalone addons? As collections of related primitives in a single addon? As standalone addons that released and then pulled together into related concepts and also released as collections? Should they be addons at all? Will there any size bloat / performance degradation due to them being addons instead of something like importable es6 modules or something like that?
Allow me to try and clarify the “size bloat” question. Say 10 authors release small collections of primitives, and the consuming app ends up using all 10 collections as deps of various addons. Does the sole fact that each collection is an addon contribute anything to the consuming app’s size? Would there be any benefit in making them “lighter” than an addon?