foundation_rails_helper 2.0.0 → 3.0.0.beta3

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: eaf080baa48830a883681c55c892a30b366deabc
4
- data.tar.gz: 84a7e2dd8b70cbbe2b622a41bc9d3500bae8f396
3
+ metadata.gz: f82cdd3a1e082e60417f16ac49f49bac77b92aa9
4
+ data.tar.gz: 12c3e4a9a151295dab07c4d66e6cc7aaf603aa87
5
5
  SHA512:
6
- metadata.gz: b578327401357039bf3ec51d10c45c86f36183f86f682ea0b303c181da14278a7a3f4de4223c92c7c451d7dccba539eec8e7799c490c855bc7a9eabd7b70cfbc
7
- data.tar.gz: b8d41f62ad350069855247e1bdc1672c6ae08d549424768123dd67500e79eb5e1bcea1dbe820ef4e79822ec04a251f6eddf67cdde003c40bbc28e3fb725fbdbf
6
+ metadata.gz: 10148a13208ea0dfb88669e319e7b0e98c6f53cc013bfc96c152a245d21b69dc9c2853ce55dad19fadf6f00aee3e66ba9273c185f051999097d9379d9b4193dc
7
+ data.tar.gz: 6f6ae496a923551dc81d375689f056accc381e59c4990ffefeb664df9e4112fb1965693e65129664b5628ec81a8fd0c7155cd76f4cc879a42b3c09569939adc8
data/.rubocop.yml CHANGED
@@ -9,11 +9,8 @@ AllCops:
9
9
  Exclude:
10
10
  - 'vendor/**/*'
11
11
 
12
- # A quick fix for not having magic comments at the top of each file
13
- # # frozen_string_literal: true
14
- # https://github.com/bbatsov/rubocop/issues/3284
15
- FrozenStringLiteralComment:
16
- Enabled: false
17
-
18
12
  Documentation:
19
13
  Enabled: false
14
+
15
+ Style/VariableNumber:
16
+ EnforcedStyle: 'snake_case'
data/.rubocop_todo.yml CHANGED
@@ -1,67 +1,25 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2016-09-14 16:08:41 -0700 using RuboCop version 0.42.0.
3
+ # on 2017-01-13 13:27:28 -0800 using RuboCop version 0.44.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 3
10
- Lint/NestedMethodDefinition:
11
- Exclude:
12
- - 'spec/support/mock_rails.rb'
13
-
14
- # Offense count: 3
9
+ # Offense count: 1
15
10
  Metrics/AbcSize:
16
- Max: 179
11
+ Max: 17
17
12
 
18
13
  # Offense count: 1
19
14
  # Configuration parameters: CountComments.
20
15
  Metrics/ClassLength:
21
- Max: 186
16
+ Max: 183
22
17
 
23
18
  # Offense count: 1
24
19
  Metrics/CyclomaticComplexity:
25
20
  Max: 7
26
21
 
27
- # Offense count: 157
28
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
29
- # URISchemes: http, https
30
- Metrics/LineLength:
31
- Max: 163
32
-
33
- # Offense count: 5
34
- # Configuration parameters: CountComments.
35
- Metrics/MethodLength:
36
- Max: 55
37
-
38
22
  # Offense count: 1
39
23
  # Configuration parameters: CountComments.
40
- Metrics/ModuleLength:
41
- Max: 102
42
-
43
- # Offense count: 2
44
- # Configuration parameters: CountKeywordArgs.
45
- Metrics/ParameterLists:
46
- Max: 8
47
-
48
- # Offense count: 1
49
- Metrics/PerceivedComplexity:
50
- Max: 8
51
-
52
- # Offense count: 3
53
- # Configuration parameters: EnforcedStyle, SupportedStyles.
54
- # SupportedStyles: nested, compact
55
- Style/ClassAndModuleChildren:
56
- Exclude:
57
- - 'spec/support/mock_rails.rb'
58
-
59
- # Offense count: 1
60
- # Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
61
- # NamePrefix: is_, has_, have_
62
- # NamePrefixBlacklist: is_, has_, have_
63
- # NameWhitelist: is_a?
64
- Style/PredicateName:
65
- Exclude:
66
- - 'spec/**/*'
67
- - 'lib/foundation_rails_helper/form_builder.rb'
24
+ Metrics/MethodLength:
25
+ Max: 13
data/CHANGELOG.md CHANGED
@@ -1,8 +1,13 @@
1
+ ## Version 3.0.0
2
+ * Added Foundation 6 support
3
+ * Added auto_labels config
4
+
1
5
  ## Version 2.0
