-
Notifications
You must be signed in to change notification settings - Fork 3
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
Enhance form and widget button label functionality #28
Conversation
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.
- radio的设计也更新了,需要改
- button不需要这两个按钮,加了的话得看前端实现会不会忽略
- submit/cancel两个值最好不是作为render函数的参数,而是__init__参数,并且可作为widget的property
参考设计文档变更:devchat-ai/devchat-website#4
367fbe9
to
9c3ebd0
Compare
libs/chatmark/widgets.py
Outdated
@@ -9,10 +9,12 @@ class Widget(ABC): | |||
Abstract base class for widgets | |||
""" | |||
|
|||
def __init__(self): | |||
def __init__(self, submit: Optional[str] = None, cancel: str = "Cancel"): |
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.
cancel
也应该是 Optional的吧
libs/chatmark/widgets.py
Outdated
@@ -249,12 +265,12 @@ def __init__( | |||
# if default_selected is not None: | |||
# assert 0 <= default_selected < len(options) |
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.
加了default_selected
后,这段注释也恢复一下,检查下标是否越界
libs/chatmark/widgets.py
Outdated
if self._selection is not None and self._selection == idx: | ||
lines.append(f"> X ({key}) {option}") |
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.
可以只判断 if self._selection == idx:
,另外文档里x
是小写,不确定前端解析到时是不是case-sensitive,这边还是按文档来吧
- Form and TextEditor classes now accept submit_button_name and cancel_button_name - Widget's chatmark header updated with customizable submit and cancel labels - Adjusted initialization of Checkbox and Radio classes with button label parameters
- Introduced the default_selected parameter in the Radio widget - Updated Radio widget to mark default selected option visually - Removed TODO comment for the default_selected implementation
- Add trailing commas to button name parameters in widgets - Reformat constructor definitions for consistency - Clean up unnecessary whitespace in widget render logic
- Make submit and cancel button labels optional in form and widgets - Refactor chatmark header construction for conditional button labels - Implement assertion for Radio widget's default_selected option
bb48e77
to
05d8e6d
Compare
This pull request introduces two key features to enhance the user interface components:
default_selected
parameter has been added to the Radio widget, allowing a default option to be specified and visually marked when the widget is rendered.These updates aim to provide a more flexible and user-friendly experience with our UI components.
As there was no specific issue linked to these changes, there is no issue to close with this pull request.