This is the idea behind class hierarchy - feel free to comment, we can change it:
Component trait just provide HTMLElement
ParentComponent provides some useful protected methods for manipulating element (add/remove child, attributes setting)
Content of HTML element is created by the Component code, not by the user of the component (TextInput, Grid, ...)
HTMLParentComponent
inner content of the html element can be created by DSL
example: div, span, ...
So If I undestand well, ParentComponents are the components which for we don't want to allow the user to add any kind of child elements explicitly. So for example the Grid: It is a table with many child elements, but these elements are added and controlled by the Grid itself, not the user of Grid, so she can't do like this:
Grid {...
div {...} // It is prohibited for 'ParentComponents'
}
I think then that the name 'ParentComponent' is misleading.
In my opinion, we need only two base classes:
- abstract Component class with the protected helper methods of ParentComponent.
The classes that now are inherited from ParentComponent, would be the child of this Component.
These child classes can control which elements can a user add to themselves.
- HTMLParentComponent, but with an another name, e.g. "ComponentContainer", which for the user can freely add any elements (div, ul, etc.)
Can you use 4 spaces as indent?
Of course.
Was thinking about adding id and class as optional parameters to all HTML DSL functions, namely HTMLParentComponent.div an .span.
So that instead of
div {
id = "bla"
ul { }
}
we can write
div(id="bla") {
ul { }
}
I think it is a good Idead, but the default value should be an empty string.
enhancement