2
6
  This will be used for Foundation 5 support
3
7
 
4
8
  ### Breaking changes:
5
9
  * Dropped support for Ruby 1.9.3
10
+ * display_flash_messages now requires the key_matching hash to be prefixed with the keyword argument :key_matching
6
11
 
7
12
  ### Features:
8
13
  * Add Rubocop code style linting
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  source 'https://rubygems.org'
2
3
 
3
4
  # Specify your gem's dependencies in foundation_rails_helper.gemspec
data/README.md CHANGED
@@ -9,15 +9,14 @@ So far it includes:
9
9
 
10
10
  * A custom FormBuilder that generates a form using the Foundation framework classes. It replaces the current `form_for`, so there is no need to change your Rails code. Error messages are properly displayed.
11
11
 
12
- * A `display_flash_messages` helper method that uses Zurb Foundation Alerts UI.
12
+ * A `display_flash_messages` helper method that uses Zurb Foundation Callout UI.
13
13
 
14
14
  #### Compatibility
15
15
 
16
- * Only Rails 4.1/4.2/5 and Foundation 5 are fully supported
17
- * Some features may work with Foundation 4 and older, but results may vary, and markup which exists only for those versions will be gradually removed
18
- * Legacy branches exist for Rails 3 and 4.0 (see the rails3 and rails4.0 branches). These are not actively supported, and fixes are not retroactively applied, but pull requests are welcome.
19
- * We test against ruby versions 2.1 and up. This gem may still work fine on
20
- 1.9.3, but your mileage may vary
16
+ * Only Rails 4.1/4.2/5, and Foundation 6 are fully supported
17
+ * Some features may work with Foundation 5 and older, but results may vary, and markup which exists only for those versions will be gradually removed
18
+ * Legacy branches exist for Rails 3, 4.0, and Foundation 5 (see the rails3, rails4.0, and foundation-5 branches). These are not actively supported, and fixes are not retroactively applied, but pull requests are welcome.
19
+ * We test against ruby versions 2.1 and up. This gem may still work fine on 1.9.3, but your mileage may vary
21
20
 
22
21
 
23
22
  ## Screenshots
@@ -27,7 +26,7 @@ A classic devise sign up view will look like this:
27
26
 
28
27
  ```erb
29
28
  <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
30
- <%= f.email_field :email, label: 'E-mail' %>
29
+ <%= f.email_field :email %>
31
30
  <%= f.password_field :password %>
32
31
  <%= f.password_field :password_confirmation %>
33
32
 
@@ -45,10 +44,10 @@ A classic devise sign up view will look like this:
45
44
  <tbody>
46
45
  <tr>
47
46
  <td valign='top'>
48
- <img src="https://cloud.githubusercontent.com/assets/1400414/5994195/d9b467ce-aa1e-11e4-914c-f696724b53ed.png"/>
47
+ <img src="https://cloud.githubusercontent.com/assets/1400414/18522106/8b981524-7a63-11e6-8450-0605cc310205.png"/>
49
48
  </td>
50
49
  <td valign='top'>
51
- <img src="https://cloud.githubusercontent.com/assets/1400414/5994196/dbf4bc0a-aa1e-11e4-8c18-b7d3b1b370dc.png"/>
50
+ <img src="https://cloud.githubusercontent.com/assets/1400414/18522107/8d0bfa24-7a63-11e6-8c0a-12757528b9ee.png"/>
52
51
  </td>
53
52
  </tr>
54
53
  </tbody>
@@ -56,15 +55,15 @@ A classic devise sign up view will look like this:
56
55
 
57
56
  ### Flash messages
58
57
 
59
- ![Flash-message](https://cloud.githubusercontent.com/assets/393167/5845238/563dc094-a1b2-11e4-8548-2dd2950a60be.png "Flash-message")
58
+ ![Flash-message](https://cloud.githubusercontent.com/assets/1400414/18522256/3d13c97e-7a64-11e6-9ee2-33adc93cd573.png "Flash-message")
60
59
 
61
60
  ## Installation
62
61
 
63
62
  Add this line to your application's Gemfile:
64
63
 
65
64
  ```ruby
