Skip to content

Commit

Permalink
Fix priority of Alert pane (#1422)
Browse files Browse the repository at this point in the history
* Fix priority of Alert pane

* Fixed flakes

* Fixed Alert API

* Fix kwargs of Alert
  • Loading branch information
philippjfr authored Jun 18, 2020
1 parent 626ac27 commit e8eeda7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion panel/pane/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from __future__ import absolute_import, division, unicode_literals

from .ace import Ace # noqa
from .alert import Alert
from .alert import Alert # noqa
from .base import PaneBase, Pane, panel # noqa
from .equation import LaTeX # noqa
from .deckgl import DeckGL # noqa
Expand Down
27 changes: 11 additions & 16 deletions panel/pane/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,17 @@ class Alert(Markdown):

alert_type = param.ObjectSelector("primary", objects=ALERT_TYPES)

def __init__(self, text: str, **kwargs):
"""An Primary Alert that renders Markdown
- CSS Styling is done via the classes `alert` and `alert-primary`.
- sizing_mode is set to `stretch_width` by default
Arguments:
text {str} -- Some MarkDown text
"""
if "margin" not in kwargs:
kwargs["margin"] = (0, 0, 25, 0)
if "sizing_mode" not in kwargs:
kwargs["sizing_mode"] = "stretch_width"

super().__init__(text, **kwargs)

@classmethod
def applies(cls, obj):
priority = Markdown.applies(obj)
return 0 if priority else False

def __init__(self, object=None, **params):
if "margin" not in params:
params["margin"] = (0, 0, 25, 0)
if "sizing_mode" not in params:
params["sizing_mode"] = "stretch_width"
super().__init__(object, **params)
self._set_css_classes()

@param.depends("alert_type", watch=True)
Expand Down
5 changes: 3 additions & 2 deletions panel/tests/pane/test_alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pytest

import panel as pn

from panel.pane import Alert
from panel.pane.alert import ALERT_TYPES

Expand All @@ -28,7 +29,7 @@ def test_existing_css_classes():
assert set(alert.css_classes) == {"alert", f"alert-{Alert.param.alert_type.default}", "important"}

alert.alert_type="info"
assert set(alert.css_classes) == {"alert", f"alert-info", "important"}
assert set(alert.css_classes) == {"alert", "alert-info", "important"}


def test_all_view():
Expand All @@ -48,4 +49,4 @@ def test_all_view():


if __name__.startswith("bk"):
test_all_view().servable()
test_all_view().servable()

0 comments on commit e8eeda7

Please sign in to comment.