Skip to content
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

feat: accordion #1075

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft

Conversation

ethanalvizo
Copy link
Contributor

@ethanalvizo ethanalvizo commented Jan 6, 2025

Closes #18136

Wait for ui.disclosure to merge

@ethanalvizo ethanalvizo requested a review from mofojed January 6, 2025 08:12
@ethanalvizo ethanalvizo self-assigned this Jan 6, 2025
@ethanalvizo ethanalvizo requested a review from mofojed January 17, 2025 05:33
Comment on lines +23 to +37
@ui.component
def ui_accordion_event():
expanded_keys, set_expanded_keys = ui.use_state([])

def handle_expanded_keys_change(e):
set_expanded_keys(e)
print("Expanded key changed")

return ui.accordion(
ui.disclosure(title="FAQ #1", panel="Answer", id="a"),
ui.disclosure(title="FAQ #2", panel="Answer", id="b"),
expanded_keys=expanded_keys,
on_expanded_change=lambda k: set_expanded_keys(k),
)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of printing to console, we should just show it underneath. e.g.

Suggested change
@ui.component
def ui_accordion_event():
expanded_keys, set_expanded_keys = ui.use_state([])
def handle_expanded_keys_change(e):
set_expanded_keys(e)
print("Expanded key changed")
return ui.accordion(
ui.disclosure(title="FAQ #1", panel="Answer", id="a"),
ui.disclosure(title="FAQ #2", panel="Answer", id="b"),
expanded_keys=expanded_keys,
on_expanded_change=lambda k: set_expanded_keys(k),
)
@ui.component
def ui_accordion_event():
expanded_keys, set_expanded_keys = ui.use_state([])
return ui.view(
ui.accordion(
ui.disclosure(title="FAQ #1", panel="Answer", id="a"),
ui.disclosure(title="FAQ #2", panel="Answer", id="b"),
expanded_keys=expanded_keys,
on_expanded_change=set_expanded_keys,
),
ui.heading("Currently expanded: ", expanded_keys)
)

Also we should have better/different content for each, and the id should match the disclosure titles.

)


my_accordion_event = ui_accordion_event()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should an example with allows_multiple_expanded as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants