effective_style_guide 1.3.7 → 1.3.8

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: 216aeae702c2c0e1f55229ca6b337d3f550c7aff
4
- data.tar.gz: 0ed0c1daf2fa7a52139aa974a8242eb4b683a2b2
3
+ metadata.gz: 18b0f17114ce0854f32a746049cb25c1b79fc53b
4
+ data.tar.gz: 120d946bd4e11ce36b5ae2ece495d85b341013cd
5
5
  SHA512:
6
- metadata.gz: 39ad4c8d26ebf06b3402d57725c43d909e61c31cbee47463558dcdc778012d0830d15ee3cc84696b5912de8ff28ad9e0b43d18ea1d48611f42fbbc2175c5d3df
7
- data.tar.gz: 82055edca53970a0c435a12d85749b23c94f9ed438d8ae1df7db04f4d7f003164abcca558a1cde3d3d5ca71dbe808b6ded92c53275f9ebf96cdff3ccf50d4853
6
+ metadata.gz: d59129ea4789365675891e6e0cd4bbbedb6d0844e446e63511620515946fc1afefb1b3ca86002457a2011e119bf20d4fbcd9dc2402969b2a655243888ffef9c4
7
+ data.tar.gz: 4fce52f5ca8b65936aaba06c563c127c8b1369b62daf8a5e02ba815ac28289d1470b6a70fec2d675032ef77248980f5b6931d47a65a43f25cf6ea97029a52f7b
data/README.md CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Ensure that your custom CSS theme looks good with all Twitter Bootstrap3 html components.
4
4
 
5
- Creates a /styleguide page that renders the correct HTML for all bootstrap3 (v3.2.0) components.
5
+ Creates a `/styleguide` page that renders the correct HTML for all bootstrap3 (v3.2.0) components.
6
6
 
7
7
  Use this page to ensure that your custom CSS theme looks good with the bootstrap3 components.
8
8
 
9
- Create a _my_component.html.erb partial in the /effective/style_guide/ directory to add your own custom components.
9
+ Create a `_my_component.html.erb` partial in the `views/effective/style_guide/` directory to add your own custom components.
10
10
 
11
11
  Works with simple_form to ensure that the generated form HTML matches the bootstrap3 HTML.
12
12
 
@@ -42,197 +42,34 @@ Visit `/styleguide` to test how the bootstrap3 components look with your site's
42
42
 
43
43
  ### Add Custom Components
44
44
 
45
- Create a _my_component.html.erb partial in the app/views/effective/style_guide/ directory.
45
+ Create a `_my_component.html.erb` partial in the `views/effective/style_guide/` directory.
46
46
 
47
- This file will be automatically detected and included in the /styleguide page.
47
+ This file will be automatically detected and included in the `/styleguide` page.
48
48
 
49
49
 
50
50
  ### simple_form
51
51
 
