Skip to content

Commit

Permalink
Allow providing additional stylesheets in card_params (#6242)
Browse files Browse the repository at this point in the history
* Allow providing additional stylesheets in card_params

* Do not override stylesheets
  • Loading branch information
philippjfr committed Jan 19, 2024
1 parent b206b45 commit 931b957
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
15 changes: 12 additions & 3 deletions panel/chat/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down Expand Up @@ -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):
Expand Down
1 change: 0 additions & 1 deletion panel/chat/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 931b957

Please sign in to comment.