icon_link 0.0.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.travis.yml +1 -1
- data/README.md +21 -9
- data/lib/icon_link/version.rb +1 -1
- data/lib/icon_link/view_helpers.rb +14 -6
- data/spec/icon_link/icon_link_spec.rb +8 -0
- metadata +15 -25
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8128c8ba21bdf7875199e3b21ea2ece2ec10b4c2
|
4
|
+
data.tar.gz: d99c5e08da8c6ca6efde5edc92767cd0679c4495
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d58ccd1b1890e9a03f5e019245845a00e8839bb6223b882f97f32342ff61daf73919462298d174b54e24fb7be999225ed1fd4545c3e6d9f27a7034dffde61132
|
7
|
+
data.tar.gz: ea6979b815deff07a613ba77fde753b5c1cc5f1af00a76f98bd183ecc749d95188cb293ca020bd942f54a4413940148c6839ee06a6bd307e6682a0e37f8b819f
|
data/.travis.yml
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
rvm:
|
2
|
-
-
|
2
|
+
- 2.0.0
|
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
# IconLink
|
1
|
+
# IconLink
|
2
|
+
[](https://travis-ci.org/noroddsto/icon_link)
|
3
|
+
[](https://codeclimate.com/github/noroddsto/icon_link)
|
2
4
|
|
3
5
|
View helper methods that makes it easy to add the html that is needed to display icons (from Font Awesome or Twitter Bootstrap) within links, or buttons.
|
4
6
|
|
@@ -6,7 +8,9 @@ View helper methods that makes it easy to add the html that is needed to display
|
|
6
8
|
|
7
9
|
Add this line to your application's Gemfile:
|
8
10
|
|
9
|
-
|
11
|
+
```ruby
|
12
|
+
gem 'icon_link'
|
13
|
+
```
|
10
14
|
|
11
15
|
And then execute:
|
12
16
|
|
@@ -17,24 +21,32 @@ And then execute:
|
|
17
21
|
Link with icon:
|
18
22
|
|
19
23
|
```ruby
|
20
|
-
icon_link_to("Example", "http://www.example.com", icon: "comment
|
21
|
-
# => <a href="http://www.example.com" class="btn"><i class="icon-comment"></i>
|
24
|
+
icon_link_to("Example", "http://www.example.com", icon: "icon-comment")
|
25
|
+
# => <a href="http://www.example.com" class="btn"><i class="icon-comment"></i> Example</a>
|
22
26
|
```
|
27
|
+
|
23
28
|
Button with icon:
|
24
29
|
|
25
30
|
```ruby
|
26
|
-
icon_button_tag("
|
27
|
-
# => <button class="btn" type="submit"><i class="icon-comment"></i> Create
|
31
|
+
icon_button_tag("Create example", icon: "icon-comment")
|
32
|
+
# => <button class="btn" type="submit"><i class="icon-comment"></i> Create example</button>
|
28
33
|
```
|
29
34
|
|
30
35
|
Text with icon:
|
31
36
|
|
32
37
|
```ruby
|
33
|
-
iconize("Example", icon: "comment
|
34
|
-
# => <i class="icon-comment"></i>
|
38
|
+
iconize("Example", icon: "icon-comment")
|
39
|
+
# => <i class="icon-comment"></i> Example
|
40
|
+
```
|
41
|
+
|
42
|
+
Only icon:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
icon_for("icon-comment")
|
46
|
+
# => <i class="icon-comment"></i>
|
35
47
|
```
|
36
48
|
|
37
|
-
See documentation: [
|
49
|
+
See documentation: [RubyDoc](http://rubydoc.info/github/noroddsto/icon_link/master/frames)
|
38
50
|
|
39
51
|
## Contributing
|
40
52
|
|
data/lib/icon_link/version.rb
CHANGED
@@ -5,7 +5,7 @@ module IconLink
|
|
5
5
|
# but takes an additional :icon option. Type is set to submit by default.
|
6
6
|
#
|
7
7
|
# ==== Examples
|
8
|
-
# icon_button_tag("Example", icon: "comment
|
8
|
+
# icon_button_tag("Example", icon: "icon-comment")
|
9
9
|
# # => <button class="btn" type="submit"><i class="icon-comment"></i> Create model</button>
|
10
10
|
def icon_button_tag(title, options={})
|
11
11
|
options[:type] ||= 'submit'
|
@@ -18,24 +18,32 @@ module IconLink
|
|
18
18
|
# but takes an additional :icon option.
|
19
19
|
#
|
20
20
|
# ==== Examples
|
21
|
-
# icon_link_to("Example", "http://www.example.com", icon: "comment
|
21
|
+
# icon_link_to("Example", "http://www.example.com", icon: "icon-comment")
|
22
22
|
# # => <a href="http://www.example.com" class="btn"><i class="icon-comment"></i> Title</a>
|
23
23
|
def icon_link_to(title, url, options = {})
|
24
|
-
|
24
|
+
link_to(iconize(title, options[:icon]), url, options.merge(icon: nil))
|
25
25
|
end
|
26
26
|
|
27
27
|
# Adds icon to a given text
|
28
28
|
#
|
29
29
|
# ==== Examples
|
30
|
-
# iconize("Example", icon: "comment
|
30
|
+
# iconize("Example", icon: "icon-comment")
|
31
31
|
# # => <i class="icon-comment"></i> Title
|
32
32
|
def iconize(text, icon = nil)
|
33
33
|
if icon.to_s.empty?
|
34
34
|
text
|
35
35
|
else
|
36
|
-
|
36
|
+
icon_for(icon) + " " + text
|
37
37
|
end
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
|
+
# Returns <i class="your-icon"></i>
|
41
|
+
#
|
42
|
+
# === Examples
|
43
|
+
# icon_for("icon-comment")
|
44
|
+
# # => <i class="your-icon"></i>
|
45
|
+
def icon_for(icon)
|
46
|
+
content_tag(:i, nil, class: icon.to_s)
|
47
|
+
end
|
40
48
|
end
|
41
49
|
end
|
metadata
CHANGED
@@ -1,68 +1,60 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: icon_link
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- NorOddSto
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-09-15 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: capybara
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: actionpack
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ~>
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,13 +62,12 @@ dependencies:
|
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ~>
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '3.0'
|
78
|
-
description:
|
79
|
-
|
69
|
+
description: ' View helper methods that makes it easy adding icons to links and buttons.
|
70
|
+
Meant to be used with Font Awesome or Twitter Bootstrap.'
|
80
71
|
email:
|
81
72
|
- oddgeir@kjorren.com
|
82
73
|
executables: []
|
@@ -99,27 +90,26 @@ files:
|
|
99
90
|
- spec/spec_helper.rb
|
100
91
|
homepage: ''
|
101
92
|
licenses: []
|
93
|
+
metadata: {}
|
102
94
|
post_install_message:
|
103
95
|
rdoc_options: []
|
104
96
|
require_paths:
|
105
97
|
- lib
|
106
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
-
none: false
|
108
99
|
requirements:
|
109
|
-
- -
|
100
|
+
- - '>='
|
110
101
|
- !ruby/object:Gem::Version
|
111
102
|
version: '0'
|
112
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
104
|
requirements:
|
115
|
-
- -
|
105
|
+
- - '>='
|
116
106
|
- !ruby/object:Gem::Version
|
117
107
|
version: '0'
|
118
108
|
requirements: []
|
119
109
|
rubyforge_project:
|
120
|
-
rubygems_version:
|
110
|
+
rubygems_version: 2.0.3
|
121
111
|
signing_key:
|
122
|
-
specification_version:
|
112
|
+
specification_version: 4
|
123
113
|
summary: Helper methods for adding icon to links and submit buttons
|
124
114
|
test_files:
|
125
115
|
- spec/icon_link/icon_link_spec.rb
|