New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancing HTML Component design #38
Comments
Yep, that's what I meant.
But we can rename class hierarchy: |
Then the second difference is that ParentComponent creates its own Element, which fact is slightly hidden from the programmer (the name "ParentComponent" does not tell about it). What about the following idea: The Grid and other classes that are inherited from ParentComponent would use this Element as their parents, like public class Grid<T>(val columns:Array<Column<T>>) : Element(document.createElement("table") as HTMLElement) { (Of course the createElement should be extracted to a method with a shorter name.) I know that the "Element" word is quite frequent (as well as the "Component"), but maybe it tells more about their function (I think "Component" means a bigger thing than "Element", especially in a HTML context) |
I think we should keep ability to create HTMLElement later, like it is used in Spinner class. Putting all the logic into constructor might be lead to messy code. I think it would be better to use Component name as it kind of encapsulate HTMLElement with some additiona logic (our code) What about this:
Maybe we do not need helper methods add,replace,fade. You are right that it hides from user what is really hapenning, what about making these extension methods of HTMLElement ? (if these are not there already) |
You are totally right.
I like this version.
I think they are useful and the Trait can contain them, just need some renaming for clarifications: add(component:Component) -> appendChild
add(text:String) -> appendContent?
public fun replace(text:String) -> setContent? (most programmer is familiar "replace" from String.replace(pattern, newText), so using "replace" here is confusing)
public fun replace(component:Component) -> setChild? setContent? Maybe these functions souldn't be open. |
New method names looks good (last one would call setContent to match appendContent). |
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:
I think then that the name 'ParentComponent' is misleading.
In my opinion, we need only two base classes:
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.
Of course.
I think it is a good Idead, but the default value should be an empty string.
The text was updated successfully, but these errors were encountered: