-
Notifications
You must be signed in to change notification settings - Fork 114
feat: Add input_submit_textarea() and update_submit_textarea()
#2099
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
Open
cpsievert
wants to merge
7
commits into
main
Choose a base branch
from
feat/submit-input
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
811efb8
First pass at input_submit_textarea() port
cpsievert 2f7f130
First pass at Playwright testing
cpsievert f3b0b0f
Update changelog
cpsievert bd812fb
Add to API reference
cpsievert d1bb4c7
Add examples for update_submit_textarea
cpsievert ce8757d
Merge branch 'main' into feat/submit-input
cpsievert 31bb65d
Address feedback
cpsievert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import time | ||
|
|
||
| from shiny import App, Inputs, Outputs, Session, render, ui | ||
|
|
||
| app_ui = ui.page_fluid( | ||
| ui.input_submit_textarea("text", placeholder="Enter some input..."), | ||
| ui.output_text("value"), | ||
| ) | ||
|
|
||
|
|
||
| def server(input: Inputs, output: Outputs, session: Session): | ||
| @render.text | ||
| def value(): | ||
| if "text" in input: | ||
| # Simulate processing time | ||
| time.sleep(2) | ||
| return f"You entered: {input.text()}" | ||
| else: | ||
| return "Submit some input to see it here." | ||
|
|
||
|
|
||
| app = App(app_ui, server) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import time | ||
|
|
||
| from shiny.express import input, render, ui | ||
|
|
||
| ui.input_submit_textarea("text", placeholder="Enter some input...") | ||
|
|
||
|
|
||
| @render.text | ||
| def value(): | ||
| if "text" in input: | ||
| # Simulate processing time | ||
| time.sleep(2) | ||
| return f"You entered: {input.text()}" | ||
| else: | ||
| return "Submit some input to see it here." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| from shiny import App, Inputs, Outputs, Session, reactive, render, ui | ||
|
|
||
| app_ui = ui.page_fluid( | ||
| ui.input_submit_textarea( | ||
| "comment", | ||
| label="Your Comment", | ||
| placeholder="Type your comment here...", | ||
| rows=2, | ||
| toolbar=[ | ||
| ui.input_action_button("clear", "Clear", class_="btn-sm btn-danger"), | ||
| ui.input_action_button("template", "Use Template", class_="btn-sm"), | ||
| ], | ||
| ), | ||
| ui.output_text("submitted_comment"), | ||
| ) | ||
|
|
||
|
|
||
| def server(input: Inputs, output: Outputs, session: Session): | ||
| @reactive.effect | ||
| @reactive.event(input.clear) | ||
| def _(): | ||
| ui.update_submit_textarea( | ||
| "comment", | ||
| value="", | ||
| placeholder="Type your comment here...", | ||
| ) | ||
|
|
||
| @reactive.effect | ||
| @reactive.event(input.template) | ||
| def _(): | ||
| ui.update_submit_textarea( | ||
| "comment", | ||
| value="Thank you for your feedback. We appreciate your input!", | ||
| placeholder="", | ||
| label="Your Comment (Template Applied)", | ||
| ) | ||
|
|
||
| @render.text | ||
| def submitted_comment(): | ||
| if "comment" in input: | ||
| return f"Submitted: {input.comment()}" | ||
| return "No comment submitted yet." | ||
|
|
||
|
|
||
| app = App(app_ui, server) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| from shiny import reactive, render | ||
| from shiny.express import input, ui | ||
|
|
||
| ui.input_submit_textarea( | ||
| "comment", | ||
| label="Your Comment", | ||
| placeholder="Type your comment here...", | ||
| rows=2, | ||
| toolbar=[ | ||
| ui.input_action_button("clear", "Clear", class_="btn-sm btn-danger"), | ||
| ui.input_action_button("template", "Use Template", class_="btn-sm"), | ||
| ], | ||
| ) | ||
|
|
||
|
|
||
| @reactive.effect | ||
| @reactive.event(input.clear) | ||
| def _(): | ||
| ui.update_submit_textarea( | ||
| "comment", | ||
| value="", | ||
| placeholder="Type your comment here...", | ||
| ) | ||
|
|
||
|
|
||
| @reactive.effect | ||
| @reactive.event(input.template) | ||
| def _(): | ||
| ui.update_submit_textarea( | ||
| "comment", | ||
| value="Thank you for your feedback. We appreciate your input!", | ||
| placeholder="", | ||
| label="Your Comment (Template Applied)", | ||
| ) | ||
|
|
||
|
|
||
| @render.text | ||
| def submitted_comment(): | ||
| if "comment" in input: | ||
| return f"Submitted: {input.comment()}" | ||
| return "No comment submitted yet." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.