1 | <p align="center">
|
2 | <a href="https://svgjar.web.app" target="_blank">
|
3 | <img src="https://svgjar.web.app/images/logo-96eaca43925f5d648acc8193b1b9ddd7.svg" alt="Logo">
|
4 | </a>
|
5 | </p>
|
6 |
|
7 | <h3 align="center">
|
8 | Best way to use SVG images in Ember apps.
|
9 | </h3>
|
10 |
|
11 | <p align="center">
|
12 | <a href="https://svgjar-demo.web.app" target="_blank">🎮 View Live Demo</a>
|
13 | ·
|
14 | <a href="https://github.com/ivanvotti/ember-svg-jar/issues/new?template=---bug-report.md">🐞 Report Bug</a>
|
15 | ·
|
16 | <a href="https://github.com/ivanvotti/ember-svg-jar/issues/new?template=---feature-request.md">🍩 Request Feature</a>
|
17 | ·
|
18 | <a href="https://github.com/ivanvotti/ember-svg-jar/issues/new?template=---question.md">🤔 Ask Question</a>
|
19 | </p>
|
20 |
|
21 | <p align="center">
|
22 | <a href="https://travis-ci.org/ivanvotti/ember-svg-jar" target="_blank">
|
23 | <img src="https://travis-ci.org/ivanvotti/ember-svg-jar.svg?branch=master"
|
24 | alt="Build Status">
|
25 | </a>
|
26 | <a href="https://www.npmjs.com/package/ember-svg-jar" target="_blank">
|
27 | <img src="https://img.shields.io/npm/v/ember-svg-jar.svg?color=informational" />
|
28 | </a>
|
29 | <a href="https://www.npmjs.com/package/ember-svg-jar" target="_blank">
|
30 | <img src="https://img.shields.io/npm/dm/ember-svg-jar.svg?color=informational" />
|
31 | </a>
|
32 | <a href="http://emberobserver.com/addons/ember-svg-jar" target="_blank">
|
33 | <img src="http://emberobserver.com/badges/ember-svg-jar.svg" alt="Ember Observer Score">
|
34 | </a>
|
35 | </p>
|
36 |
|
37 | ![](https://svgjar.web.app/images/app-screenshot-adb77f291ccaf5251e42c31eb3b5ddd3.png)
|
38 |
|
39 | ## Table of Contents
|
40 |
|
41 | - [🍩 Features](#-features)
|
42 | - [👋 Getting started](#-getting-started)
|
43 | - [🎮 Usage](#-usage)
|
44 | - [🔧 Configuration](#-configuration)
|
45 | - [❓ FAQ](#-faq)
|
46 | - [👓 Compatibility](#-compatibility)
|
47 | - [💟 Contributors](#-contributors)
|
48 | - [🆓 License](#-license)
|
49 |
|
50 | ## 🍩 Features
|
51 |
|
52 | Here's some of useful features:
|
53 |
|
54 | - <a href="https://svgjar-demo.web.app" target="_blank">Visual workflow</a> to find and use SVGs the fastest way possible
|
55 | - Automatic SVG optimization (it can cut file size by half or more)
|
56 | - Easy to use helper `{{svg-jar "asset-name"}}`
|
57 | - Support for both `inline` and `symbol` embedding methods
|
58 | - Copy SVG as CSS background
|
59 | - Zero configuration
|
60 |
|
61 | ## 👋 Getting started
|
62 |
|
63 | **Installation**
|
64 |
|
65 | `$ ember install ember-svg-jar`
|
66 |
|
67 | **Start in 3 easy steps**
|
68 |
|
69 | - 1️⃣ Drop some SVG images to the `public` directory (e.g. [material-design-icons](https://github.com/google/material-design-icons))
|
70 |
|
71 | - 2️⃣ Open the [asset viewer](http://localhost:4200/ember-svg-jar/index.html) and select any icon you like
|
72 |
|
73 | - 3️⃣ Copy the helper code from the viewer and paste it to your template
|
74 |
|
75 | ## 🎮 Usage
|
76 |
|
77 | Place your SVG images to the `public` directory (e.g. `./public/images/my-icon.svg`). Then copy the helper code for your image from the [asset viewer](http://localhost:4200/ember-svg-jar/index.html) or just write it by hand like this: `{{svg-jar "my-icon"}}`.
|
78 |
|
79 | The viewer is available at: <a href="http://localhost:4200/ember-svg-jar/index.html" target="_blank">http://localhost:4200/ember-svg-jar/index.html</a>
|
80 |
|
81 | If your `rootURL` is not `/`, then to use the asset viewer you will need to add `rootURL` to the addon [config](https://github.com/ivanvotti/ember-svg-jar/blob/master/docs/configuration.md#global-options).
|
82 |
|
83 | ### Helper
|
84 |
|
85 | Use the `svg-jar` helper to embed SVG images to your application's templates.
|
86 |
|
87 | For the default `inline` embedding strategy you can write:
|
88 |
|
89 | ```handlebars
|
90 | {{svg-jar "my-cool-icon" class="icon" width="24px"}}
|
91 | ```
|
92 |
|
93 | 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:
|
94 |
|
95 | ```handlebars
|
96 | <svg class="icon" width="24px">...</svg>
|
97 | ```
|
98 |
|
99 | For the `symbol` strategy you will need to add `#` to the asset ID like this:
|
100 |
|
101 | ```handlebars
|
102 | {{svg-jar "#my-cool-icon"}}
|
103 | ```
|
104 |
|
105 | In this case the result can look like this:
|
106 |
|
107 | ```handlebars
|
108 | <svg><use xlink:href="#my-cool-icon"></use></svg>
|
109 | ```
|
110 |
|
111 | ### Assets from Node modules
|
112 |
|
113 | 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:
|
114 |
|
115 | ```js
|
116 | var app = new EmberApp(defaults, {
|
117 | svgJar: {
|
118 | sourceDirs: [
|
119 | 'node_modules/material-design-icons/file/svg/design',
|
120 | 'node_modules/material-design-icons/action/svg/design',
|
121 | 'public/images/icons',
|
122 | ],
|
123 | },
|
124 | });
|
125 | ```
|
126 |
|
127 | [Click here for more configuration options](#configuration)
|
128 |
|
129 | ### Usage in an addon
|
130 |
|
131 | Using `ember-svg-jar` in an addon is the same as in an app, except that in the `package.json`
|
132 | of the addon, it should be listed as one of the `dependencies` and not `devDependencies`.
|
133 |
|
134 | ## 🔧 Configuration
|
135 |
|
136 | The addon should be useful without any configuration. But it wants to be very configurable when it's time to adjust it for your needs.
|
137 |
|
138 | - [All configuration options](docs/configuration.md)
|
139 | - [Advanced usage examples](docs/examples.md)
|
140 |
|
141 | ## ❓ FAQ
|
142 |
|
143 | **Q:** `Will the asset viewer affect my production build size?`
|
144 | **A:** No, it won't at all. The asset viewer is included in development mode only.
|
145 |
|
146 | **Q:** `Can it find SVG icons outside of the public directory, e.g. from node_modules?`
|
147 | **A:** Yes, it can import SVGs from any directory defined in the sourceDirs array.
|
148 |
|
149 | **Q:** `Why the SVG files deployed into the dist/assets folder without being fingerprinted?`
|
150 | **A:** This is done with the default ember cli behaviour. For more information see [SVG Fingerprinting](docs/svg-fingerprinting.md).
|
151 |
|
152 | **Q:** `Why does this matter?`
|
153 |
|
154 | - [Why GitHub switched from an icon font to SVG](https://github.com/blog/2112-delivering-octicons-with-svg)
|
155 | - ["Inline SVG vs icon fonts" from css-tricks](https://css-tricks.com/icon-fonts-vs-svg/)
|
156 | - [Ten reasons to switch from an icon font to SVG](http://ianfeather.co.uk/ten-reasons-we-switched-from-an-icon-font-to-svg/)
|
157 |
|
158 | **Q:** `Why would you switch from Font Awesome to SVG?`
|
159 |
|
160 | - original Font Awesome is about `149 KB` as TTF and `88.3 KB` as WOFF
|
161 | - it includes `634` icons and you need just some of them usually
|
162 | - 20 Font Awesome icons in SVGJar will be about 4.3 KB (you save `84 KB` or `145 KB` as TTF)
|
163 | - 50 Font Awesome icons in SVGJar will be about `9 KB`
|
164 |
|
165 | You can get Font Awesome icons as individual SVG files from [font-awesome-svg](https://github.com/ivanvotti/font-awesome-svg).
|
166 |
|
167 | ## 👓 Compatibility
|
168 |
|
169 | Latest ember-svg-jar `2.X.X` currently supports:
|
170 |
|
171 | - Node `8.* || >= 10.*`
|
172 | - Ember >= `2.X.X`
|
173 |
|
174 | ## 💟 Contributors
|
175 |
|
176 | Contributions of any kind welcome! See the [Contributing](CONTRIBUTING.md) guide for details.
|
177 |
|
178 | Thanks goes to these wonderful people:
|
179 |
|
180 |
|
181 |
|
182 | <table>
|
183 | <tr>
|
184 | <td align="center"><a href="http://eaf4.com"><img src="https://avatars0.githubusercontent.com/u/319282?v=4" width="100px;" alt="Edward Faulkner"/><br /><sub><b>Edward Faulkner</b></sub></a><br /><a href="https://github.com/ivanvotti/ember-svg-jar/commits?author=ef4" title="Code">💻</a></td>
|
185 | <td align="center"><a href="https://github.com/Turbo87"><img src="https://avatars2.githubusercontent.com/u/141300?v=4" width="100px;" alt="Tobias Bieniek"/><br /><sub><b>Tobias Bieniek</b></sub></a><br /><a href="https://github.com/ivanvotti/ember-svg-jar/commits?author=Turbo87" title="Code">💻</a></td>
|
186 | <td align="center"><a href="https://shipshape.io"><img src="https://avatars3.githubusercontent.com/u/2640861?v=4" width="100px;" alt="Robert Wagner"/><br /><sub><b>Robert Wagner</b></sub></a><br /><a href="https://github.com/ivanvotti/ember-svg-jar/commits?author=rwwagner90" title="Code">💻</a></td>
|
187 | <td align="center"><a href="https://github.com/wagenet"><img src="https://avatars3.githubusercontent.com/u/9835?v=4" width="100px;" alt="Peter Wagenet"/><br /><sub><b>Peter Wagenet</b></sub></a><br /><a href="https://github.com/ivanvotti/ember-svg-jar/commits?author=wagenet" title="Code">💻</a></td>
|
188 | <td align="center"><a href="https://github.com/ryanpatrickcook"><img src="https://avatars2.githubusercontent.com/u/3067243?v=4" width="100px;" alt="Ryan Cook"/><br /><sub><b>Ryan Cook</b></sub></a><br /><a href="https://github.com/ivanvotti/ember-svg-jar/commits?author=ryanpatrickcook" title="Code">💻</a></td>
|
189 | <td align="center"><a href="https://github.com/mupkoo"><img src="https://avatars0.githubusercontent.com/u/1788571?v=4" width="100px;" alt="Mirko Akov"/><br /><sub><b>Mirko Akov</b></sub></a><br /><a href="https://github.com/ivanvotti/ember-svg-jar/commits?author=mupkoo" title="Code">💻</a></td>
|
190 | <td align="center"><a href="http://mrloop.com"><img src="https://avatars3.githubusercontent.com/u/12345?v=4" width="100px;" alt="Ewan McDougall"/><br /><sub><b>Ewan McDougall</b></sub></a><br /><a href="https://github.com/ivanvotti/ember-svg-jar/commits?author=mrloop" title="Code">💻</a></td>
|
191 | </tr>
|
192 | <tr>
|
193 | <td align="center"><a href="https://github.com/markcatley"><img src="https://avatars0.githubusercontent.com/u/5198?v=4" width="100px;" alt="Mark Catley"/><br /><sub><b>Mark Catley</b></sub></a><br /><a href="https://github.com/ivanvotti/ember-svg-jar/commits?author=markcatley" title="Code">💻</a></td>
|
194 | <td align="center"><a href="http://www.seated.com"><img src="https://avatars1.githubusercontent.com/u/19490?v=4" width="100px;" alt="John Griffin"/><br /><sub><b>John Griffin</b></sub></a><br /><a href="https://github.com/ivanvotti/ember-svg-jar/commits?author=john-griffin" title="Code">💻</a></td>
|
195 | <td align="center"><a href="http://www.facebook.com/lucin.ivan"><img src="https://avatars3.githubusercontent.com/u/4481706?v=4" width="100px;" alt="Ivan Lučin"/><br /><sub><b>Ivan Lučin</b></sub></a><br /><a href="https://github.com/ivanvotti/ember-svg-jar/commits?author=ilucin" title="Code">💻</a></td>
|
196 | <td align="center"><a href="https://hyjk2000.github.io"><img src="https://avatars1.githubusercontent.com/u/4647136?v=4" width="100px;" alt="James Shih"/><br /><sub><b>James Shih</b></sub></a><br /><a href="https://github.com/ivanvotti/ember-svg-jar/commits?author=hyjk2000" title="Code">💻</a></td>
|
197 | <td align="center"><a href="http://seg.al"><img src="https://avatars1.githubusercontent.com/u/3156114?v=4" width="100px;" alt="djsegal"/><br /><sub><b>djsegal</b></sub></a><br /><a href="https://github.com/ivanvotti/ember-svg-jar/commits?author=djsegal" title="Code">💻</a></td>
|
198 | <td align="center"><a href="https://jan.buschtoens.me"><img src="https://avatars0.githubusercontent.com/u/834636?v=4" width="100px;" alt="Jan Buschtöns"/><br /><sub><b>Jan Buschtöns</b></sub></a><br /><a href="https://github.com/ivanvotti/ember-svg-jar/commits?author=buschtoens" title="Code">💻</a></td>
|
199 | <td align="center"><a href="https://siva.dev"><img src="https://avatars1.githubusercontent.com/u/7725225?v=4" width="100px;" alt="Sivasubramanyam A"/><br /><sub><b>Sivasubramanyam A</b></sub></a><br /><a href="https://github.com/ivanvotti/ember-svg-jar/commits?author=astronomersiva" title="Code">💻</a></td>
|
200 | </tr>
|
201 | <tr>
|
202 | <td align="center"><a href="https://alexdiliberto.com"><img src="https://avatars0.githubusercontent.com/u/666459?v=4" width="100px;" alt="Alex DiLiberto"/><br /><sub><b>Alex DiLiberto</b></sub></a><br /><a href="https://github.com/ivanvotti/ember-svg-jar/commits?author=alexdiliberto" title="Code">💻</a></td>
|
203 | <td align="center"><a href="https://github.com/Dhaulagiri"><img src="https://avatars1.githubusercontent.com/u/1672302?v=4" width="100px;" alt="Brian Runnells"/><br /><sub><b>Brian Runnells</b></sub></a><br /><a href="https://github.com/ivanvotti/ember-svg-jar/commits?author=Dhaulagiri" title="Code">💻</a></td>
|
204 | <td align="center"><a href="https://jenweber.github.io/portfolio/"><img src="https://avatars1.githubusercontent.com/u/16627268?v=4" width="100px;" alt="Jen Weber"/><br /><sub><b>Jen Weber</b></sub></a><br /><a href="https://github.com/ivanvotti/ember-svg-jar/commits?author=jenweber" title="Documentation">📖</a></td>
|
205 | <td align="center"><a href="http://hakilebara.com"><img src="https://avatars2.githubusercontent.com/u/1991564?v=4" width="100px;" alt="Frédéric Soumaré"/><br /><sub><b>Frédéric Soumaré</b></sub></a><br /><a href="https://github.com/ivanvotti/ember-svg-jar/commits?author=hakilebara" title="Documentation">📖</a></td>
|
206 | <td align="center"><a href="http://kiwiupover.com"><img src="https://avatars3.githubusercontent.com/u/647691?v=4" width="100px;" alt="David Laird"/><br /><sub><b>David Laird</b></sub></a><br /><a href="https://github.com/ivanvotti/ember-svg-jar/commits?author=kiwiupover" title="Code">💻</a></td>
|
207 | <td align="center"><a href="http://www.lumialabs.com"><img src="https://avatars2.githubusercontent.com/u/533152?v=4" width="100px;" alt="Daan van Etten"/><br /><sub><b>Daan van Etten</b></sub></a><br /><a href="https://github.com/ivanvotti/ember-svg-jar/commits?author=Daan-" title="Code">💻</a></td>
|
208 | <td align="center"><a href="https://github.com/tcjr"><img src="https://avatars3.githubusercontent.com/u/142243?v=4" width="100px;" alt="Tom Carter"/><br /><sub><b>Tom Carter</b></sub></a><br /><a href="https://github.com/ivanvotti/ember-svg-jar/issues?q=author%3Atcjr" title="Bug reports">🐛</a></td>
|
209 | </tr>
|
210 | </table>
|
211 |
|
212 |
|
213 |
|
214 | ## 🆓 License
|
215 |
|
216 | This project is distributed under the MIT license.
|
217 |
|
218 | ---
|
219 |
|
220 | GitHub [@ivanvotti](https://github.com/ivanvotti) ·
|
221 | Twitter [@ivanvotti](https://twitter.com/ivanvotti)
|