Giter Site home page Giter Site logo

flask-feather's Introduction

Flask Feather

Build Status GitHub PyPI - Python Version

A simple Tag ({% icon "name" %}) to implement Feather Icons in Flask. This is largely based of the library django_feather by Jonas Drotleff.

Install

Install flask-feather using pip.

pip install flask-feather

Quick Start

Firstly, initialise the extension within your Flask context

from flask_feather import Feather
feather = Feather(app)

This extension also supports the Flask application factory pattern by allowing you to create a Feather object and then initialised it separately for an app:

feather = Feather()

def create_app(config):
    app = Flask(__name__)
    app.config.from_object(config)

    feather.init_app(app)

Advanced setup

In addition to the wonderful icons provided in the feather set, you can supply your own svg icons, to attempt to parse them and use them in the same format. Simply initialise the extension with a directory containing .svg files that are similar in style to the feather ones. They should resemble the feather icon style as near as possible - any significant differences in formatting/structure may result in unexpected errors.

feather = Feather(import_dir='app\\static\\customsvg')

def create_app(config):
    app = Flask(__name__)
    app.config.from_object(config)

    feather.init_app(app)

Usage

It's pretty simple to use this package. From within a jinja template:

<p>{{ feather.icon('icon-name', width=32, height=32) }}</p>

If the property you're modifying has a hyphen, use an underscore instead. You can refer to icon names with either hyphens or underscores.

<p>{{ feather.icon('icon-name', stroke_width=2) }}</p>

The icon function takes the SVG source from the Feather project, applies additional attributes and return the SVG tag.

Performance

flask-feather borrows the application structure from django-feather and does not read the .svg files each time an icon is rendered. Instead, on installation, all the icons are written to a .py file. All icons are rendered on the server side, avoiding the need to call feather.replace() after the page has loaded.

Any custom icons are parsed each time the server is restarted, and not every time they're loaded.

License

Feather is licensed under the MIT License.

flask-feather is a derivative work of django-feather, both of which are licensed under the Apache License, Version 2.0:

    Modifications Copyright 2020 Tom Vos <[email protected]>
    
    Original Django-feather Copyright 2020 Jonas Drotleff <[email protected]>
    
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
    
       http://www.apache.org/licenses/LICENSE-2.0
    
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

flask-feather's People

Contributors

thetomcat avatar

Stargazers

 avatar Stefan Jeremic avatar

Watchers

 avatar  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.