Compare commits

..

5 Commits

Author SHA1 Message Date
Ariel Rin
1478588016 Merge branch 'add-js-type' into 'master'
[ADD] `js_type` parameter to allow JS modules to be loaded

See merge request allianceauth/allianceauth!1664
2024-12-04 11:24:21 +00:00
Ariel Rin
a16eb4b7f7 Merge branch 'image-overflow-fix' into 'master'
[FIX] Prevent images from overflowing their parent element

See merge request allianceauth/allianceauth!1665
2024-12-04 11:23:38 +00:00
Peter Pfeufer
cef2e86ea1
[FIX] Prevent images from overflowing their parent element 2024-11-26 22:28:35 +01:00
Peter Pfeufer
50681b023b
[CHANGE] Move the if inside the script tag
Makes the code better readable and maintainable.
2024-11-23 01:55:04 +01:00
Peter Pfeufer
2822775fb8
[ADD] js_type parameter to allow JS modules to be loaded 2024-11-22 15:01:32 +01:00
3 changed files with 33 additions and 9 deletions

View File

@ -13,6 +13,15 @@
} }
} }
/* Image overflow fix
------------------------------------------------------------------------------------- */
@media all {
img {
max-width: 100%;
height: auto;
}
}
/* Side Navigation /* Side Navigation
------------------------------------------------------------------------------------- */ ------------------------------------------------------------------------------------- */
@media all { @media all {

View File

@ -8,14 +8,16 @@ class ThemeHook:
""" """
def __init__(self, def __init__(self,
name: str, name: str,
description: str, description: str,
css: List[dict], css: List[dict],
js: List[dict], js: List[dict],
css_template: Optional[str] = None, css_template: Optional[str] = None,
js_template: Optional[str] = None, js_template: Optional[str] = None,
html_tags: Optional[Union[dict, str]] = None, js_type: Optional[str] = None,
header_padding: Optional[str] = "4em"): html_tags: Optional[Union[dict, str]] = None,
header_padding: Optional[str] = "4em"
):
""" """
:param name: Theme python name :param name: Theme python name
:type name: str :type name: str
@ -29,11 +31,14 @@ class ThemeHook:
:type css_template: Optional[str], optional :type css_template: Optional[str], optional
:param js_template: _description_, defaults to None :param js_template: _description_, defaults to None
:type js_template: Optional[str], optional :type js_template: Optional[str], optional
:param js_type: The type of the JS (e.g.: 'module'), defaults to None
:type js_type: Optional[str], optional
:param html_tags: Attributes added to the `<html>` tag, defaults to None :param html_tags: Attributes added to the `<html>` tag, defaults to None
:type html_tags: Optional[dict|str], optional :type html_tags: Optional[dict|str], optional
:param header_padding: Top padding, defaults to "4em" :param header_padding: Top padding, defaults to "4em"
:type header_padding: Optional[str], optional :type header_padding: Optional[str], optional
""" """
self.name = name self.name = name
self.description = description self.description = description
@ -45,11 +50,15 @@ class ThemeHook:
self.css_template = css_template self.css_template = css_template
self.js_template = js_template self.js_template = js_template
# Define the JS type (e.g.: 'module')
self.js_type = js_type
self.html_tags = ( self.html_tags = (
" ".join([f"{key}={value}" for key, value in html_tags.items()]) " ".join([f"{key}={value}" for key, value in html_tags.items()])
if isinstance(html_tags, dict) if isinstance(html_tags, dict)
else html_tags else html_tags
) )
self.header_padding = header_padding self.header_padding = header_padding
def get_name(self): def get_name(self):
return f"{self.__class__.__module__}.{self.__class__.__name__}" return f"{self.__class__.__module__}.{self.__class__.__name__}"

View File

@ -4,7 +4,13 @@
{% include theme.js_template %} {% include theme.js_template %}
{% else %} {% else %}
{% for x in theme.js %} {% for x in theme.js %}
<script src="{{ x.url }}" integrity="{{ x.integrity }}" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script
{% if x.js_type %}type="{{ x.js_type }}"{% endif %}
src="{{ x.url }}"
integrity="{{ x.integrity }}"
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
<!-- allianceauth.theme.{{ theme.name }} JS Ends--> <!-- allianceauth.theme.{{ theme.name }} JS Ends-->