-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
191 additions
and
215 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -1,37 +1,31 @@ | ||
from trame.widgets import quasar | ||
from trame.widgets import html | ||
from trame.app import get_server | ||
|
||
state = get_server().state | ||
card_count = 0 | ||
|
||
class CollapsibleCard(quasar.QCard): | ||
id_count = 0 | ||
|
||
def get_card_open_key(): | ||
global card_count | ||
card_count += 1 | ||
key = f"is_card_open_{card_count}" | ||
state[key] = True | ||
state.client_only(key) | ||
return key | ||
def __init__(self, name=None, collapsed=False, **kwargs): | ||
super().__init__(**kwargs) | ||
|
||
if name is None: | ||
CollapsibleCard.id_count += 1 | ||
name = f"is_card_open_{CollapsibleCard.id_count}" | ||
self.state.client_only(name) # keep it local if not provided | ||
|
||
def card(open_key=None): | ||
key = open_key if open_key is not None else get_card_open_key() | ||
with quasar.QCard(): | ||
with quasar.QCardSection(): | ||
with html.Div(classes="row items-center no-wrap"): | ||
title_slot = html.Div(classes="col") | ||
with html.Div(classes="col-auto"): | ||
quasar.QBtn( | ||
round=True, | ||
flat=True, | ||
dense=True, | ||
click=f"{key} = !{key}", | ||
icon=(f"{key} ? 'keyboard_arrow_up' : 'keyboard_arrow_down'",), | ||
) | ||
with quasar.QSlideTransition(): | ||
with html.Div(v_show=f"{key}"): | ||
content_slot = quasar.QCardSection() | ||
actions_slot = quasar.QCardActions(align="right") | ||
|
||
return title_slot, content_slot, actions_slot | ||
with self: | ||
with quasar.QCardSection(): | ||
with html.Div(classes="row items-center no-wrap"): | ||
self.slot_title = html.Div(classes="col") | ||
with html.Div(classes="col-auto"): | ||
quasar.QBtn( | ||
round=True, | ||
flat=True, | ||
dense=True, | ||
click=f"{name} = !{name}", | ||
icon=(f"{name} ? 'keyboard_arrow_up' : 'keyboard_arrow_down'",), | ||
) | ||
with quasar.QSlideTransition(): | ||
with html.Div(v_show=(name, not collapsed)): | ||
self.slot_content = quasar.QCardSection() | ||
self.slot_actions = quasar.QCardActions(align="right") |
Oops, something went wrong.