weather-icons-rails 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c44e47fd965f279dea4903072cc084c512feacf
4
- data.tar.gz: b98d7b2c1fca4ab3b6861728905c1968162fcf6e
3
+ metadata.gz: f0f0f7ab340343a534a9ce93445af161704acf1f
4
+ data.tar.gz: 8d2f3a519462599576f9d676db9b94e21345cc4b
5
5
  SHA512:
6
- metadata.gz: 588bf13624280532c7460069e6f9c8ae455d0a833b88d171031d1477c2b5305ac2f4252ba1e15d552eb69b97c54e4d0a5623b649822efa38d92cda4f834e7278
7
- data.tar.gz: 2f5d9d3e90fc320658eaa2d5cb4c5594b3693c5c7b69e3a3b9661c8f4fb3e7568fe939645baea40b713a06c98d8fcf92a677ce6070ab256654f106efe021202b
6
+ metadata.gz: b926d0c115f23842d7e5f30a536afcb1047e46d24a9906de0da079465643d7fd037695a3c48b0c7e1f0779258ea42ec827932e0690943d260752c916745e3cdb
7
+ data.tar.gz: 86f6eb974acc7eefad3bea531732251de3e6e82d397f1cffd2483b46711bf7cfcee0cf9ba25ec4964ac6a0ad30ccad519ff772f28bc720a0ecbfc60ff7a599ff
data/README.md CHANGED
@@ -36,7 +36,7 @@ To add icons anywhere in your html just add one of these tags with your symbole
36
36
  ```
37
37
  ## If that wasn't easy enough, Helpers make it even easier!
38
38
 
39
- ######In your view just add these to your HAML or ERB:
39
+ #####In your view just add these to your HAML or ERB:
40
40
 
41
41
  ```ruby
42
42
  wi_icon('day-lightning')
@@ -45,7 +45,6 @@ wi_icon('day-lightning')
45
45
  ```ruby
46
46
  wi_icon('day-lightning', '', class: 'strong')
47
47
  # => <i class="wi wi-day-lightning strong"></i>
48
- # Although this currently does not change the actual look of the font yet. Any suggestions?
49
48
  ```
50
49
  ```ruby
51
50
  wi_icon "day-lightning lg", class: "text-muted pull-left"
@@ -61,7 +60,7 @@ content_tag(:li, wi_icon("day-lightning li", text: "Bulleted list item"))
61
60
  # => <li><i class="wi wi-day-lightning wi-li"></i> Bulleted list item</li>
62
61
  ```
63
62
 
64
- I cant really think of a use for this, but I'm sure someone can. Works better with empty box icon in font awesome.
63
+ I cant really think of a use for this, but I'm sure someone can. Works better with empty box icon in Font Awesome.
65
64
 
66
65
  ```ruby
67
66
  wi_stacked_icon "day-lightning", base: "day-cloudy-gusts"
@@ -79,7 +78,7 @@ wi_stacked_icon "day-lightning inverse", base: 'day-cloudy-gusts', class: "pull-
79
78
 
80
79
  #### Weathered Lists:
81
80
 
82
- ###### Use wi-li tag with an icon nested inside a ul.wi-ul > li list to have it used as the bullet point. Must have text or element after it to work
81
+ ##### Use `wi-li` tag with an icon nested inside a `ul.wi-ul > li` list to have it used as the bullet point. Must have text or element after it to work
83
82
 
84
83
  ```ruby
85
84
  wi_list_item('wi-day-hail', 'Bad Weather Today')
@@ -48,8 +48,8 @@ module WeatherIcons
48
48
 
49
49
  def register_rails_engine
50
50
  require 'sass-rails'
51
- require 'weather-icons/rails/rails/engine'
52
- require 'weather-icons/rails/rails/railtie'
51
+ require 'weather-icons/rails/engine'
52
+ require 'weather-icons/rails/railtie'
53
53
  end
54
54
  end
55
55
  end
@@ -0,0 +1,135 @@
1
+ module WeatherIcons
2
+ module Rails
3
+ module IconHelpers
4
+ # Creates an icon tag given an icon name and possible icon
5
+ # modifiers.
6
+ #
7
+ # Examples
8
+ #
9
+ # wi_icon "day-hail"
10
+ # # => <i class="wi wi-day-hail"></i>
11
+ #
12
+ # wi_icon "day-hail", text: "Hailing Outside!"
13
+ # # => <i class="wi wi-day-hail"></i> Hailing Outside
14
+ #
15
+ # wi_icon "day-hail 2x"
16
+ # # => <i class="wi wi-day-hail wi-2x"></i>
17
+ # wi_icon ["day-hail", "4x"]
18
+ # # => <i class="wi wi-day-hail wi-4x"></i>
19
+ # wi_icon "wi-day-hail spin lg"
20
+ # # => <i class="wi wi-day-hail wi-spin wi-lg">
21
+ #
22
+ # wi_icon "day-hail 4x", class: "pull-left"
23
+ # # => <i class="wi wi-day-hail wi-4x pull-left"></i>
24
+ #
25
+ # wi_icon "day-hail", data: { id: 123 }
26
+ # # => <i class="wi wi-day-hail" data-id="123"></i>
27
+ #
28
+ # content_tag(:li, wi_icon("day-hail li", text: "Bulleted list item"))
29
+ # # => <li><i class="wi wi-day-hail wi-li"></i> Bulleted list item</li>
30
+ def wi_icon(names = "flag", options = {})
31
+ classes = ['wi']
32
+ classes.concat Private.icon_names(names)
33
+ classes.concat Array(options.delete(:class))
34
+ text = options.delete(:text)
35
+ icon = content_tag(:i, nil, options.merge(:class => classes))
36
+ Private.icon_join(icon, text)
37
+ end
38
+
39
+ # Creates an stack set of icon tags given a base icon name, a main icon
40
+ # name, and possible icon modifiers.
41
+ #
42
+ # Examples
43
+ #
44
+ # wi_stacked_icon "day-hail", base: "day-cloudy-gusts"
45
+ # # => <span class="wi-stack">
46
+ # # => <i class="wi wi-day-cloudy-gusts wi-stack-2x"></i>
47
+ # # => <i class="wi wi-day-hail wi-stack-1x"></i>
48
+ # # => </span>
49
+ #
50
+ # wi_stacked_icon "day-hail inverse", base: "lightning", class: "pull-right", text: "Hi!"
51
+ # # => <span class="wi-stack pull-right">
52
+ # # => <i class="wi wi-lightning wi-stack-2x"></i>
53
+ # # => <i class="wi wi-day-hail wi-inverse wi-stack-1x"></i>
54
+ # # => </span> Hi!
55
+ #
56
+ # wi_stacked_icon "lightning", base: "day-cloudy-gusts", reverse: true
57
+ # # => <span class="wi-stack">
58
+ # # => <i class="wi wi-lightning wi-stack-1x"></i>
59
+ # # => <i class="wi wi-day-cloudt-gusts wi-stack-2x"></i>
60
+ # # => </span>
61
+ def wi_stacked_icon(names = "flag", options = {})
62
+ classes = Private.icon_names("stack").concat(Array(options.delete(:class)))
63
+ base_names = Private.array_value(options.delete(:base) || "wi-lightning").push("stack-2x")
64
+ names = Private.array_value(names).push("stack-1x")
65
+ base = wi_icon(base_names, options.delete(:base_options) || {})
66
+ icon = wi_icon(names, options.delete(:icon_options) || {})
67
+ icons = [base, icon]
68
+ icons.reverse! if options.delete(:reverse)
69
+ text = options.delete(:text)
70
+ stacked_icon = content_tag(:span, safe_join(icons), options.merge(:class => classes))
71
+ Private.icon_join(stacked_icon, text)
72
+ end
73
+
74
+ # Creates a list item with the specified icon as the marker.
75
+ # To be used with an ul tag having a class of wi-ul
76
+ #
77
+ # Examples
78
+ #
79
+ # wi_list_item('day-hail', 'Bad Weather Today')
80
+ # # => <li><i class="wi wi-day-hail wi-li"></i> Bad Weather Today</li>
81
+ #
82
+ # wi_list_item('day-hail md', 'Bad Weather Today', icon_options: {class: 'inverse'}, class: 'something' )
83
+ # # => <li class="something"><i class="wi wi-day-hail wi-md wi-li inverse"></i> Bad Weather Today</li>
84
+ def wi_list_item(icon_name, string, options={})
85
+ icons_options = {text: string}.merge(Hash(options[:icon_options]))
86
+ content_tag(:li, wi_icon("#{icon_name} li", icons_options), options.reject{|key,value| key == :icon_options})
87
+ end
88
+
89
+ # Creates an unordered list with the specified icon as the markers.
90
+ #
91
+ # Examples
92
+ #
93
+ # wi_list('day-hail', ['Bad Weather', 'Good Weather'])
94
+ # # => <ul class: 'wi-ul'>
95
+ # # => <li>
96
+ # # => <i class="wi wi-day-hail wi-li"></i> Bad Weather
97
+ # # => </li>
98
+ # # => <li>
99
+ # # => <i class="wi wi-day-hail wi-li"></i> Good Weather
100
+ # # => </li>
101
+ # # => </ul>
102
+ #
103
+ # wi_list('day-hail lg', ['Bad Weather', 'Good Weather'], icon_options: {class: 'pull-right'}, class: 'something' )
104
+ # # => <ul class: 'wi-ul'>
105
+ # # => <li class="something">
106
+ # # => <i class="wi wi-day-hail wi-lg wi-li pull-right"></i> Bad Weather
107
+ # # => </li>
108
+ # # => <li class="something">
109
+ # # => <i class="wi wi-day-hail wi-lg wi-li pull-right"></i> Good Weather
110
+ # # => </li>
111
+ # # => </ul>
112
+ def wi_list(icon_name, strings, options={})
113
+ list_items = strings.map { |str| wi_list_item(icon_name, str, options) }
114
+ content_tag(:ul, safe_join(list_items), class: Private.icon_names('ul'))
115
+ end
116
+
117
+ module Private
118
+ extend ActionView::Helpers::OutputSafetyHelper
119
+
120
+ def self.icon_join(icon, text)
121
+ return icon if text.blank?
122
+ safe_join([icon, ERB::Util.html_escape(text)], " ")
123
+ end
124
+
125
+ def self.icon_names(names = [])
126
+ array_value(names).map { |n| "wi-#{n}" }
127
+ end
128
+
129
+ def self.array_value(value = [])
130
+ value.is_a?(Array) ? value : value.to_s.split(/\s+/)
131
+ end
132
+ end
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,11 @@
1
+ require 'weather-icons/rails/helpers'
2
+
3
+ module WeatherIcons
4
+ module Rails
5
+ class Railtie < ::Rails::Railtie
6
+ initializer "weather-icons-rails.view_helpers" do
7
+ ActionView::Base.send :include, IconHelpers
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  module WeatherIcons
2
2
  module Rails
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weather-icons-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Schaaf
@@ -122,14 +122,10 @@ executables: []
122
122
  extensions: []
