Mercurial > libervia-web
view libervia/web/pages/_browser/components.py @ 1619:a2cd4222c702
browser: Updates for new design:
This patch add code to handle the new design for chat.
New bridge method are used to invite users to MUC or get list of occupants.
A new modules is used for components, with a first one for collapsible cards.
rel 457
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 12 Apr 2025 00:21:45 +0200 |
parents | |
children |
line wrap: on
line source
from browser import document def init_collapsible_cards(parent_elt=None) -> None: """Initialize cards which can be collapsed.""" parent = parent_elt or document cards = parent.select('.collapsible-card') for card in cards: header = card.select_one('.collapsible-header') content = card.select_one('.collapsible-content') content.style.maxHeight = 'none' natural_height = content.scrollHeight content.dataset.natural_height = natural_height header.bind('click', lambda ev: _toggle_card(ev)) def _toggle_card(event): """Collapse/expand the card.""" header = event.currentTarget card = header.closest('.collapsible-card') content = card.select_one('.collapsible-content') if content.style.maxHeight == '0px': # Expand content.style.maxHeight = f"{content.dataset.natural_height}px" header.classList.remove('collapsed') else: # Collapse content.style.maxHeight = '0px' header.classList.add('collapsed')