Skip to content
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

added better default labels to form components #1040

Merged
merged 5 commits into from
Apr 20, 2022
Merged

Conversation

abidlabs
Copy link
Member

@abidlabs abidlabs commented Apr 20, 2022

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":

image

Of course, these labels can be overridden by the user to say whatever they want. In the Interface class, 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 interactive prop could take true, false, or null, and so I adapted the logic to not depend on null.

Also I included some other minor cleanups that I noticed going through the components.py file.

Closes: #669 #982

@abidlabs abidlabs requested review from pngwn and omerXfaruq April 20, 2022 15:56
Copy link
Member

@pngwn pngwn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all working fine, the three interactive cases (explicit true/false and implicit autodetection) are working perfectly and the default values look great!

@abidlabs
Copy link
Member Author

Yay thanks @pngwn!

@abidlabs abidlabs merged commit 5c34d91 into main Apr 20, 2022
@abidlabs abidlabs deleted the improve-labels branch April 20, 2022 17:54
Copy link
Contributor

@omerXfaruq omerXfaruq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Good work!

@@ -4,7 +4,7 @@
export let value: boolean = false;
export let default_value: boolean = false;
export let style: string = "";
export let label: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: How does the label is realized when the user provides one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean , sorry?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@@ -164,5 +165,24 @@ def test_format_ner_list_empty(self):
self.assertEqual(format_ner_list(string, groups), result)


class TestDeleteNone(unittest.TestCase):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good practice to write a test for it, great!

@@ -2371,7 +2369,11 @@ def get_template_context(self):
return {"default_value": self.default_value, **super().get_template_context()}


############################
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better borders 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

omit null values in config
3 participants