66
- gem 'foundation-rails'
67
- gem 'foundation_rails_helper', '~> 1.2.0'
65
+ gem 'foundation-rails', '~> 6.0' # required
66
+ gem 'foundation_rails_helper', '>= 3.0.0.beta3', '< 4.0'
68
67
  ```
69
68
 
70
69
  And then execute:
@@ -124,21 +123,21 @@ Change the label text and add a class on the label:
124
123
  f.text_field :name, label: 'Nombre', label_options: { class: 'large' }
125
124
  ```
126
125
 
127
- If the hint option is specified
126
+ If the help_text option is specified
128
127
 
129
128
  ```ruby
130
- f.text_field :name, hint: "I'm a text field"
129
+ f.text_field :name, help_text: "I'm a text field"
131
130
  ```
132
131
 
133
- an additional span element will be added after the input element:
132
+ an additional p element will be added after the input element:
134
133
 
135
134
  ```html
136
- <span class="hint">I'm a text field</span>
135
+ <p class="help-text">I'm a text field</p>
137
136
  ```
138
137
 
139
138
  ### Submit Button
140
139
 
141
- The 'submit' helper wraps the rails helper and sets the class attribute to "small radius success button" by default.
140
+ The 'submit' helper wraps the rails helper and sets the class attribute to "success button" by default.
142
141
 
143
142
  ```ruby
144
143
  f.submit
@@ -147,7 +146,7 @@ f.submit
147
146
  generates:
148
147
 
149
148
  ```html
150
- <input class="small radius success button" name="commit" type="submit" value="Create User">
149
+ <input class="success button" name="commit" type="submit" value="Create User">
151
150
  ```
152
151
 
153
152
  Specify the class option to override the default classes.
@@ -163,9 +162,9 @@ f.email_field :email
163
162
  generates:
164
163
 
165
164
  ```html
166
- <label class="error" for="user_email">Email</label>
167
- <input class="error" id="user_email" name="user[email]" type="email" value="">
168
- <small class="error">can't be blank</small>
165
+ <label class="is-invalid-label" for="user_email">Email</label>
166
+ <input class="is-invalid-input" id="user_email" name="user[email]" type="email" value="">
167
+ <small class="form-error is-visible">can't be blank</small>
169
168
  ```
170
169
 
171
170
  The class attribute of the 'small' element will mirror the class attribute of the 'input' element.
@@ -205,8 +204,8 @@ Currently supported options:
205
204
  ### Submit Button Class
206
205
  To use a different class for the [submit button](https://github.com/sgruhier/foundation_rails_helper#submit-button) used in `form_for`, add a config named **button_class**:
207
206
  ```ruby
