Skip to content

Commit

Permalink
chore: use icon fns from jinjarope
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Oct 29, 2024
1 parent b43ebb8 commit 6044968
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 250 deletions.
6 changes: 3 additions & 3 deletions mknodes/basenodes/mkbinaryimage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

from typing import Any, Literal, Self, TYPE_CHECKING

from jinjarope import textfilters
from jinjarope import textfilters, iconfilters

from mknodes.basenodes import mkimage
from mknodes.utils import icons, log
from mknodes.utils import log

if TYPE_CHECKING:
from mknodes.info import linkprovider
Expand Down Expand Up @@ -75,7 +75,7 @@ def for_icon(cls, icon: str, **kwargs: Any) -> Self:
icon: Icon to get a MkBinaryImage for (example: material/file-image)
kwargs: Keyword arguments passed to constructor
"""
content = icons.get_icon_svg(icon)
content = iconfilters.get_icon_svg(icon)
path = f"{textfilters.slugify(icon)}.svg"
return cls(data=content, path=path, **kwargs)

Expand Down
9 changes: 5 additions & 4 deletions mknodes/basenodes/mkicon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

from typing import Any

from jinjarope import iconfilters
from mknodes.basenodes import mknode
from mknodes.utils import icons, log
from mknodes.utils import log


logger = log.get_logger(__name__)
Expand All @@ -23,8 +24,8 @@ def __init__(
color: str | None = None,
height: str | int | None = None,
width: str | int | None = None,
flip: icons.Flip | None = None,
rotate: icons.Rotation | None = None,
flip: iconfilters.Flip | None = None,
rotate: iconfilters.Rotation | None = None,
box: bool | None = None,
**kwargs: Any,
):
Expand Down Expand Up @@ -63,7 +64,7 @@ def svg(self) -> str:
import requests.exceptions

try:
return icons.get_icon_svg(
return iconfilters.get_icon_svg(
self.icon_name,
color=self.color,
height=self.height,
Expand Down
10 changes: 0 additions & 10 deletions mknodes/resources/filters.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,6 @@ template = """
"""


[filters.get_icon_svg]
fn = "mknodes.utils.icons.get_icon_svg"
group = "icon"

[filters.get_icon_svg.examples.class]
template = """
{{ "mdi:file" | get_icon_svg }}
"""


[filters.get_emoji_slug]
fn = "mknodes.utils.icons.get_emoji_slug"
group = "icon"
Expand Down
Binary file removed mknodes/resources/icons.json.gzip
Binary file not shown.
5 changes: 3 additions & 2 deletions mknodes/theme/materialtheme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

from typing import Any, Literal, TYPE_CHECKING

from jinjarope import iconfilters
from mknodes.theme import colortheme, theme
from mknodes.theme.materialtheme import palette
from mknodes.utils import color as col, icons, log, reprhelpers
from mknodes.utils import color as col, log, reprhelpers

if TYPE_CHECKING:
from mknodes.data import datatypes
Expand Down Expand Up @@ -283,7 +284,7 @@ def add_status_icon(
icon: Iconify icon name
description: Optional status description (used for tooltip)
"""
data = icons.get_icon_svg(icon)
data = iconfilters.get_icon_svg(icon)
self.status_icons[name] = StatusIcon(name, data, description)

def add_tag(
Expand Down
5 changes: 3 additions & 2 deletions mknodes/theme/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
from typing import TYPE_CHECKING, Any

import jinjarope
from jinjarope import iconfilters

from mknodes.data import admonition, datatypes
from mknodes.info import contexts
from mknodes.pages import templateblocks, templateregistry
from mknodes.utils import color, icons, log, reprhelpers, resources
from mknodes.utils import color, log, reprhelpers, resources


if TYPE_CHECKING:
Expand Down Expand Up @@ -99,7 +100,7 @@ def add_admonition_type(
font_col_str = str(color.Color(font_color or (255, 255, 255)))
adm = admonition.AdmonitionType(
name=name,
svg=icons.get_icon_svg(icon) if not icon.startswith("<") else icon,
svg=iconfilters.get_icon_svg(icon) if not icon.startswith("<") else icon,
header_color=header_col_str,
icon_color=icon_col_str,
border_color=border_col_str,
Expand Down
Loading

0 comments on commit 6044968

Please sign in to comment.