GithubHelp home page GithubHelp logo

wagenet / ember-svg-jar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from voltidev/ember-svg-jar

1.0 1.0 0.0 1.06 MB

:star2: Best way to embed SVG images into your Ember application

Home Page: https://svgjar.firebaseapp.com

License: MIT License

JavaScript 91.46% HTML 8.54%

ember-svg-jar's Introduction

Logo
Ember SVGJar

Build Status NPM Version Ember Observer Score

The best way to embed SVG images into your Ember application

Features

  • a visual workflow to find and use your assets the fastest way possible
  • automatic SVG optimization (it can cut file size by half or more)
  • work out of the box (no configuration needed)
  • an easy to use helper {{svg-jar "asset-name"}}
  • support for both inline and symbol embedding methods

Why does this matter?

I know why. Just show me how to get started.

Switching from Font Awesome to SVG will save you 80 Kb or even more:

  • original Font Awesome is about 149 KB as TTF and 88.3 KB as WOFF
  • it includes 634 icons and you need just some of them usually
  • 20 Font Awesome icons in SVGJar will be about 4.3 KB (you save 84 KB or 145 KB as TTF)
  • 50 Font Awesome icons in SVGJar will be about 9 KB

You can get Font Awesome icons as individual SVG files from font-awesome-svg:

git clone [email protected]:ivanvotti/font-awesome-svg.git

SVG vs icon fonts

If you can go IE 9+ and Android 3+, SVG is a better solution than icon fonts. Also if your images are multi-coloured or involved in animation, you actually have to use SVG.

Installation

$ ember install ember-svg-jar

Start in 4 easy steps

  • Put some SVG files to any place in your project's public directory (e.g. get some from font-awesome-svg)
  • Run the development server and open this link with Chrome: http://localhost:4200/ember-svg-jar/index.html
  • Select any SVG there and press Enter to copy it to the clipboard.
  • Paste it into any template and see it rendered in your browser.

Usage

Drag and drop SVG images to your project's public directory and copy & paste them from the assets viewer to your templates.

The viewer is available at: http://localhost:4200/ember-svg-jar/index.html

Assets from Node modules

By default ember-svg-jar looks for SVGs in the public directory. To get SVGs from node_modules packages or any other directory you will need to add them to ember-cli-build.js like this:

  var app = new EmberApp(defaults, {
    svgJar: {
      sourceDirs: [
        'node_modules/material-design-icons/file/svg/design',
        'node_modules/material-design-icons/action/svg/design',
        'public/images/icons'
      ]
    }
  });

Click here for more configuration options

Helper

Use the svg-jar helper to embed SVG images to your application's templates:

{{svg-jar "my-cool-icon" class="icon" width="24px"}}

The helper takes an asset ID and optional attributes that will be added to the created SVG element. The example above will create an SVG like this:

<svg class="icon" width="24px">...</svg>

Configuration

Note: Ember SVGJar should be useful without any configuration. But it wants to be very configurable when it's time to adjust it for your needs.

Compatibility

The addon is compatible with Ember 1.10.1 and beyond.

FAQ

Q: Will the asset viewer affect my production build size?
A: No, it won't at all. The asset viewer is included in development mode only.

Q: Can it find SVG icons outside of the public directory, e.g. from node_modules?
A: Yes, it can import SVGs from any directory defined in the sourceDirs array.

Development setup

Installation

  • git clone <repository-url> this repository
  • cd ember-svg-jar
  • npm install

Building

  • npm run build

Running tests and linting

Run all tests and lint code (npm run lint && npm run nodetest && ember test):

npm test

Test node modules (src directory):

npm run nodetest

Test Ember related code:

  • ember test
  • ember test --server
  • ember try:each

Lint all code (src, addon, app, node-tests, tests directories)

npm run lint

Running the dummy app

For more information on using ember-cli, visit https://ember-cli.com/.

Asset viewer

The viewer is a separate Ember application, which repository can be found at this link.

License

This project is distributed under the MIT license.


GitHub @ivanvotti  ·  Twitter @ivanvotti

ember-svg-jar's People

Contributors

alexdiliberto avatar dhaulagiri avatar djsegal avatar ef4 avatar ember-tomster avatar ilucin avatar ivanvotti avatar john-griffin avatar mupkoo avatar rwwagner90 avatar ryanpatrickcook avatar turbo87 avatar

Stargazers

 avatar

Watchers

 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.