wagtail-svg-icons


Namewagtail-svg-icons JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/LilJack118/wagtail_icons
Summary
upload_time2022-08-18 17:45:51
maintainer
docs_urlNone
authorLilJack118
requires_python
license
keywords wagtail django
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Wagtail Icons
Wagtail Icons is package that allows you to add icons (in svg format) on your page, divide them on groups, resize and style displayed icons.

![](images/wagtail_icons.gif)
## Install

```
pip install wagtail-svg-icons
```

Then add `wagtail_icons` and `generic_chooser` to your installed apps:

```
INSTALLED_APPS = [
    ...
    'wagtail_icons',
	'generic_chooser',
	...
]
```

## Usage

#### IconsField, IconsChooserPanel and IconsChooserBlock
**IconsField** - Subclass of [ForeignKey](https://docs.djangoproject.com/en/4.1/ref/models/fields/#foreignkey "ForeignKey") Field with many-to-one relationship with Icon model. Have all arguments of [ForeignKey](https://docs.djangoproject.com/en/4.1/ref/models/fields/#foreignkey "ForeignKey") with defaults:
- on_delete=models.SET_NULL
- null=True
- blank=True

**IconsChooserPanel** - Subclass of [FieldPanel](https://docs.wagtail.org/en/stable/reference/pages/panels.html#fieldpanel "FieldPanel")

Extra (optional) argument:
- group - slug of the group from which icons can be choosen. If not specified all available icons will be displayed.

**IconsChooserBlock** - Subclass of [ChooserBlock](https://github.com/wagtail/wagtail/blob/main/wagtail/blocks/field_block.py#L750 "ChooserBlock")

Extra (optional) argument:
- group - slug of the group from which icons can be choosen. If not specified all available icons will be displayed.

```python
from wagtail_icons.edit_handlers import IconsChooserPanel
from wagtail_icons.fields import IconsField
from wagtail_icons.blocks import IconsChooserBlock

from wagtail.admin.edit_handlers import StreamFieldPanel
try:
    from wagtail.fields import StreamField
    from wagtail.models import Page
    from wagtail import blocks
except ImportError:
    # wagtail version under 3.0
    from wagtail.core.fields import StreamField
    from wagtail.core import blocks
    from wagtail.core.models import Page


class HomePage(Page):
    icon = IconsField()

    body = StreamField([
        ('block_icon', IconsChooserBlock(group='some_group', required=False)),
    ], blank=True)


    content_panels = Page.content_panels + [
        IconsChooserPanel('icon', group='another_group'),
        StreamFieldPanel('body'),
    ]
```

#### How to use Icons in templates
The 'icon' tag inserts svg element into page, setting its size and custom_class (if specified). To use 'icon' tag load 'wagtail_icons_tags'
```
{% load wagtail_icons_tags %}
```
Icon tag required arguments:
- icon - instance of Icon model

Icon tag optional arguments:
- size - icon resize given in format "HEIGHTxWIDTH"
- class_name - icon class name that can be used to css styling
- color - custom icon color

**Example usage**
```
<!-- Display original size icon -->
{% icon self.icon %}

<!-- Display icon scaled to width 200 and height 250 -->
{% icon self.icon size='250x200' class_name='filter-green' %}

<!-- Display icon scaled to width 200 and height 200 and with class 'my-icon'-->
{% icon self.icon size='200x200' class_name='my-icon' %}

<!-- Display icon scaled to width 200 and height 200 and in color #81b29a-->
{% icon self.icon size='200x200' class_name='my-icon'  color='#81b29a' %}
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/LilJack118/wagtail_icons",
    "name": "wagtail-svg-icons",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "wagtail django",
    "author": "LilJack118",
    "author_email": "jakub@kachange.com",
    "download_url": "https://files.pythonhosted.org/packages/63/13/2ba6ec71c30c9d7af59365ff0347546a80313d5c39c61d4129d97d39f9a0/wagtail-svg-icons-0.0.2.tar.gz",
    "platform": null,
    "description": "# Wagtail Icons\nWagtail Icons is package that allows you to add icons (in svg format) on your page, divide them on groups, resize and style displayed icons.\n\n![](images/wagtail_icons.gif)\n## Install\n\n```\npip install wagtail-svg-icons\n```\n\nThen add `wagtail_icons` and `generic_chooser` to your installed apps:\n\n```\nINSTALLED_APPS = [\n    ...\n    'wagtail_icons',\n\t'generic_chooser',\n\t...\n]\n```\n\n## Usage\n\n#### IconsField, IconsChooserPanel and IconsChooserBlock\n**IconsField** - Subclass of [ForeignKey](https://docs.djangoproject.com/en/4.1/ref/models/fields/#foreignkey \"ForeignKey\") Field with many-to-one relationship with Icon model. Have all arguments of [ForeignKey](https://docs.djangoproject.com/en/4.1/ref/models/fields/#foreignkey \"ForeignKey\") with defaults:\n- on_delete=models.SET_NULL\n- null=True\n- blank=True\n\n**IconsChooserPanel** - Subclass of [FieldPanel](https://docs.wagtail.org/en/stable/reference/pages/panels.html#fieldpanel \"FieldPanel\")\n\nExtra (optional) argument:\n- group - slug of the group from which icons can be choosen. If not specified all available icons will be displayed.\n\n**IconsChooserBlock** - Subclass of [ChooserBlock](https://github.com/wagtail/wagtail/blob/main/wagtail/blocks/field_block.py#L750 \"ChooserBlock\")\n\nExtra (optional) argument:\n- group - slug of the group from which icons can be choosen. If not specified all available icons will be displayed.\n\n```python\nfrom wagtail_icons.edit_handlers import IconsChooserPanel\nfrom wagtail_icons.fields import IconsField\nfrom wagtail_icons.blocks import IconsChooserBlock\n\nfrom wagtail.admin.edit_handlers import StreamFieldPanel\ntry:\n    from wagtail.fields import StreamField\n    from wagtail.models import Page\n    from wagtail import blocks\nexcept ImportError:\n    # wagtail version under 3.0\n    from wagtail.core.fields import StreamField\n    from wagtail.core import blocks\n    from wagtail.core.models import Page\n\n\nclass HomePage(Page):\n    icon = IconsField()\n\n    body = StreamField([\n        ('block_icon', IconsChooserBlock(group='some_group', required=False)),\n    ], blank=True)\n\n\n    content_panels = Page.content_panels + [\n        IconsChooserPanel('icon', group='another_group'),\n        StreamFieldPanel('body'),\n    ]\n```\n\n#### How to use Icons in templates\nThe 'icon' tag inserts svg element into page, setting its size and custom_class (if specified). To use 'icon' tag load 'wagtail_icons_tags'\n```\n{% load wagtail_icons_tags %}\n```\nIcon tag required arguments:\n- icon - instance of Icon model\n\nIcon tag optional arguments:\n- size - icon resize given in format \"HEIGHTxWIDTH\"\n- class_name - icon class name that can be used to css styling\n- color - custom icon color\n\n**Example usage**\n```\n<!-- Display original size icon -->\n{% icon self.icon %}\n\n<!-- Display icon scaled to width 200 and height 250 -->\n{% icon self.icon size='250x200' class_name='filter-green' %}\n\n<!-- Display icon scaled to width 200 and height 200 and with class 'my-icon'-->\n{% icon self.icon size='200x200' class_name='my-icon' %}\n\n<!-- Display icon scaled to width 200 and height 200 and in color #81b29a-->\n{% icon self.icon size='200x200' class_name='my-icon'  color='#81b29a' %}\n```\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "",
    "version": "0.0.2",
    "split_keywords": [
        "wagtail",
        "django"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "e30c85240c9f38b5daba76b80274d091",
                "sha256": "583480855f395f6231e6a8d3b0afffa80d98110007f234cf754b875e8de6b2ee"
            },
            "downloads": -1,
            "filename": "wagtail_svg_icons-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e30c85240c9f38b5daba76b80274d091",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 41259,
            "upload_time": "2022-08-18T17:45:50",
            "upload_time_iso_8601": "2022-08-18T17:45:50.113357Z",
            "url": "https://files.pythonhosted.org/packages/92/ce/3577e32a79007a2f34db732838b57624450d63389c3e81dac64578bf50fd/wagtail_svg_icons-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "70c7cb2694f4d49202bbb6f8c7d7461b",
                "sha256": "d5765a1367336bcb02221a140b3383682b8ba3d36d0c56e5a336b56233d405d4"
            },
            "downloads": -1,
            "filename": "wagtail-svg-icons-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "70c7cb2694f4d49202bbb6f8c7d7461b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 27727,
            "upload_time": "2022-08-18T17:45:51",
            "upload_time_iso_8601": "2022-08-18T17:45:51.855923Z",
            "url": "https://files.pythonhosted.org/packages/63/13/2ba6ec71c30c9d7af59365ff0347546a80313d5c39c61d4129d97d39f9a0/wagtail-svg-icons-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-08-18 17:45:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "LilJack118",
    "github_project": "wagtail_icons",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "wagtail-svg-icons"
}
        
Elapsed time: 0.36030s