Skip to content

Commit

Permalink
Load CSS stylesheets on from aiidalab_widgets_base... import
Browse files Browse the repository at this point in the history
  • Loading branch information
edan-bainglass committed Aug 21, 2024
1 parent c961bc4 commit 3e0fd0a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
35 changes: 21 additions & 14 deletions aiidalab_widgets_base/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""Reusable widgets for AiiDAlab applications."""

from aiida.manage import get_profile

_WARNING_TEMPLATE = """
<div style="background-color: #f7f7f7; border: 2px solid #e0e0e0; padding: 20px; border-radius: 5px;">
<p style="font-size: 16px; font-weight: bold; color: #ff5733;">Warning:</p>
Expand All @@ -27,22 +25,31 @@ def is_running_in_jupyter():
return False


# load the default profile if no profile is loaded, and raise a deprecation warning
# this is a temporary solution to avoid breaking existing notebooks
# this will be removed in the next major release
if is_running_in_jupyter() and get_profile() is None:
# if no profile is loaded, load the default profile and raise a deprecation warning
from aiida import load_profile
if is_running_in_jupyter():
from aiida.manage import get_profile
from IPython.display import HTML, display

load_profile()
# load the default profile if no profile is loaded, and raise a deprecation warning
# this is a temporary solution to avoid breaking existing notebooks
# this will be removed in the next major release
if get_profile() is None:
# if no profile is loaded, load the default profile and raise a deprecation warning
from aiida import load_profile

load_profile()

profile = get_profile()
assert profile is not None, "Failed to load the default profile"

# raise a deprecation warning
warning = HTML(_WARNING_TEMPLATE.format(profile=profile.name, version="v3.0.0"))
display(warning)

from .static import styles
from .utils.loaders import load_css_stylesheet

profile = get_profile()
assert profile is not None, "Failed to load the default profile"
load_css_stylesheet(package=styles)

# raise a deprecation warning
warning = HTML(_WARNING_TEMPLATE.format(profile=profile.name, version="v3.0.0"))
display(warning)

from .computational_resources import (
ComputationalResourcesWidget,
Expand Down
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ docs =
pydata-sphinx-theme~=0.15
myst-nb~=1.1


[options.package_data]
aiidalab_widgets_base.static.styles = *.css

[bumpver]
current_version = "v2.3.0a1"
version_pattern = "vMAJOR.MINOR.PATCH[PYTAGNUM]"
Expand Down

0 comments on commit 3e0fd0a

Please sign in to comment.