Skip to content

Commit

Permalink
Update documentation, remove Font Awesome 4 examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dyve committed Dec 31, 2023
1 parent d299c7f commit 99ad613
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ INSTALLED_APPS = (

DJANGO_ICONS = {
"ICONS": {
"edit": {"name": "far fa-pencil"},
"edit": {"name": "fa-solid fa-pencil"},
},
}
```
Expand All @@ -47,26 +47,30 @@ Render an icon in a Django template.

```djangotemplate
{% load icons %}
<!-- Include your icon library. This example uses Font Awesome 6 through cdnjs. -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
{% icon 'edit' %}
```

This will generate the FontAwesome 5 pencil icon in regular style.
This will generate the FontAwesome 6 pencil icon in regular style.

```html
<i class="far fa-pencil"></i>
<i class="fa-solid fa-pencil"></i>
```

Add extra classes and attributes to your predefined icon.

```djangotemplate
{% load icons %}
{% icon 'edit' extra_classes='fa-fw my-own-icon' title='Update' %}
{% icon 'edit' extra_classes='fa-2xs my-extra-class' title='Update' %}
```

These will be added to the HTML output.

```html
<i class="far fa-pencil fa-fw my-own-icon" title="Update"></i>
<i class="fa-solid fa-pencil fa-2xs my-extra-class" title="Update"></i>
```

## Requirements
Expand Down
5 changes: 3 additions & 2 deletions docs/renderers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ What is it?

A renderer converts your icon definition to HTML.

This package includes the default renderer `IconRenderer` which renders to an HTML element styled with CSS classes and other attributes, a method used by many icon libraries.
This package includes the default renderer `IconRenderer` which renders to an HTML element styled with CSS classes and other attributes.
This method is used by many icon libraries, such as Font Awesome.

You can use a customized renderer to support specific icon libraries or specific code.

This package includes renderers for FontAwesome 4, Bootstrap 3, Material Design and image sets.
This package includes specific renderers for Font Awesome 4, Bootstrap 3, Material Design and image sets.

The example app includes a custom SVG renderer.

Expand Down
10 changes: 4 additions & 6 deletions docs/settings.rst
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
Settings
========

In your Django ``settings.py`` file, make a dictionary for ``DJANGO_ICONS`` like this:
In your Django ``settings.py`` file, make a dictionary for ``DJANGO_ICONS``.

.. code:: Python
# Settings for django-icons
DJANGO_ICONS = {
"DEFAULTS": {
"renderer": "fontawesome4",
"renderer": "icon",
},
"RENDERERS": {
"fontawesome4": "FontAwesome4Renderer",
"bootstrap3": "Bootstrap3Renderer",
"custom-svg": "tests.app.renderers.CustomSvgRenderer",
},
"ICONS": {
Expand All @@ -28,15 +27,14 @@ In your Django ``settings.py`` file, make a dictionary for ``DJANGO_ICONS`` like
"renderer": "tests.app.renderers.CustomSvgRenderer",
},
"paperplane": {
"renderer": "tests.app.renderers.CustomSvgRenderer",
"renderer": "custom-svg",
}
},
}
The ``DJANGO_ICONS`` dictionary has 3 sections, all of which are optional.


DEFAULTS
--------

Expand Down
2 changes: 1 addition & 1 deletion src/django_icons/renderers/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def get_image_root(cls):
return "special-icons"
DJANGO_ICONS = {
"DEFAULTS": {"renderer": "fontawesome4", "attrs": {"aria-hidden": True}},
"DEFAULTS": {"attrs": {"aria-hidden": True}},
"RENDERERS": {
"image": "app.renderers.CustomImageRenderer",
},
Expand Down
2 changes: 1 addition & 1 deletion src/django_icons/templatetags/icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def icon_tag(name, *args, **kwargs):
renderer
The renderer to use for the icon
:default: The default renderer as per ``settings.py``, or ultimately `FontAwesome4Renderer`.
:default: The default renderer as per ``settings.py``, or ultimately `IconRenderer`.
**Usage**::
Expand Down

0 comments on commit 99ad613

Please sign in to comment.