icon_tag 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -4
- data/lib/icon_tag.rb +1 -0
- data/lib/icon_tag/presenter.rb +38 -0
- data/lib/icon_tag/version.rb +1 -1
- data/lib/icon_tag/view_helpers.rb +11 -2
- metadata +11 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 562f16b2a3b8d54867c5a9baeb2a50b7a75869bb
|
4
|
+
data.tar.gz: 626a77892b56ce2d36d7ca7fd76c45744f2aa0e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf22cec970534d3972cc2508877665cd090e18187493c121eae1c3cd37b768f6e6c5508f2871cfed688a6b2f946502dee0ffdbfeec9add4ce1e8d88951191cf5
|
7
|
+
data.tar.gz: 2314326e0d450d75997f2e484433829e2a0386e0d8361b6eae34d39272fa168ca4968f67b98dd91b38c23478c518af7c3cd04d84dc8381abf3e30d6529c7acb9
|
data/README.md
CHANGED
@@ -1,6 +1,24 @@
|
|
1
1
|
# IconTag
|
2
2
|
|
3
3
|
Simple helper for Font Awesome icons. Adds icon_tag helper method to your views.
|
4
|
+
Follow examples at: [http://fortawesome.github.io/Font-Awesome/examples/](http://fortawesome.github.io/Font-Awesome/examples/)
|
5
|
+
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
### Options:
|
10
|
+
|
11
|
+
* `size`: "lg, 2x, 3x, 4x"
|
12
|
+
* `spin`: `true` or `false`
|
13
|
+
* `fixed-width` (alias `fw`): `true` or `false`
|
14
|
+
* `border`: `true` or `false`
|
15
|
+
* `rotate`: '90', '180', '270'
|
16
|
+
* `flip`: 'horizontal' or 'vertical'
|
17
|
+
|
18
|
+
#### Example:
|
19
|
+
|
20
|
+
<%= icon_tag('user', size: '2x') %>
|
21
|
+
# => <i class='fa fa-user fa-2x'></i>
|
4
22
|
|
5
23
|
## Installation
|
6
24
|
|
@@ -16,10 +34,6 @@ Or install it yourself as:
|
|
16
34
|
|
17
35
|
$ gem install icon_tag
|
18
36
|
|
19
|
-
## Usage
|
20
|
-
|
21
|
-
`<%= icon_tag('user') %>`
|
22
|
-
|
23
37
|
## Contributing
|
24
38
|
|
25
39
|
1. Fork it
|
data/lib/icon_tag.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
module IconTag
|
2
|
+
class Presenter
|
3
|
+
|
4
|
+
include ActionView::Helpers::TagHelper
|
5
|
+
|
6
|
+
def initialize icon, options={}
|
7
|
+
@icon = icon
|
8
|
+
@options = options
|
9
|
+
extract_options
|
10
|
+
compile_html_class
|
11
|
+
end
|
12
|
+
|
13
|
+
def html_tag
|
14
|
+
content_tag(:i, nil, @options.reverse_merge(class: @html_class))
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def extract_options
|
20
|
+
@size = @options.delete(:size)
|
21
|
+
@fixed_with = @options.delete(:fw) || @options.delete(:fixed_with)
|
22
|
+
@border = @options.delete(:border)
|
23
|
+
@spin = @options.delete(:spin)
|
24
|
+
@rotate = @options.delete(:rotate)
|
25
|
+
@flip = @options.delete(:flip)
|
26
|
+
end
|
27
|
+
|
28
|
+
def compile_html_class
|
29
|
+
@html_class = "fa fa-#{@icon}"
|
30
|
+
@html_class << " fa-#{@size}" if @size
|
31
|
+
@html_class << " fa-fw" if @fixed_with
|
32
|
+
@html_class << " fa-border" if @border
|
33
|
+
@html_class << " fa-spin" if @spin
|
34
|
+
@html_class << " fa-rotate-#{@rotate}" if @rotate
|
35
|
+
@html_class << " fa-flip-#{@flip}" if @flip
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/icon_tag/version.rb
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
module IconTag
|
2
2
|
module ViewHelpers
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
# icon: icon name from Font Awesome (without 'fa')
|
5
|
+
# Follow examples at: http://fortawesome.github.io/Font-Awesome/examples/
|
6
|
+
# Options:
|
7
|
+
# Size: lg, 2x, 3x, 4x
|
8
|
+
# Spin: true or false
|
9
|
+
# Fixed Width: "Use fa-fw to set icons at a fixed width. Great to use when different icon widths throw off alignment. Especially useful in things like nav lists & list groups."
|
10
|
+
# Border: true or false
|
11
|
+
# Rotate: 90, 180, 270
|
12
|
+
# Flip: horizontal / vertical
|
13
|
+
def icon_tag(icon, options={})
|
14
|
+
IconTag::Presenter.new(icon, options).html_tag
|
6
15
|
end
|
7
16
|
|
8
17
|
end
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: icon_tag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathieu Gagné
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description: Simple helper for Font Awesome icons
|
@@ -45,13 +45,14 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- .gitignore
|
48
|
+
- ".gitignore"
|
49
49
|
- Gemfile
|
50
50
|
- LICENSE.txt
|
51
51
|
- README.md
|
52
52
|
- Rakefile
|
53
53
|
- icon_tag.gemspec
|
54
54
|
- lib/icon_tag.rb
|
55
|
+
- lib/icon_tag/presenter.rb
|
55
56
|
- lib/icon_tag/railtie.rb
|
56
57
|
- lib/icon_tag/version.rb
|
57
58
|
- lib/icon_tag/view_helpers.rb
|
@@ -65,17 +66,17 @@ require_paths:
|
|
65
66
|
- lib
|
66
67
|
required_ruby_version: !ruby/object:Gem::Requirement
|
67
68
|
requirements:
|
68
|
-
- -
|
69
|
+
- - ">="
|
69
70
|
- !ruby/object:Gem::Version
|
70
71
|
version: '0'
|
71
72
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
73
|
requirements:
|
73
|
-
- -
|
74
|
+
- - ">="
|
74
75
|
- !ruby/object:Gem::Version
|
75
76
|
version: '0'
|
76
77
|
requirements: []
|
77
78
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.
|
79
|
+
rubygems_version: 2.2.2
|
79
80
|
signing_key:
|
80
81
|
specification_version: 4
|
81
82
|
summary: Simple helper for Font Awesome icons. Adds icon_tag helper method to your
|