52
52
  simple_form (https://github.com/plataformatec/simple_form) is a pretty good FormBuilder gem.
53
53
 
54
- At this time of writing, the latest simple_form v3.2.1 includes a bootstrap3 config/initializer that gets very close to generating the correct bootstrap3 form HTML (as per bootstrap's example page).
54
+ At this time of writing, the latest simple_form v3.2.1 includes a bootstrap3 config/initializer that generates correct bootstrap3 form HTML (as per bootstrap's example page).
55
55
 
56
- Very close, but not quite perfect.
56
+ It does a great job with vertical and inline forms, but needs a little bit of help with the horizontal forms.
57
57
 
58
- It is also somewhat cumbersome to work with vertical, horizontal and inline forms from within the same app.
59
-
60
- Due to these limitations, we have created our own custom config/initializer that does generate the correct bootstrap3 form HTML.
61
-
62
- Here is the initializer:
58
+ Add the following snippet to the bottom of the `config/initializers/simple_form_bootstrap.rb` file:
63
59
 
64
60
  ```ruby
65
- SimpleForm.setup do |config|
66
- config.error_notification_class = 'alert alert-danger'
67
- config.button_class = 'btn btn-primary'
68
- config.boolean_label_class = nil
69
-
70
- config.boolean_style = :nested
71
- config.browser_validations = true
72
-
73
- config.form_class = ''
74
- config.default_wrapper = :vertical_form
75
-
76
- config.wrapper_mappings = {
77
- :boolean => :vertical_boolean,
78
- :check_boxes => :vertical_radio_and_checkboxes,
79
- :radio_buttons => :vertical_radio_and_checkboxes,
80
-
81
- :horizontal_form => {
82
- :boolean => :horizontal_boolean,
83
- :check_boxes => :horizontal_radio_and_checkboxes,
84
- :radio_buttons => :horizontal_radio_and_checkboxes
85
- }
86
- }
87
-
88
- config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
89
- b.use :html5
90
- b.use :placeholder
91
- b.optional :maxlength
92
- b.optional :pattern
93
- b.optional :min_max
94
- b.optional :readonly
95
- b.use :label, class: 'control-label'
96
-
97
- b.use :input, class: 'form-control'
98
- b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
99
- b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
100
- end
101
-
102
- config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
103
- b.use :html5
104
- b.use :placeholder
105
- b.optional :maxlength
106
- b.optional :readonly
107
- b.use :label, class: 'control-label'
108
-
109
- b.use :input
110
- b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
111
- b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
112
- end
113
-
114
- config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
115
- b.use :html5
116
- b.optional :readonly
117
-
118
- b.wrapper tag: 'div', class: 'checkbox' do |ba|
119
- ba.use :label_input
120
- end
121
-
122
- b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
123
- b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
124
- end
125
-
126
- config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
127
- b.use :html5
128
- b.optional :readonly
129
- b.use :label_input, :class => 'control-label'
130
- b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
131
- b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
132
- end
133
-
134
- config.wrappers :vertical_inline_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
135
- b.use :html5
136
- b.optional :readonly
137
-
138
- b.use :label, class: 'control-label'
139
-
140
- b.wrapper tag: 'div', class: 'inline-radio-or-checkboxes' do |ba|
141
- ba.use :input
142
- end
143
-
144
- b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
145
- b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
146
- end
147
-
148
- config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
149
- b.use :html5
150
- b.use :placeholder
151
- b.optional :maxlength
152
- b.optional :pattern
153
- b.optional :min_max
154
- b.optional :readonly
155
- b.use :label, class: 'col-sm-3 control-label'
156
-
157
- b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
158
- ba.use :input, class: 'form-control'
159
- ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
160
- ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
161
- end
162
- end
163
-
164
- config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
165
- b.use :html5
166
- b.use :placeholder
167
- b.optional :maxlength
168
- b.optional :readonly
169
- b.use :label, class: 'col-sm-3 control-label'
170
-
171
- b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
172
- ba.use :input
173
- ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
174
- ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
175
- end
176
- end
177
-
178
- config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
179
- b.use :html5
180
- b.optional :readonly
181
-
182
- b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr|
183
- wr.wrapper tag: 'div', class: 'checkbox' do |ba|
184
- ba.use :label_input, class: 'col-sm-9'
185
- end
186
-
187
- wr.use :error, wrap_with: { tag: 'span', class: 'help-block' }
188
- wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
189
- end
190
- end
191
-
192
- config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
193
- b.use :html5
194
- b.optional :readonly
195
-
196
- b.use :label, class: 'col-sm-3 control-label'
197
-
198
- b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
199
- ba.use :input
200
- ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
201
- ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
202
- end
203
- end
204
-
205
- config.wrappers :horizontal_inline_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
206
- b.use :html5
207
- b.optional :readonly
208
-
209
- b.use :label, class: 'col-sm-3 control-label'
210
-
211
- b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
212
- ba.wrapper tag: 'div', :class => 'inline-radio-or-checkboxes' do |bb|
213
- bb.use :input
214
- end
215
-
216
- ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
217
- ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
218
- end
219
- end
220
-
221
- config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
222
- b.use :html5
223
- b.use :placeholder
224
- b.optional :maxlength
225
- b.optional :pattern
226
- b.optional :min_max
227
- b.optional :readonly
228
- b.use :label, class: 'sr-only'
229
-
230
- b.use :input, class: 'form-control'
231
- b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
232
- b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
233
- end
234
-
235
- end
61
+ ### Custom as per Effective Style Guide ###
62
+ config.browser_validations = true
63
+
64
+ config.wrapper_mappings[:horizontal_form] = {
65
+ check_boxes: :horizontal_radio_and_checkboxes,
66
+ radio_buttons: :horizontal_radio_and_checkboxes,
67
+ file: :horizontal_file_input,
68
+ boolean: :horizontal_boolean,
69
+ datetime: :horizontal_radio_and_checkboxes,
70
+ date: :horizontal_radio_and_checkboxes,
71
+ time: :horizontal_radio_and_checkboxes
72
+ }
236
73
  ```
237
74
 
238
75
  To create a bootstrap3 vertical_form:
@@ -246,7 +83,7 @@ To create a bootstrap3 vertical_form:
246
83
  To create a bootstrap3 horizontal_form:
247
84
 
248
85
  ```ruby
249
- = simple_form_for(@post, :html => {:class => 'form-horizontal'}, :wrapper => :horizontal_form, :wrapper_mappings => SimpleForm.wrapper_mappings[:horizontal_form]) do |f|
86
+ = simple_form_for(@post, html: {class: 'form-horizontal'}, wrapper: :horizontal_form, wrapper_mappings: SimpleForm.wrapper_mappings[:horizontal_form]) do |f|
250
87
  # one or more inputs....
251
88
  .form-group
252
89
  .col-sm-offset-3.col-sm-9= f.button :submit
@@ -255,39 +92,11 @@ To create a bootstrap3 horizontal_form:
255
92
  To create a bootstrap3 inline_form:
256
93
 
257
94
  ```ruby
258
- = simple_form_for(@post, :html => {:class => 'form-inline'}, :wrapper => :inline_form) do |f|
95
+ = simple_form_for(@post, html: {class: 'form-inline'}, wrapper: :inline_form) do |f|
259
96
  # one or more inputs....
260
97
  = f.button :submit
261
98
  ```
262
99
 
263
- In all 3 of the above examples, the proper wrappers will be used to generate the correct HTML for every type of form field.
264
-
265
- This includes the frustrating booleans, radio and checkbox groups.
266
-
267
- One gotcha, if you'd like to use the 'Inline checkboxes and radios' component, you will need to pass a wrapper to the f.input.
268
-
269
- For a vertical_form or inline_form:
270
-
271
- ```ruby
272
- = f.input :favorite_drink, :as => :check_boxes, :wrapper => :vertical_inline_radio_and_checkboxes, :collection => ['Water', 'Tea', 'Coffee', 'Soda']
273
- ```
274
-
275
- For a horizontal_form:
276
-
277
- ```ruby
278
- = f.input :favorite_drink, :as => :check_boxes, :wrapper => :horizontal_inline_radio_and_checkboxes, :collection => ['Water', 'Tea', 'Coffee', 'Soda']
279
- ```
280
-
281
- And add the following CSS:
282
-
283
- ```css
284
- form .inline-radio-or-checkboxes > span {
285
- display: inline-block;
286
- margin: 0px 10px 0px 0px;
287
- }
288
- ```
289
-
290
-
291
100
  ## Authorization
292
101
 
293
102
  All authorization checks are handled via the config.authorization_method found in the config/initializers/ file.
@@ -7,7 +7,7 @@ module Effective
7
7
  end
8
8
 
9
9
  ATTRIBUTES = [
10
- :id, :title, :email, :password, :number, :range, :category, :content,
10
+ :id, :title, :email, :password, :number, :range, :category, :content, :phone,
11
11
  :archived, :drink, :food, :price, :updated_at, :publish_on, :static_text
12
12
  ]
13
13
 
@@ -1,4 +1,4 @@
1
- = simple_form_for Effective::StyleGuide.new(), :html => {:class => 'form-horizontal'}, :wrapper => :horizontal_form, :wrapper_mappings => SimpleForm.wrapper_mappings[:horizontal_form], :url => '/' do |f|
1
+ = simple_form_for Effective::StyleGuide.new(), :html => {:class => 'form-horizontal'}, :wrapper => :horizontal_form, :wrapper_mappings => (SimpleForm.wrapper_mappings[:horizontal_form] || SimpleForm.wrapper_mappings), :url => '/' do |f|
2
2
  = f.input :title, :hint => 'please enter a title (this is a standard text field)'
3
3
  = f.input :email, :hint => 'please enter an email address (this is an email field)'
4
4
  = f.input :password, :hint => 'please enter a password (this is a password field)'
@@ -31,20 +31,18 @@
31
31
  :collection => EffectiveStyleGuide.colors,
32
32
  :hint => 'please select a category (this is a select field)'
33
33
 
34
- = f.input :content, :hint => 'please enter a whole bunch of content (this is a textarea)'
35
- = f.input :archived, :hint => 'please select true or false (this is a boolean field)'
34
+ = f.input :content, :as => :text, :hint => 'please enter a whole bunch of content (this is a textarea)'
35
+ = f.input :archived, :as => :boolean, :hint => 'please select true or false (this is a boolean field)'
36
36
 
37
37
  = f.input :drink,
38
38
  :as => :check_boxes,
39
39
  :collection => EffectiveStyleGuide.foods,
40
- :hint => 'please select one or more drinks (this is a check_boxes :wrapper => :horizontal_radio_and_checkboxes field)',
41
- :wrapper => :horizontal_radio_and_checkboxes
40
+ :hint => 'please select one or more drinks (this is a check_boxes field)'
42
41
 
43
42
  = f.input :food,
44
43
  :as => :radio_buttons,
45
44
  :collection => EffectiveStyleGuide.foods,
46
- :hint => 'please select one food (this is a radio_buttons :wrapper => :horizontal_radio_and_checkboxes field)',
47
- :wrapper => :horizontal_radio_and_checkboxes
45
+ :hint => 'please select one food (this is a radio_buttons field)'
48
46
 
49
47
  - if defined?(EffectiveAssets)
50
48
  = f.input :files,
@@ -67,8 +65,14 @@
67
65
  = f.input :updated_at, :as => :datetime, :hint => 'please enter a date and time (this is a datetime field)'
68
66
  = f.input :publish_on, :as => :date, :hint => 'please enter a date (this is a date field)'
69
67
 
70
- - if defined?(EffectiveOrders)
71
- = f.input :price, :as => :price, :hint => 'please enter a price (this is a price field from EffectiveOrders)'
68
+ - if defined?(EffectiveFormInputs)
69
+ = f.input :phone,
70
+ :as => :effective_tel,
71
+ :hint => 'please enter a phone number (this is an effective_tel field from EffectiveFormInputs'
72
+
73
+ = f.input :price,
74
+ :as => :effective_price,
75
+ :hint => 'please enter a price (this is an effective_price field from EffectiveFormInputs'
72
76
 
73
77
  .form-group
74
78
  .col-sm-offset-3.col-sm-9
@@ -79,7 +83,7 @@
79
83
  %hr
80
84
  .inline-example Form Horizontal Invalid State
81
85
 
82
- = simple_form_for Effective::StyleGuide.new().tap { |s| s.valid? }, :html => {:class => 'form-horizontal'}, :wrapper => :horizontal_form, :wrapper_mappings => SimpleForm.wrapper_mappings[:horizontal_form], :url => '/' do |f|
86
+ = simple_form_for Effective::StyleGuide.new().tap { |s| s.valid? }, :html => {:class => 'form-horizontal'}, :wrapper => :horizontal_form, :wrapper_mappings => (SimpleForm.wrapper_mappings[:horizontal_form] || SimpleForm.wrapper_mappings), :url => '/' do |f|
83
87
  = f.input :title, :hint => 'please enter a title (this is a standard text field)'
84
88
  = f.input :email, :hint => 'please enter an email address (this is an email field)'
85
89
  = f.input :password, :hint => 'please enter a password (this is a password field)'
@@ -112,20 +116,18 @@
112
116
  :collection => EffectiveStyleGuide.colors,
113
117
  :hint => 'please select a category (this is a select field)'
114
118
 
115
- = f.input :content, :hint => 'please enter a whole bunch of content (this is a textarea)'
116
- = f.input :archived, :wrapper => :horizontal_boolean, :hint => 'please select true or false (this is a boolean field)'
119
+ = f.input :content, :as => :text, :hint => 'please enter a whole bunch of content (this is a textarea)'
120
+ = f.input :archived, :as => :boolean, :hint => 'please select true or false (this is a boolean field)'
117
121
 
118
122
  = f.input :drink,
119
123
  :as => :check_boxes,
120
124
  :collection => EffectiveStyleGuide.foods,
121
- :hint => 'please select one or more drinks (this is a check_boxes :wrapper => :horizontal_radio_and_checkboxes field)',
122
- :wrapper => :horizontal_radio_and_checkboxes
125
+ :hint => 'please select one or more drinks (this is a check_boxes field)'
123
126
 
124
127
  = f.input :food,
125
128
  :as => :radio_buttons,
126
129
  :collection => EffectiveStyleGuide.foods,
127
- :hint => 'please select one food (this is a radio_buttons :wrapper => :horizontal_radio_and_checkboxes field)',
128
- :wrapper => :horizontal_radio_and_checkboxes
130
+ :hint => 'please select one food (this is a radio_buttons field)'
129
131
 
130
132
  - if defined?(EffectiveAssets)
131
133
  = f.input :files,
@@ -148,8 +150,14 @@
148
150
  = f.input :updated_at, :as => :datetime, :hint => 'please enter a date and time (this is a datetime field)'
149
151
  = f.input :publish_on, :as => :date, :hint => 'please enter a date (this is a date field)'
150
152
 
151
- - if defined?(EffectiveOrders)
152
- = f.input :price, :as => :price, :hint => 'please enter a price (this is a price field from EffectiveOrders)'
153
+ - if defined?(EffectiveFormInputs)
154
+ = f.input :phone,
155
+ :as => :effective_tel,
156
+ :hint => 'please enter a phone number (this is an effective_tel field from EffectiveFormInputs)'
157
+
158
+ = f.input :price,
159
+ :as => :effective_price,
160
+ :hint => 'please enter a price (this is an effective_price field from EffectiveFormInputs)'
153
161
 
154
162
  .form-group
155
163
  .col-sm-offset-3.col-sm-9
@@ -38,12 +38,12 @@
38
38
  = f.input :drink,
39
39
  :as => :check_boxes,
40
40
  :collection => EffectiveStyleGuide.foods,
41
- :hint => 'please select one or more drinks (this is a check_boxes input)'
41
+ :hint => 'please select one or more drinks (this is a check_boxes field)'
42
42
 
43
43
  = f.input :food,
44
44
  :as => :radio_buttons,
45
45
  :collection => EffectiveStyleGuide.foods,
46
- :hint => 'please select one food (this is a radio_buttons input)'
46
+ :hint => 'please select one food (this is a radio_buttons field)'
47
47
 
48
48
  - if defined?(EffectiveAssets)
49
49
  = f.input :files,
@@ -66,8 +66,14 @@
66
66
  = f.input :updated_at, :as => :datetime, :hint => 'please enter a date and time (this is a datetime field)'
67
67
  = f.input :publish_on, :as => :date, :hint => 'please enter a date (this is a date field)'
68
68
 
69
- - if defined?(EffectiveOrders)
70
- = f.input :price, :as => :price, :hint => 'please enter a price (this is a price field from EffectiveOrders)'
69
+ - if defined?(EffectiveFormInputs)
70
+ = f.input :phone,
71
+ :as => :effective_tel,
72
+ :hint => 'please enter a phone number (this is an effective_tel field from EffectiveFormInputs)'
73
+
74
+ = f.input :price,
75
+ :as => :effective_price,
76
+ :hint => 'please enter a price (this is an effective_price field from EffectiveFormInputs)'
71
77
 
72
78
  = f.button :submit, 'Save', class: 'btn btn-primary'
73
79
  = f.button :submit, 'Save and Add New'
@@ -142,8 +148,14 @@
142
148
  = f.input :updated_at, :as => :datetime, :hint => 'please enter a date and time (this is a datetime field)'
143
149
  = f.input :publish_on, :as => :date, :hint => 'please enter a date (this is a date field)'
144
150
 
145
- - if defined?(EffectiveOrders)
146
- = f.input :price, :as => :price, :hint => 'please enter a price (this is a price field from EffectiveOrders)'
151
+ - if defined?(EffectiveFormInputs)
152
+ = f.input :phone,
153
+ :as => :effective_tel,
154
+ :hint => 'please enter a phone number (this is an effective_tel field from EffectiveFormInputs)'
155
+
156
+ = f.input :price,
157
+ :as => :effective_price,
158
+ :hint => 'please enter a price (this is an effective_price field from EffectiveFormInputs)'
147
159
 
148
160
  = f.button :submit, 'Save', class: 'btn btn-primary'
149
161
  = f.button :submit, 'Save and Add New'
@@ -1,3 +1,3 @@
1
1
  module EffectiveStyleGuide
2
- VERSION = '1.3.7'.freeze
2
+ VERSION = '1.3.8'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_style_guide
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.7
4
+ version: 1.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect