Open ntoll opened 3 weeks ago
Do we have a style collection for each widget? If so, what are they for each widget. Ask Toga..!
Examples include platform agnostic ways to define (as appropriate for each different widget):
Toga doesn't explicitly list which styles are appropriate to which widget – irrelevant styles are simply ignored. But the Invent builder would need such a list.
The applicable styles depend not only on the class of the widget, but also on the widget's parent. For example, every Invent Component currently has a row_span and column_span, but they have no effect unless the Component is inside a Grid.
So here's what I'm thinking of:
Separate the "style" properties (which will become CSS) from the "content" properties (which will become HTML).
Keep the content properties as they are, but move the style properties into a separate class, like this:
Button(
name="button honk",
label="HONK!",
channel="honk",
style=Style(position="FILL"),
),
Each Component subclass would declare (in a non-public attribute) which styles it supports for itself. A Container subclass would additionally declare a list of possible styles for its children. For each widget, the builder would offer the combination of the self-styles for the widget, and the child-styles from its parent.
Advantages of this approach:
@mhsmith Thank you for this... it all makes sense to me..! :slightly_smiling_face:
Happy to pair on this with you at a time of your convenience. :+1:
How about during the Honkathon on Thursday, unless you already have something planned for that?
Sounds like a plan! Looking forward to it. We can also explain the work we've been doing on tasks (i.e. the simple abstraction in Invent for asynchronous / non-blocking activity).
Styling is provided by themes. However, we need to provide an "escape hatch" for experienced developers who want more flexibility on styling components. Hence the need for (and refinement of) a
style
attribute onComponent
subclasses. In its simplest form,style
could just be raw CSS attached to the component via the HTMLstyle
attribute.