Skip to main content

Add FontAwesome icons to StreamField.

Project description

https://img.shields.io/pypi/l/wagtailfontawesome.svg

Add FontAwesome 4.7 icons to your Wagtail project.

Screenshot

Install

pip install wagtailfontawesome

Then add wagtailfontawesome to your installed apps.

Usage

StreamField

Add FontAwesome icons to StreamField the regular way, just set icon=”fa-something”. Reference the full list.

For example, using fa-exclamation-triangle on a block that’s a class:

class NoticeBlock(StructBlock):
    message = RichTextBlock()
    indicator = ChoiceBlock()

    class Meta:
        icon = 'fa-exclamation-triangle'

The same block, but inline:

notice = StructBlock([
  ('message', RichTextBlock()),
  ('indicator', ChoiceBlock())
], icon='fa-exclamation-triangle')

Using IconBlock

Wagtail FontAwesome contains a dropdown chooser you can use to select a block from the available options. For example,

from wagtailfontawesome.blocks import IconBlock

class CardBlock(StructBlock):
    icon = IconBlock()
    title = CharBlock()

You are responsible for including the FontAwesome CSS yourself somewhere on the page. See the section “On the front-end” below for a way to do that with Wagtail FontAwesome.

ModelAdmin

ModelAdmin is supported if you’re using Wagtail 1.5 or above. Similar to StreamField, just set icon=”fa-something” on your menu item.

Other parts of the admin

You can include icons anywhere in the admin with:

<i class="icon icon-fa-something"></i>

In Wagtail 1.3.x and below you can only use icons on the page editor screen.

On the front-end

You can also include the CSS on the front end, and follow FontAwesome’s documentation.

{% load wagtailfontawesome %}

{% fontawesome_css %}

This will generate equivalent markup to:

<link rel="stylesheet" href="{% static 'wagtailfontawesome/css/fontawesome.css' %}">

Then include icons anywhere on the front-end with:

<i class="fa fa-something"></i>

Using wagtailfontawesome as an optional dependency

If you want to distribute a Wagtail plugin with FontAwesome icons, you can use this package as an optional dependency by checking if it’s installed in Django, and falling back otherwise.

from django.apps import apps
try:
    from wagtail.core.blocks import StructBlock
except ImportError:  # fallback for Wagtail <2.0
    from wagtail.wagtailcore.blocks import StructBlock


class BlockquoteBlock(StructBlock):
    quote = TextBlock()
    author = TextBlock()

    class Meta:
        if apps.is_installed('wagtailfontawesome'):
            icon = 'fa-quote-left'

(in this case, the fallback is to do nothing)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wagtailfontawesome-1.2.0.tar.gz (659.1 kB view details)

Uploaded Source

Built Distribution

wagtailfontawesome-1.2.0-py2.py3-none-any.whl (661.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file wagtailfontawesome-1.2.0.tar.gz.

File metadata

  • Download URL: wagtailfontawesome-1.2.0.tar.gz
  • Upload date:
  • Size: 659.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.9

File hashes

Hashes for wagtailfontawesome-1.2.0.tar.gz
Algorithm Hash digest
SHA256 5f5fbde323246f61fb99e5c97b3972644b9cc9a8ed6ba9ccddd62fa52cb381c9
MD5 b09e4a576dd1f78d4269d6094f49840f
BLAKE2b-256 63ecc73ec95be322b0dafa1a2f3feb9f5d3183273de8b580acf6428a8f938bb7

See more details on using hashes here.

File details

Details for the file wagtailfontawesome-1.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: wagtailfontawesome-1.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 661.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.9

File hashes

Hashes for wagtailfontawesome-1.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 db953ab7dcd89442cec61afa320b1ecbfcc5fef53679a46a0c8234e6ab6ee6ea
MD5 b3abd75451ca8a3741937c5753f516d0
BLAKE2b-256 f3cd82f376d81593fa50dc0db12a7b37b11c29afcefb49ed62a848be71ddb482

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page