From 931b957aad8bdd4182f3b35a7884a966ea44fdaf Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Fri, 19 Jan 2024 13:53:04 +0100 Subject: [PATCH] Allow providing additional stylesheets in card_params (#6242) * Allow providing additional stylesheets in card_params * Do not override stylesheets --- panel/chat/feed.py | 15 ++++++++++++--- panel/chat/interface.py | 1 - 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/panel/chat/feed.py b/panel/chat/feed.py index 0451705992..5ef2a41b32 100644 --- a/panel/chat/feed.py +++ b/panel/chat/feed.py @@ -254,6 +254,11 @@ def __init__(self, *objects, **params): **linked_params ) card_params = linked_params.copy() + card_stylesheets = ( + self._stylesheets + + self.param.stylesheets.rx() + + self.param.card_params.rx().get('stylesheets', []) + ) card_params.update( margin=self.param.margin, align=self.param.align, @@ -267,9 +272,11 @@ def __init__(self, *objects, **params): min_height=self.param.min_height, title_css_classes=["chat-feed-title"], styles={"padding": "0px"}, - stylesheets=self._stylesheets + self.param.stylesheets.rx(), + stylesheets=card_stylesheets ) - card_params.update(self.card_params) + card_overrides = self.card_params.copy() + card_overrides.pop('stylesheets', None) + card_params.update(card_overrides) self.link(self._chat_log, objects='objects', bidirectional=True) # we have a card for the title self._card = Card( @@ -303,7 +310,9 @@ def _cleanup(self, root: Model | None = None) -> None: @param.depends("card_params", watch=True) def _update_card_params(self): - self._card.param.update(**self.card_params) + card_params = self.card_params.copy() + card_params.pop('stylesheets', None) + self._card.param.update(**card_params) @param.depends("placeholder_text", watch=True, on_init=True) def _update_placeholder(self): diff --git a/panel/chat/interface.py b/panel/chat/interface.py index 8642dc4e25..a612a53be9 100644 --- a/panel/chat/interface.py +++ b/panel/chat/interface.py @@ -164,7 +164,6 @@ def __init__(self, *objects, **params): self._card.param.update( objects=self._card.objects + [self._input_container], css_classes=["chat-interface"], - stylesheets=self._stylesheets, ) def _link_disabled_loading(self, obj: Viewable):