Skip to content

Commit

Permalink
chore: css work
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Sep 22, 2023
1 parent 577e3bf commit 0d72d09
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
26 changes: 13 additions & 13 deletions mknodes/resources/material_css.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
content_area_width, classic_admonition_style, show_annotation_numbers, default_icons, color_theme*/
:root {
{% for admonition in admonitions %}
--md-admonition-icon--note: url('data:image/svg+xml;charset=utf-8,{{ admonition.svg }}');
--md-admonition-icon--{{ admonition.name }}: url('data:image/svg+xml;charset=utf-8,{{ admonition.svg }}');
{% endfor %}
{% for status_icon in status_icons %}
--md-status--encrypted: url('data:image/svg+xml;charset=utf-8,{ {status_icon.svg }}');
Expand All @@ -28,26 +28,26 @@ content_area_width, classic_admonition_style, show_annotation_numbers, default_i
{% endif %}
}
{% for admonition in admonitions %}
.md-typeset .admonition.{{ admonition.type }},
.md-typeset details.{{ admonition.type }} {
.md-typeset .admonition.{{ admonition.name }},
.md-typeset details.{{ admonition.name }} {
border-color: {{ admonition.border_color }};
}
.md-typeset .admonition.{{ admonition.type }}:focus-within,
.md-typeset details.{{ admonition.type }}:focus-within {
.md-typeset .admonition.{{ admonition.name }}:focus-within,
.md-typeset details.{{ admonition.name }}:focus-within {
box-shadow: 0 0 0 0.2rem {{ admonition.header_color }}; ## #00c8531a
}
.md-typeset .{{ admonition.type }} > .admonition-title,
.md-typeset .{{ admonition.type }} > summary {
.md-typeset .{{ admonition.name }} > .admonition-title,
.md-typeset .{{ admonition.name }} > summary {
background-color: {{ admonition.header_color }};
}
.md-typeset .{{ admonition.type }} > .admonition-title:before,
.md-typeset .{{ admonition.type }} > summary:before {
.md-typeset .{{ admonition.name }} > .admonition-title:before,
.md-typeset .{{ admonition.name }} > summary:before {
background-color: {{admonition.icon_color}};
-webkit-mask-image: var(--md-admonition-icon--{{ admonition.type }});
mask-image: var(--md-admonition-icon--{{ admonition.type }});
-webkit-mask-image: var(--md-admonition-icon--{{ admonition.name }});
mask-image: var(--md-admonition-icon--{{ admonition.name }});
}
.md-typeset .{{ admonition.type }} > .admonition-title:after,
.md-typeset .{{ admonition.type }} > summary:after {
.md-typeset .{{ admonition.name }} > .admonition-title:after,
.md-typeset .{{ admonition.name }} > summary:after {
color: {{ admonition.icon_color }}; ## #00c853
}

Expand Down
19 changes: 12 additions & 7 deletions mknodes/theme/materialtheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from mknodes.data import datatypes
from mknodes.theme import mkblog, theme
from mknodes.theme.material import palette
from mknodes.utils import helpers, log, reprhelpers
from mknodes.utils import helpers, log, pathhelpers, reprhelpers


logger = log.get_logger(__name__)
Expand Down Expand Up @@ -75,6 +75,7 @@ def build_badge(icon: str, text: str = "", typ: str = ""):

@dataclasses.dataclass
class AdmonitionType:
name: str
svg: str
header_color: str
icon_color: str
Expand Down Expand Up @@ -238,15 +239,17 @@ def _text_color(self):
def add_admonition_type(
self,
name: str,
data: str,
material_icon: str,
header_color: datatypes.ColorType,
icon_color: datatypes.ColorType | None = None,
border_color: datatypes.ColorType | None = None,
):
header_color_str = helpers.get_color_str(header_color)
icon_color_str = helpers.get_color_str(icon_color or (255, 255, 255))
border_color_str = helpers.get_color_str(border_color or (255, 255, 255))
adm = AdmonitionType(data, header_color_str, icon_color_str, border_color_str)
header_col_str = helpers.get_color_str(header_color)
icon_col_str = helpers.get_color_str(icon_color or (255, 255, 255))
border_col_str = helpers.get_color_str(border_color or (255, 255, 255))
icon = pathhelpers.get_material_icon_path(material_icon)
data = icon.read_text()
adm = AdmonitionType(name, data, header_col_str, icon_col_str, border_col_str)
self.admonitions.append(adm)

def set_primary_foreground_color(
Expand All @@ -272,7 +275,9 @@ def set_primary_foreground_color(
def set_default_icon(self, icon_type: IconTypeStr, data: str):
self.default_icons[icon_type] = data

def add_status_icon(self, name: str, data: str):
def add_status_icon(self, name: str, material_icon: str):
icon = pathhelpers.get_material_icon_path(material_icon)
data = icon.read_text()
self.status_icons.append(StatusIcon(name, data))

def adapt_extensions(self, extensions: MutableMapping[str, dict]):
Expand Down

0 comments on commit 0d72d09

Please sign in to comment.