added better default labels to form components#1040
Conversation
pngwn
left a comment
There was a problem hiding this comment.
This is all working fine, the three interactive cases (explicit true/false and implicit autodetection) are working perfectly and the default values look great!
|
Yay thanks @pngwn! |
| export let value: boolean = false; | ||
| export let default_value: boolean = false; | ||
| export let style: string = ""; | ||
| export let label: string; |
There was a problem hiding this comment.
Question: How does the label is realized when the user provides one?
There was a problem hiding this comment.
@pngwn the default label is assigned like this:
export let label: string = "Checkbox";
I was wondering how do we assign the label given by the user
There was a problem hiding this comment.
These export let statement essentially marks the interface for the component. They are passed in from above : <Checkbox label="some_label" />. Same way arguments are marked on a function and passed in by the caller.
| self.assertEqual(format_ner_list(string, groups), result) | ||
|
|
||
|
|
||
| class TestDeleteNone(unittest.TestCase): |
There was a problem hiding this comment.
Good practice to write a test for it, great!
| return {"default_value": self.default_value, **super().get_template_context()} | ||
|
|
||
|
|
||
| ############################ |
This PR adds better default labels to form components. Instead of "null", the label now shows the name of the component. For example, the default label for a slider is "Slider":
Of course, these labels can be overridden by the user to say whatever they want. In the
Interfaceclass, the labels continue to be based off of the parameter names (for the input components) and are "output" or "output X" for the output components.As part of this work, I also removed any prop whose value is "null" from the config. This could potentially lead to some problems, so it would be great if you could review this @pngwn. For example, I noticed that the
interactiveprop could taketrue,false, ornull, and so I adapted the logic to not depend onnull.Also I included some other minor cleanups that I noticed going through the components.py file.
Closes: #669 #982