mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-09 12:30:15 +02:00
Merge branch 'theme-html-tags' into 'master'
[ADD] Theme html tags See merge request allianceauth/allianceauth!1642
This commit is contained in:
commit
de9d2b39a6
@ -27,6 +27,7 @@ class BootstrapThemeHook(ThemeHook):
|
||||
self,
|
||||
"Bootstrap",
|
||||
"Powerful, extensible, and feature-packed frontend toolkit.",
|
||||
html_tags={"data-theme": "bootstrap"},
|
||||
css=CSS_STATICS,
|
||||
js=JS_STATICS,
|
||||
header_padding="3.5em"
|
||||
@ -44,9 +45,9 @@ class BootstrapDarkThemeHook(ThemeHook):
|
||||
self,
|
||||
"Bootstrap Dark",
|
||||
"Powerful, extensible, and feature-packed frontend toolkit.",
|
||||
html_tags={"data-theme": "bootstrap-dark"},
|
||||
css=CSS_STATICS,
|
||||
js=JS_STATICS,
|
||||
html_tags="data-bs-theme=dark",
|
||||
header_padding="3.5em"
|
||||
)
|
||||
|
||||
|
@ -13,6 +13,7 @@ class DarklyThemeHook(ThemeHook):
|
||||
self,
|
||||
"Darkly",
|
||||
"Flatly in night mode!",
|
||||
html_tags={"data-theme": "darkly"},
|
||||
css=[{
|
||||
"url": "https://cdnjs.cloudflare.com/ajax/libs/bootswatch/5.3.3/darkly/bootstrap.min.css",
|
||||
"integrity": "sha512-HDszXqSUU0om4Yj5dZOUNmtwXGWDa5ppESlX98yzbBS+z+3HQ8a/7kcdI1dv+jKq+1V5b01eYurE7+yFjw6Rdg=="
|
||||
|
@ -13,6 +13,7 @@ class FlatlyThemeHook(ThemeHook):
|
||||
self,
|
||||
"Flatly",
|
||||
"Flat and modern!",
|
||||
html_tags={"data-theme": "flatly"},
|
||||
css=[{
|
||||
"url": "https://cdnjs.cloudflare.com/ajax/libs/bootswatch/5.3.3/flatly/bootstrap.min.css",
|
||||
"integrity": "sha512-qoT4KwnRpAQ9uczPsw7GunsNmhRnYwSlE2KRCUPRQHSkDuLulCtDXuC2P/P6oqr3M5hoGagUG9pgHDPkD2zCDA=="
|
||||
|
@ -1,10 +1,10 @@
|
||||
from typing import List, Optional
|
||||
from typing import List, Optional, Union
|
||||
|
||||
|
||||
class ThemeHook:
|
||||
"""
|
||||
Theme hook for injecting a Bootstrap 5 Theme and associated JS into alliance auth.
|
||||
these can be local or CDN delivered
|
||||
Theme hook for injecting a Bootstrap 5 Theme and associated JS into alliance auth.
|
||||
These can be local or CDN delivered.
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
@ -14,7 +14,7 @@ class ThemeHook:
|
||||
js: List[dict],
|
||||
css_template: Optional[str] = None,
|
||||
js_template: Optional[str] = None,
|
||||
html_tags: Optional[str] = "",
|
||||
html_tags: Optional[Union[dict, str]] = None,
|
||||
header_padding: Optional[str] = "4em"):
|
||||
"""
|
||||
:param name: Theme python name
|
||||
@ -29,6 +29,10 @@ class ThemeHook:
|
||||
:type css_template: Optional[str], optional
|
||||
:param js_template: _description_, defaults to None
|
||||
:type js_template: Optional[str], optional
|
||||
:param html_tags: Attributes added to the `<html>` tag, defaults to None
|
||||
:type html_tags: Optional[dict|str], optional
|
||||
:param header_padding: Top padding, defaults to "4em"
|
||||
:type header_padding: Optional[str], optional
|
||||
"""
|
||||
self.name = name
|
||||
self.description = description
|
||||
@ -41,7 +45,11 @@ class ThemeHook:
|
||||
self.css_template = css_template
|
||||
self.js_template = js_template
|
||||
|
||||
self.html_tags = html_tags
|
||||
self.html_tags = (
|
||||
" ".join([f"{key}={value}" for key, value in html_tags.items()])
|
||||
if isinstance(html_tags, dict)
|
||||
else html_tags
|
||||
)
|
||||
self.header_padding = header_padding
|
||||
def get_name(self):
|
||||
return f"{self.__class__.__module__}.{self.__class__.__name__}"
|
||||
|
@ -13,6 +13,7 @@ class MateriaThemeHook(ThemeHook):
|
||||
self,
|
||||
"Materia",
|
||||
"Material is the metaphor",
|
||||
html_tags={"data-theme": "materia"},
|
||||
css=[{
|
||||
"url": "https://cdnjs.cloudflare.com/ajax/libs/bootswatch/5.3.3/materia/bootstrap.min.css",
|
||||
"integrity": "sha512-2S9Do+uTmZmmJpdmAcOKdUrK/YslcvAuRfIF2ws8+BW9AvZXMRZM+o8Wq+PZrfISD6ZlIaeCWWZAdeprXIoYuQ=="
|
||||
|
Loading…
x
Reference in New Issue
Block a user