123
123
  extra_rdoc_files: []
124
124
  files:
125
- - LICENSE
126
- - README.md
127
- - Rakefile
128
125
  - app/assets/font/weathericons-regular-webfont.eot
129
126
  - app/assets/font/weathericons-regular-webfont.svg
130
127
  - app/assets/font/weathericons-regular-webfont.ttf
131
128
  - app/assets/font/weathericons-regular-webfont.woff
132
- - app/assets/stylesheets/weather-icons.css.scss
133
129
  - app/assets/stylesheets/weather-icons/_bootstrap.css.scss
134
130
  - app/assets/stylesheets/weather-icons/_bordered-pulled.css.scss
135
131
  - app/assets/stylesheets/weather-icons/_core.css.scss
@@ -144,23 +140,27 @@ files:
144
140
  - app/assets/stylesheets/weather-icons/_spinning.css.scss
145
141
  - app/assets/stylesheets/weather-icons/_stacked.css.scss
146
142
  - app/assets/stylesheets/weather-icons/_variables.css.scss
147
- - lib/weather-icons-rails.rb
148
- - lib/weather-icons/rails.rb
149
- - lib/weather-icons/rails/rails/engine.rb
150
- - lib/weather-icons/rails/rails/helpers.rb
151
- - lib/weather-icons/rails/rails/railtie.rb
143
+ - app/assets/stylesheets/weather-icons.css.scss
144
+ - lib/weather-icons/rails/engine.rb
145
+ - lib/weather-icons/rails/helpers.rb
146
+ - lib/weather-icons/rails/railtie.rb
152
147
  - lib/weather-icons/rails/version.rb