208
- # Default: 'small radius success button'
209
- config.button_class = 'large secondary button'
207
+ # Default: 'success button'
208
+ config.button_class = 'large hollow secondary button'
210
209
  ```
211
210
 
212
211
  Please note, the button class can still be overridden by an options hash.
@@ -227,6 +226,4 @@ See the [CONTRIBUTING](CONTRIBUTING.md) file.
227
226
 
228
227
  ## Copyright
229
228
 
230
- Sébastien Gruhier (http://xilinus.com, http://v2.maptimize.com) - MIT LICENSE - 2015
231
-
232
- [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/sgruhier/foundation_rails_helper/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
229
+ Sébastien Gruhier (http://xilinus.com, http://v2.maptimize.com) - MIT LICENSE
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env rake
2
+ # frozen_string_literal: true
2
3
  require 'bundler/gem_tasks'
3
4
  require 'rspec/core/rake_task'
4
5
  require 'rubocop/rake_task'
@@ -1,39 +1,43 @@
1
- # -*- encoding: utf-8 -*-
1
+ # frozen_string_literal: true
2
2
  require File.expand_path('../lib/foundation_rails_helper/version', __FILE__)
3
3
 
4
- Gem::Specification.new do |gem|
5
- gem.authors = ['Sebastien Gruhier']
6
- gem.email = ['sebastien.gruhier@xilinus.com']
7
- gem.description = 'Rails for zurb foundation CSS framework. Form builder, flash message, ...'
8
- gem.summary = 'Rails helpers for zurb foundation CSS framework'
9
- gem.homepage = 'http://github.com/sgruhier/foundation_rails_helper'
10
-
11
- gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
12
- gem.files = `git ls-files`.split("\n")
13
- gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
- gem.name = 'foundation_rails_helper'
15
- gem.require_paths = ['lib']
16
- gem.version = FoundationRailsHelper::VERSION
17
- gem.license = 'MIT'
4
+ class Gem::Specification # rubocop:disable ClassAndModuleChildren
5
+ def self.rails_gem_version
6
+ # Allow different versions of the rails gems to be specified, for testing
7
+ @rails_gem_version ||=
8
+ if ENV['RAILS_VERSION']
9
+ "~> #{ENV['RAILS_VERSION']}"
10
+ else
11
+ ['~> 5.0', '>= 5.0.0']
12
+ end
13
+ end
14
+ end
18
15
 
19
- # Allow different versions of the rails gems to be specified, for testing:
20
- rails_version = ENV['RAILS_VERSION'] || 'default'
16
+ Gem::Specification.new do |gem|
17
+ gem.authors = ['Sebastien Gruhier']
18
+ gem.email = ['sebastien.gruhier@xilinus.com']
19
+ gem.description =
20
+ 'Rails for zurb foundation CSS framework. Form builder, flash message, ...'
21
+ gem.summary = 'Rails helpers for zurb foundation CSS framework'
22
+ gem.homepage = 'http://github.com/sgruhier/foundation_rails_helper'
21
23
 
22
- rails = case rails_version
23
- when 'default'
24
- '>= 4.1'
25
- else
26
- "~> #{rails_version}"
27
- end
24
+ gem.executables =
25
+ `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
26
+ gem.files = `git ls-files`.split("\n")
27
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
28
+ gem.name = 'foundation_rails_helper'
29
+ gem.require_paths = %w(lib)
30
+ gem.version = FoundationRailsHelper::VERSION
31
+ gem.license = 'MIT'
28
32
 
29
- gem.add_dependency 'railties', rails
30
- gem.add_dependency 'actionpack', rails
31
- gem.add_dependency 'activemodel', rails
32
- gem.add_dependency 'activesupport', rails
33
- gem.add_dependency 'tzinfo', '~> 1.2', '>= 1.2.2'
33
+ gem.add_dependency 'railties', Gem::Specification.rails_gem_version
34
+ gem.add_dependency 'actionpack', Gem::Specification.rails_gem_version
35
+ gem.add_dependency 'activemodel', Gem::Specification.rails_gem_version
36
+ gem.add_dependency 'activesupport', Gem::Specification.rails_gem_version
37
+ gem.add_dependency 'tzinfo', '~> 1.2', '>= 1.2.2'
34
38
 
35
- gem.add_development_dependency 'rspec-rails', '>= 3.1'
36
- gem.add_development_dependency 'mime-types', '~> 2'
37
- gem.add_development_dependency 'capybara', '~> 2.7'
38
- gem.add_development_dependency 'rubocop', '> 0.41'
39
+ gem.add_development_dependency 'rspec-rails', '~> 3.1'
40
+ gem.add_development_dependency 'mime-types', '~> 2'
41
+ gem.add_development_dependency 'capybara', '~> 2.7'
42
+ gem.add_development_dependency 'rubocop', '~> 0.44.1'
39
43
  end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
1
2
  require 'foundation_rails_helper/version'
2
3
  require 'foundation_rails_helper/configuration'
3
4
  require 'foundation_rails_helper/form_builder'
5
+ require 'foundation_rails_helper/size_class_calculator'
4
6
  require 'foundation_rails_helper/flash_helper'
5
7
  require 'foundation_rails_helper/action_view_extension'
