-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add labels to all the inputs fields #53
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,6 +24,46 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| load_file_into_form) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class LabeledInput(Vertical): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DEFAULT_CSS = """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LabeledInput { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| height: auto; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LabeledInput Static { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| width: 25%; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LabeledInput Input { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| width: 100%; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def __init__( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self, label: str, placeholder: str = "", value: str = "", **kwargs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| super().__init__(**kwargs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.label = label | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.placeholder = placeholder | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self._value = value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def compose(self) -> ComposeResult: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| yield Static(self.label, classes="label") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| yield Input( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id="input", placeholder=self.placeholder, value=self._value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @property | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def value(self): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return self._value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @value.setter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def value(self, v: str): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self._value = v | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.query_one(selector="#input").value = v | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+51
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix value desync: LabeledInput.value doesn’t reflect user edits, causing saves to miss typed data Getter returns the cached Apply: @@
- def compose(self) -> ComposeResult:
- yield Static(self.label, classes="label")
- yield Input(
- id="input", placeholder=self.placeholder, value=self._value
- )
+ def compose(self) -> ComposeResult:
+ yield Static(self.label, classes="label")
+ self._input = Input(placeholder=self.placeholder, value=self._value)
+ yield self._input
@@
- @property
- def value(self):
- return self._value
+ @property
+ def value(self) -> str:
+ # Reflect current field contents
+ return self._input.value if hasattr(self, "_input") else self._value
@@
- @value.setter
- def value(self, v: str):
- self._value = v
- self.query_one(selector="#input").value = v
+ @value.setter
+ def value(self, v: str) -> None:
+ if hasattr(self, "_input"):
+ self._input.value = v
+ self._value = v📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class SocialEntry(Horizontal): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DEFAULT_CSS = """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SocialEntry Select { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -129,10 +169,18 @@ def on_mount(self) -> None: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # 2) Build the form portion, hidden at first | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.form_header = Static(FORM_HEADER, classes="header") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.name_input = Input(placeholder=PLACEHOLDER_NAME) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.email_input = Input(placeholder=PLACEHOLDER_EMAIL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.city_input = Input(placeholder=PLACEHOLDER_CITY) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.homepage_input = Input(placeholder=PLACEHOLDER_HOMEPAGE) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.name_input = LabeledInput( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| f"{PLACEHOLDER_NAME}:", placeholder=PLACEHOLDER_NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.email_input = LabeledInput( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| f"{PLACEHOLDER_EMAIL}:", placeholder=PLACEHOLDER_EMAIL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.city_input = LabeledInput( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| f"{PLACEHOLDER_CITY}:", placeholder=PLACEHOLDER_CITY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.homepage_input = LabeledInput( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| f"{PLACEHOLDER_HOMEPAGE}:", placeholder=PLACEHOLDER_HOMEPAGE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.who_area = TextArea() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.python_area = TextArea() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Side-by-side label/input won’t happen with Vertical; use Horizontal (or grid)
Current container stacks children; the widths won’t place them inline.
Apply:
📝 Committable suggestion
🤖 Prompt for AI Agents