Coder Social home page Coder Social logo

wagtailfontawesome's Introduction

Wagtail FontAwesome

Add FontAwesome icons to StreamField.

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.

wagtailmodeladmin

wagtailmodeladmin is supported if you're using Wagtail 1.4 or above. Similar to StreamField, just set icon="fa-something" on your menu item.

Hallo plugins

You can use FontAwesome icons on custom Hallo buttons by setting the icon option to icon icon-fa-something.

button.hallobutton({
  label: "Blockquote",
  icon: 'icon icon-fa-quote-left',
});

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)

wagtailfontawesome's People

Contributors

alexgleason avatar flipperpa avatar noirbizarre avatar gasman avatar mx-moth avatar thibaudcolas avatar

Watchers

Stuart Axon avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.