I have prepared some plunks using Materialize and Aurelia, showing some basic implementations of custom controls. @JeroenVinke suggested that we use these to discuss when to use custom attributes/elements. That way we can have a look at them from a user's perspective.
I will post the current plunks first, then do some variations using attributes or elements and post them here, too.
Datepicker (attribute):
http://plnkr.co/edit/7RxUGfKOTx0i4gjl3Ay9
Datepicker (element):
I guess this doesn't make sense since it's not bringing anything to the table other then manipulating an existing <input>
. (first rule of thumb here?)
Dropdown (attribute):
http://plnkr.co/edit/jaSEjYf8K1ZyRq8g4aZ8
Dropdown (element):
http://plnkr.co/edit/zhgVowIr3mPPLYHoFJyk
I like the "embedded" style of the element more. Wish we could do without the ids and use at least selectors. But we could compensate for that using a custom element which could calculate and set the id by itself (using a static variable).
Select (attribute):
http://plnkr.co/edit/BigNLhvCW2P3cS3x1lPt
Select (element):
I guess I'll pass here, too. Again, this manipulates an existing <select>
and I don't see any benefit in doing a custom element. But maybe there are good reasons I don't see. π
Tabs (just css, no custom anything):
http://plnkr.co/edit/YaMJxve5PoLwPxTwGfUQ
Since tabs seem to be a lot of work I won't do them now in the plunk but instead do it later in the catalog app. I need them anyway for the sample pages.
Basically I'm thinking custom element here since then we have better control of its contents (imo). That control will be handy if we implement for example:
- dynamic tab add/remove
- get the (view-model of) a specific tab
- get/set the selected tab
- callbacks/events for tab selection/deletion/addition
Possible usage:
<md-tabs selected.bind="selectedTab">
<md-tab title="html">html code</md-tab>
<md-tab title="javascript">js code</md-tab>
<md-tab title="css">css rules</md-tab>
</md-tabs>
Maybe it's even possible to bind the selected tab to the active route..