diff --git a/src/wagtail_heroicons/icons.py b/src/wagtail_heroicons/icons.py deleted file mode 100644 index 32767e8..0000000 --- a/src/wagtail_heroicons/icons.py +++ /dev/null @@ -1,41 +0,0 @@ -from __future__ import annotations - -from dataclasses import dataclass -from enum import Enum -from pathlib import Path -from typing import List - -from django.utils.functional import classproperty - -HeroiconList = List["Heroicon"] - - -class IconType(Enum): - OUTLINE = "outline" - SOLID = "solid" - - -@dataclass(order=True) -class Heroicon: - type: IconType - name: str - - @property - def path(self) -> Path: - return Path(f"{self.template_dir}/{self.type.value}/{self.name}.svg") - - @classproperty - def template_dir(self) -> Path: - return Path(__file__).parent / "templates" / "heroicons" - - @classmethod - def get_icons(cls) -> HeroiconList: - icons: HeroiconList = [] - - for icon_type in IconType: - icons.extend( - cls(icon_type, icon.stem) - for icon in Path(f"{cls.template_dir}/{icon_type.value}").glob("*.svg") - ) - - return icons diff --git a/src/wagtail_heroicons/wagtail_hooks.py b/src/wagtail_heroicons/wagtail_hooks.py index 7f6a3dd..a625cf4 100644 --- a/src/wagtail_heroicons/wagtail_hooks.py +++ b/src/wagtail_heroicons/wagtail_hooks.py @@ -1,15 +1,12 @@ from __future__ import annotations -try: - from wagtail import hooks -except ImportError: - from wagtail.core import hooks +from pathlib import Path -from .icons import Heroicon +from wagtail import hooks @hooks.register("register_icons") def register_icons(icons): - for icon in Heroicon.get_icons(): - icons.append(str(icon.path)) - return icons + template_dir = Path(__file__).parent / "templates" / "heroicons" + heroicons = [file.stem for file in template_dir.glob("*.svg")] + return icons + heroicons diff --git a/tests/test_icons.py b/tests/test_icons.py deleted file mode 100644 index 2be9f1b..0000000 --- a/tests/test_icons.py +++ /dev/null @@ -1,9 +0,0 @@ -from __future__ import annotations - -from wagtail_heroicons.icons import Heroicon - - -def test_get_icons(): - icons = Heroicon.get_icons() - - assert len(icons) != 0