Skip to content

Commit

Permalink
code editor: label prop
Browse files Browse the repository at this point in the history
  • Loading branch information
anish-work authored and devxpy committed Jul 26, 2024
1 parent 7742b03 commit db521a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 7 additions & 1 deletion gooey_ui/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,17 +379,23 @@ def text_area(
def code_editor(
value: str = "",
key: str = None,
label: str = None,
label_visibility: LabelVisibility = "visible",
**props,
) -> typing.Any:
value = str(state.session_state.setdefault(key, value) or "")
return state.RenderTreeNode(
if label_visibility != "visible":
label = None
state.RenderTreeNode(
name="code-editor",
props=dict(
name=key,
defaultValue=value,
label=dedent(label),
**props,
),
).mount()
return value or ""


def nrows_for_text(
Expand Down
8 changes: 6 additions & 2 deletions recipes/Functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@ def run_v2(
response.error = data.get("error")

def render_form_v2(self):
st.caption("##### " + field_title_desc(self.RequestModel, "code"))
st.code_editor(key="code", language="javascript", height=300)
st.code_editor(
label="##### " + field_title_desc(self.RequestModel, "code"),
key="code",
language="javascript",
height=300,
)

def render_variables(self):
variables_input(template_keys=["code"], allow_add=True)
Expand Down

0 comments on commit db521a6

Please sign in to comment.