148
+ - lib/weather-icons/rails.rb
149
+ - lib/weather-icons-rails.rb
150
+ - LICENSE
151
+ - Rakefile
152
+ - README.md
153
153
  - test/dummy/app/assets/stylesheets/sass-import.css.sass
154
154
  - test/dummy/app/assets/stylesheets/scss-import.css.scss
155
155
  - test/dummy/app/assets/stylesheets/sprockets-require.css
156
156
  - test/dummy/app/controllers/pages_controller.rb
157
157
  - test/dummy/app/views/pages/icons.html.erb
158
- - test/dummy/config.ru
159
158
  - test/dummy/config/application.rb
160
159
  - test/dummy/config/boot.rb
161
160
  - test/dummy/config/environment.rb
162
161
  - test/dummy/config/initializers/secret_token.rb
163
162
  - test/dummy/config/routes.rb
163
+ - test/dummy/config.ru
164
164
  - test/font_awesome_rails_test.rb
165
165
  - test/icon_helper_test.rb
166
166
  - test/test_helper.rb
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  version: '0'
185
185
  requirements: []
186
186
  rubyforge_project:
187
- rubygems_version: 2.2.2
187
+ rubygems_version: 2.0.14
188
188
  signing_key:
189
189
  specification_version: 4
190
190
  summary: an asset gemification of the weather-icons icon font library
