diff --git a/pyproject.toml b/pyproject.toml index 1959d6d..34acf73 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "edit-python-pe" -version = "0.2.9" +version = "0.2.10" description = "Allows member and project profile editing onto python.pe git repository" readme = "README.md" authors = [ diff --git a/src/edit_python_pe/main.py b/src/edit_python_pe/main.py index 7f3447e..c489a92 100755 --- a/src/edit_python_pe/main.py +++ b/src/edit_python_pe/main.py @@ -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 + + 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() diff --git a/uv.lock b/uv.lock index 11b7749..098ea14 100644 --- a/uv.lock +++ b/uv.lock @@ -325,7 +325,7 @@ wheels = [ [[package]] name = "edit-python-pe" -version = "0.2.9" +version = "0.2.10" source = { editable = "." } dependencies = [ { name = "babel" },