6
8
  ActiveSupport.on_load(:action_view) do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ActionView::Base.default_form_builder = FoundationRailsHelper::FormBuilder
2
3
  ActionView::Base.field_error_proc = proc do |html_tag, _instance_tag|
3
4
  html_tag
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module FoundationRailsHelper
2
3
  class << self
3
4
  attr_writer :configuration
@@ -18,10 +19,12 @@ module FoundationRailsHelper
18
19
  class Configuration
19
20
  attr_accessor :button_class
20
21
  attr_accessor :ignored_flash_keys
22
+ attr_accessor :auto_labels
21
23
 
22
24
  def initialize
23
- @button_class = 'small radius success button'
25
+ @button_class = 'success button'
24
26
  @ignored_flash_keys = []
27
+ @auto_labels = true
25
28
  end
26
29
  end
27
30
  end
@@ -1,44 +1,71 @@
1
+ # frozen_string_literal: true
1
2
  require 'action_view/helpers'
2
3
 
3
4
  module FoundationRailsHelper
4
5
  module FlashHelper
5
- # <div class="alert-box [success alert secondary]">
6
+ # <div class="callout [success alert secondary]" data-closable>
6
7
  # This is an alert box.
7
- # <a href="" class="close">&times;</a>
8
+ # <button name="button" type="submit" class="close-button" data-close="">
9
+ # <span>&times;</span>
10
+ # </button>
8
11
  # </div>
9
12
  DEFAULT_KEY_MATCHING = {
10
- alert: :alert,
11
- notice: :success,
12
- info: :info,
13
+ alert: :alert,
14
+ notice: :success,
15
+ info: :info,
13
16
  secondary: :secondary,
14
- success: :success,
15
- error: :alert,
16
- warning: :warning
17
+ success: :success,
18
+ error: :alert,
19
+ warning: :warning,
20
+ primary: :primary
17
21
  }.freeze
18
- def display_flash_messages(key_matching = {})
22
+
23
+ # Displays the flash messages found in ActionDispatch's +flash+ hash using
24
+ # Foundation's +callout+ component.
25
+ #
26
+ # Parameters:
27
+ # * +closable+ - A boolean to determine whether the displayed flash messages
28
+ # should be closable by the user. Defaults to true.
29
+ # * +key_matching+ - A Hash of key/value pairs mapping flash keys to the
30
+ # corresponding class to use for the callout box.
31
+ def display_flash_messages(closable: true, key_matching: {})
19
32
  key_matching = DEFAULT_KEY_MATCHING.merge(key_matching)
20
- key_matching.default = :standard
33
+ key_matching.default = :primary
21
34
 
22
35
  capture do
23
36
  flash.each do |key, value|
24
- next if FoundationRailsHelper.configuration.ignored_flash_keys.include? key.to_sym
37
+ next if ignored_key?(key.to_sym)
38
+
25
39
  alert_class = key_matching[key.to_sym]
26
- concat alert_box(value, alert_class)
40
+ concat alert_box(value, alert_class, closable)
27
41
  end
28
42
  end
29
43
  end
30
44
 
31
45
  private
32
46
 
33
- def alert_box(value, alert_class)
34
- content_tag :div, data: { alert: '' }, class: "alert-box #{alert_class}" do
47
+ def alert_box(value, alert_class, closable)
48
+ options = { class: "flash callout #{alert_class}" }
49
+ options[:data] = { closable: '' } if closable
50
+ content_tag(:div, options) do
35
51
  concat value
36
- concat close_link
52
+ concat close_link if closable
37
53
  end
38
54
  end
39
55
 
40
56
  def close_link
41
- link_to('&times;'.html_safe, '#', class: :close)
57
+ button_tag(
58
+ class: 'close-button',
59
+ type: 'button',
60
+ data: { close: '' },
61
+ aria: { label: 'Dismiss alert' }
62
+ ) do
63
+ content_tag(:span, '&times;'.html_safe, aria: { hidden: true })
64
+ end
65
+ end
66
+
67
+ def ignored_key?(key)
68
+ FoundationRailsHelper.configuration.ignored_flash_keys.include?(key)
42
69
  end
43
70
  end
44
71
  end