@@ -1,137 +0,0 @@
1
- module WeatherIcons
2
- module Rails
3
- module Rails
4
- module IconHelpers
5
- # Creates an icon tag given an icon name and possible icon
6
- # modifiers.
7
- #
8
- # Examples
9
- #
10
- # wi_icon "day-hail"
11
- # # => <i class="wi wi-day-hail"></i>
12
- #
13
- # wi_icon "day-hail", text: "Hailing Outside!"
14
- # # => <i class="wi wi-day-hail"></i> Hailing Outside
15
- #
16
- # wi_icon "day-hail 2x"
17
- # # => <i class="wi wi-day-hail wi-2x"></i>
18
- # wi_icon ["day-hail", "4x"]
19
- # # => <i class="wi wi-day-hail wi-4x"></i>
20
- # wi_icon "wi-day-hail spin lg"
21
- # # => <i class="wi wi-day-hail wi-spin wi-lg">
22
- #
23
- # wi_icon "day-hail 4x", class: "pull-left"
24
- # # => <i class="wi wi-day-hail wi-4x pull-left"></i>
25
- #
26
- # wi_icon "day-hail", data: { id: 123 }
27
- # # => <i class="wi wi-day-hail" data-id="123"></i>
28
- #
29
- # content_tag(:li, wi_icon("day-hail li", text: "Bulleted list item"))
30
- # # => <li><i class="wi wi-day-hail wi-li"></i> Bulleted list item</li>
31
- def wi_icon(names = "flag", options = {})
32
- classes = ['wi']
33
- classes.concat Private.icon_names(names)
34
- classes.concat Array(options.delete(:class))
35
- text = options.delete(:text)
36
- icon = content_tag(:i, nil, options.merge(:class => classes))
37
- Private.icon_join(icon, text)
38
- end
39
-
40
- # Creates an stack set of icon tags given a base icon name, a main icon
41
- # name, and possible icon modifiers.
42
- #
43
- # Examples
44
- #
45
- # wi_stacked_icon "day-hail", base: "day-cloudy-gusts"
46
- # # => <span class="wi-stack">
47
- # # => <i class="wi wi-day-cloudy-gusts wi-stack-2x"></i>
48
- # # => <i class="wi wi-day-hail wi-stack-1x"></i>
49
- # # => </span>
50
- #
51
- # wi_stacked_icon "day-hail inverse", base: "lightning", class: "pull-right", text: "Hi!"
52
- # # => <span class="wi-stack pull-right">
53
- # # => <i class="wi wi-lightning wi-stack-2x"></i>
54
- # # => <i class="wi wi-day-hail wi-inverse wi-stack-1x"></i>
55
- # # => </span> Hi!
56
- #
57
- # wi_stacked_icon "lightning", base: "day-cloudy-gusts", reverse: true
58
- # # => <span class="wi-stack">
59
- # # => <i class="wi wi-lightning wi-stack-1x"></i>
60
- # # => <i class="wi wi-day-cloudt-gusts wi-stack-2x"></i>
61
- # # => </span>
62
- def wi_stacked_icon(names = "flag", options = {})
63
- classes = Private.icon_names("stack").concat(Array(options.delete(:class)))
64
- base_names = Private.array_value(options.delete(:base) || "wi-lightning").push("stack-2x")
65
- names = Private.array_value(names).push("stack-1x")
66
- base = wi_icon(base_names, options.delete(:base_options) || {})
67
- icon = wi_icon(names, options.delete(:icon_options) || {})
68
- icons = [base, icon]
69
- icons.reverse! if options.delete(:reverse)
70
- text = options.delete(:text)
71
- stacked_icon = content_tag(:span, safe_join(icons), options.merge(:class => classes))
72
- Private.icon_join(stacked_icon, text)
73
- end
74
-
75
- # Creates a list item with the specified icon as the marker.
76
- # To be used with an ul tag having a class of wi-ul
77
- #
78
- # Examples
79
- #
80
- # wi_list_item('day-hail', 'Bad Weather Today')
81
- # # => <li><i class="wi wi-day-hail wi-li"></i> Bad Weather Today</li>
82
- #
83
- # wi_list_item('day-hail md', 'Bad Weather Today', icon_options: {class: 'inverse'}, class: 'something' )
84
- # # => <li class="something"><i class="wi wi-day-hail wi-md wi-li inverse"></i> Bad Weather Today</li>
85
- def wi_list_item(icon_name, string, options={})
86
- icons_options = {text: string}.merge(Hash(options[:icon_options]))
87
- content_tag(:li, wi_icon("#{icon_name} li", icons_options), options.reject{|key,value| key == :icon_options})
88
- end
89
-
90
- # Creates an unordered list with the specified icon as the markers.
91
- #
92
- # Examples
93
- #
94
- # wi_list('day-hail', ['Bad Weather', 'Good Weather'])
95
- # # => <ul class: 'wi-ul'>
96
- # # => <li>
97
- # # => <i class="wi wi-day-hail wi-li"></i> Bad Weather
98
- # # => </li>
99
- # # => <li>
100
- # # => <i class="wi wi-day-hail wi-li"></i> Good Weather
101
- # # => </li>
102
- # # => </ul>
103
- #
104
- # wi_list('day-hail lg', ['Bad Weather', 'Good Weather'], icon_options: {class: 'pull-right'}, class: 'something' )
105
- # # => <ul class: 'wi-ul'>
106
- # # => <li class="something">
107
- # # => <i class="wi wi-day-hail wi-lg wi-li pull-right"></i> Bad Weather
108
- # # => </li>
109
- # # => <li class="something">
110
- # # => <i class="wi wi-day-hail wi-lg wi-li pull-right"></i> Good Weather
111
- # # => </li>
112
- # # => </ul>
113
- def wi_list(icon_name, strings, options={})
114
- list_items = strings.map { |str| wi_list_item(icon_name, str, options) }
115
- content_tag(:ul, safe_join(list_items), class: Private.icon_names('ul'))
116
- end
117
-
118
- module Private
119
- extend ActionView::Helpers::OutputSafetyHelper
120
-
121
- def self.icon_join(icon, text)
122
- return icon if text.blank?
123
- safe_join([icon, ERB::Util.html_escape(text)], " ")
124
- end
125
-
126
- def self.icon_names(names = [])
127
- array_value(names).map { |n| "wi-#{n}" }
128
- end
129
-
130
- def self.array_value(value = [])
131
- value.is_a?(Array) ? value : value.to_s.split(/\s+/)
132
- end
133
- end
134
- end
135
- end
136
- end
137
- end
@@ -1,13 +0,0 @@
1
- require "weather-icons/rails/rails/helpers"
2
-
3
- module WeatherIcons
4
- module Rails
5
- module Rails
6
- class Railtie < ::Rails::Railtie
7
- initializer "weather-icons-rails.view_helpers" do
8
- ActionView::Base.send :include, IconHelpers
9
- end
10
- end
11
- end
12
- end
13
- end