ui_bibz 0.9.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c22d9f108a0c988e153472f8e671e0bf3620645
4
- data.tar.gz: 03155c74f62d36939e283385ee5e94fe97dbccb4
3
+ metadata.gz: e9b5e5c5961f659178606b2dd173103b354d30a5
4
+ data.tar.gz: baf00289b1e6d83b0fbb745a37bf6b6ed228e753
5
5
  SHA512:
6
- metadata.gz: 9ce5c3f73a5c1024b33488c7e9d21dd261e283b0f1dd34b60eddbf387c0b9819b4e5bd7c70feb509bd4cf22aafa5195e36568329ad4ff3b376812c9e18e0ae3e
7
- data.tar.gz: 01adb5e71d609887af681e12af05e5cd704e1603cc215b8f09d102cfea0dea1401059c667f6dbce144841ec8b95d57ffa309c4ea3c8bc218bf5477fb6270731c
6
+ metadata.gz: 8237c309e39c06190b65e3c3fc22a7cdf7f127560eaeaf966d0e0e776ee1f9b01f22a1b51b802a9e27ec2d7ae31fb8fa245c221772450d5941e40042042232fd
7
+ data.tar.gz: 2fcf6075f582f357c3075d7a719d13418d0d8b07d011df5665f6f3890c924db239430de547e3f2dda1bfc312d96f0a2517193e72783e0c27dff68348f1ee9000
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ui_bibz (0.9.0)
4
+ ui_bibz (1.0.0)
5
5
  haml
6
6
  haml-rails
7
7
  rails (~> 4.2.0)
data/README.md CHANGED
@@ -6,21 +6,20 @@
6
6
 
7
7
  This project rocks and uses MIT-LICENSE.
8
8
 
9
- # UiBibz
9
+ # Ui Bibz
10
10
  > Ui Bibz est un [framework d'interface](http://fr.wikipedia.org/wiki/Framework_d%27interface)
11
11
  > permettant de construire une interface très rapidement et simplement
12
12
  > à l'aide de Ruby on Rails 4 et de Boostrap 3.
13
13
 
14
14
  Ui Bibz charge la librairie [boostrap](http://getbootstrap.com/) et
15
- [awesomefont](http://fontawesome.io/).
15
+ [awesomefont](http://fontawesome.io/) en [CDN](https://fr.wikipedia.org/wiki/Content_delivery_network).
16
16
 
17
17
  **NB** : [HAML](http://haml.info/) est utilisé pour présenter les exemples de chaque élément.
18
- Vous pouvez bien entendu utiliser l'interpréteur ERB dans votre application Rails.
18
+ Vous pouvez bien entendu utiliser l'interpréteur [ERB](https://en.wikipedia.org/wiki/ERuby) dans votre application Rails.
19
19
 
20
- Tous les composants du framework Ui Bibz comportent des *options* et des *html_options*.
20
+ Tous les composants du framework Ui Bibz comportent l'agument *options* et l'argument *html_options*.
21
21
  Ces éléments sont basés sur l'élément ```Component```.
22
22
  Un ```component``` accepte un contenu par variable ou par block.
23
- ex :
24
23
 
25
24
  ### Component
26
25
 
@@ -29,7 +28,7 @@ L'élément ```component``` accepte dans content et block :
29
28
 
30
29
  * le contenu
31
30
 
32
- L'élément ```component``` accepte en option les arguments :
31
+ L'élément ```component``` à pour ```options``` un Hash acceptant les clefs :
33
32
 
34
33
  * [state](#state-values)
35
34
  * [glyph](#glyph-arguments)
@@ -37,17 +36,18 @@ L'élément ```component``` accepte en option les arguments :
37
36
  * class
38
37
 
39
38
 
40
- L'élément ```component``` accepte en html_option les arguments :
39
+ L'élément ```component``` à pour ```html_options``` un Hash acceptant les clefs :
41
40
 
42
41
  * class
43
42
  * data
44
43
  * ...
45
44
 
46
- Ex :
45
+ Exemple :
46
+
47
47
  ```ruby
48
- Component.new 'Exemple', { state: :success }, { class: 'exemple' }
48
+ Component.new 'Exemple', { state: :success, glyph: { name: 'pencil', size: 3} }, { class: 'exemple' }
49
49
  # ou
50
- Component.new { state: :success }, { class: 'exemple' } do
50
+ Component.new { state: :success, glyph: 'eye' }, { class: 'exemple' } do
51
51
  'Exemple'
52
52
  end
53
53
  ```
@@ -67,7 +67,7 @@ dans ```options``` et ```html_options```.
67
67
  Ajouter la gem dans Rails :
68
68
 
69
69
  ```ruby
70
- gem "ui_bibz", '~> 0.9.0'
70
+ gem "ui_bibz", '~> 1.0.0'
71
71
  ```
72
72
 
73
73
  Lancer la command suivante :
@@ -92,6 +92,20 @@ Exemple :
92
92
  %body
93
93
  ```
94
94
 
95
+ Placer la ligne suivante dans ```/app/assets/stylesheets/applications.css```
96
+ ```ruby
97
+ ...
98
+ *= require ui_bibz
99
+ ...
100
+ ```
101
+
102
+ Placer la ligne suivante dans ```/app/assets/javascripts/applications.js```
103
+ ```ruby
104
+ ...
105
+ //= require ui_bibz
106
+ ...
107
+ ```
108
+
95
109
 
96
110
  ## Utilisation
97
111
 
@@ -99,7 +113,7 @@ Exemple :
99
113
 
100
114
  ![alert](doc/images/alert.png)
101
115
 
102
- L'élément ```notify``` accepte en option les arguments :
116
+ L'élément ```notify``` à pour ```options``` un Hash acceptant les clefs :
103
117
 
104
118
  * [state](#state-values)
105
119
  * [glyph](#glyph-arguments)
@@ -112,7 +126,7 @@ L'élément ```notify``` accepte en option les arguments :
112
126
 
113
127
  ![breadcrumb](doc/images/breadcrumb.png)
114
128
 
115
- L'élément ```breadcrumb``` accepte en option les arguments :
129
+ L'élément ```breadcrumb``` à pour ```options``` un Hash acceptant les clefs :
116
130
 
117
131
  * [status](#status-values)
118
132
  * [glyph](#glyph-arguments)
@@ -133,7 +147,7 @@ L'élément ```link``` est un [component](#component).
133
147
 
134
148
  ![button](doc/images/button.png)
135
149
 
136
- L'élément ```button``` accepte en option les arguments :
150
+ L'élément ```button``` à pour ```options``` un Hash acceptant les clefs :
137
151
 
138
152
  * [state](#state-values)
139
153
  * [status](#status-values)
@@ -146,7 +160,7 @@ L'élément ```button``` accepte en option les arguments :
146
160
 
147
161
  #### Button Dropdown
148
162
 
149
- L'élément ```button_dropdown``` accepte pour options les mêmes arguments que l'élément
163
+ L'élément ```button_dropdown``` accepte pour options les mêmes clefs que l'élément
150
164
  [dropdown](#dropdown).
151
165
 
152
166
  ![button_link](doc/images/button_dropdown.png)
@@ -163,12 +177,12 @@ L'élément ```button_dropdown``` accepte pour options les mêmes arguments que
163
177
 
164
178
  ![button_group](doc/images/button_group.png)
165
179
 
166
- L'élément ```button_group``` accepte pour options les arguments :
180
+ L'élément ```button_group``` à pour ```options``` un Hash acceptant les clefs :
167
181
 
168
182
  * position (:vertical, :horizontal)
169
183
  * [size](#size-values)
170
184
 
171
- L'élément ```list```accepte pour options les arguments :
185
+ L'élément ```list``` à pour ```options``` un Hash acceptant les clefs :
172
186
 
173
187
  * [status](#status-values)
174
188
  * [state](#state-values)
@@ -192,20 +206,21 @@ L'élément ```list```accepte pour options les arguments :
192
206
 
193
207
  #### Button Link (Lien Bouton)
194
208
 
195
- L'élément ```button_link```accepte pour options les arguments :
196
-
197
209
  ![button_link](doc/images/button_link.png)
210
+
211
+ L'élément ```button_link``` à pour ```options``` un Hash acceptant les clefs :
212
+
198
213
  ```ruby
199
214
  = button_link 'Button', { url: '#button', state: :primary, glyph: 'star' }, { class: 'my-button' }
200
215
  ```
201
216
 
202
217
  #### Button Split Dropdown
203
218
 
204
- L'élément ```button_split_dropdown```accepte pour options les mêmes arguments
205
- que l'élément [dropdown](#dropdown).
219
+ ![button_group](doc/images/button_split_dropdown.png)
206
220
 
221
+ L'élément ```button_split_dropdown```accepte pour options les mêmes clefs
222
+ que l'élément [dropdown](#dropdown).
207
223
 
208
- ![button_group](doc/images/button_split_dropdown.png)
209
224
  ```ruby
210
225
  = button_split_dropdown 'Dropdown', state: :primary do |d|
211
226
  - d.list do
@@ -218,13 +233,13 @@ que l'élément [dropdown](#dropdown).
218
233
 
219
234
  ### Dropdown
220
235
 
221
- L'élément ```dropdown```accepte pour options les arguments :
236
+ L'élément ```dropdown``` à pour ```options``` un Hash acceptant les clefs :
222
237
 
223
238
  * [state](#state-values)
224
239
  * [status](#status-values)
225
240
  * position (:left, :right)
226
241
 
227
- L'élément ```list``` est un [component](#component) qui accepte pour options les arguments :
242
+ L'élément ```list``` est un [component](#component) qui accepte pour options les clefs :
228
243
 
229
244
  * type (:header)
230
245
  * [glyph](#glyph-arguments)
@@ -240,19 +255,49 @@ L'élément ```list``` est un [component](#component) qui accepte pour options l
240
255
  ```
241
256
 
242
257
  Pour ajouter une ligne séparatrice, il suffit d'insérer 3 "-" à la suite
243
- ex :
258
+
259
+ Exemple :
260
+
244
261
  ```
245
262
  ...
246
263
  d.list '--'
247
264
  ...
248
265
  ```
249
266
 
267
+ ### Progress Bar
268
+
269
+ ![glyph](doc/images/progress_bar.png)
270
+
271
+ L'élément ```progress_bar``` à pour ```options``` un Hash acceptant les clefs :
272
+
273
+ * [state](#state-values)
274
+ * type (:animated, :striped)
275
+ * label - String (default: "percentage%")
276
+ * tap - Boolean (true: To add several bars)
277
+ * percentage_min - Integer (default: 0)
278
+ * percentage_max - Integer (default: 100)
279
+ * sr_only - Boolean to show label (default: false)
280
+
281
+ ```ruby
282
+ = progress_bar 30
283
+ # or
284
+ = progress_bar state: :info, sr_only: true, type: :animated do
285
+ = 70
286
+ # or
287
+ = progress_bar(tap: true) do |pb|
288
+ - pb.bar 10, { state: :success, label: 'Loading...' },{ class: 'test' }
289
+ - pb.bar 30, state: :warning
290
+ - pb.bar(type: :striped) do
291
+ = 10
292
+ ```
293
+
250
294
  ### Glyph
251
295
 
252
296
  ![glyph](doc/images/glyph.png)
253
297
 
254
298
  Les glyphs utilisés proviennent de [Font Awesome](http://fontawesome.io/).
255
- L'élément ```glyph``` accepte pour options les arguments :
299
+ L'élément ```glyph``` peut contenir un hash pour ```content```
300
+ L'élément ```glyph``` à pour ```options``` un Hash acceptant les clefs :
256
301
 
257
302
  * size
258
303
  * type
@@ -267,12 +312,13 @@ ou
267
312
 
268
313
  ![panel](doc/images/panel.png)
269
314
 
270
- L'élément ```panel``` accepte pour options les arguments :
315
+ L'élément ```panel``` à pour ```options``` un Hash acceptant les clefs :
271
316
 
272
317
  * [state](#state)
273
318
  * tap (true) : permet de créer un header, body et footer
274
319
 
275
320
  Les éléments ```header```, ```body```,```footer``` sont des éléments [component](#component).
321
+
276
322
  Exemple :
277
323
 
278
324
  ```ruby
@@ -292,14 +338,15 @@ Exemple :
292
338
 
293
339
  ![table](doc/images/table.png)
294
340
 
295
- L'élément ```table``` est un tableau composé d'une recherche, une pagination et un trie de colonnes intégré.
341
+ L'élément ```table``` est un tableau composé d'une recherche, une pagination et un trie de colonnes intégrées.
296
342
  Le tableau est compatible [I18n](http://guides.rubyonrails.org/i18n.html).
297
- Le tableau contient pour chaque ligne un bouton dropdown action avec par défaut
298
- ces 3 actions : voir, éditer, supprimer. Toute les colonnes sont présentent et
343
+ Le tableau contient pour chaque ligne un bouton dropdown 'action' avec par défaut
344
+ ces 3 actions : voir, éditer, supprimer. Toutes les colonnes sont présentes et
299
345
  affichées par défaut.
300
346
 
301
- La table doit contenir un store. Ce store est créé dans le controlleur avec la
347
+ La table doit contenir un store. Ce store doit-être créé dans le controlleur avec la
302
348
  méthode ```table_search_pagination```.
349
+
303
350
  La méthode ```table_search_pagination``` contient 3 arguments :
304
351
 
305
352
  * params
@@ -307,6 +354,7 @@ La méthode ```table_search_pagination``` contient 3 arguments :
307
354
  * args (optionel)
308
355
 
309
356
  Exemple :
357
+
310
358
  ```ruby
311
359
  # app/controllers/document_controller.rb
312
360
  @documents = Document.table_search_pagination(params, session)
@@ -316,12 +364,14 @@ Dans le model, insérer la méthode ```searchable_attributes``` afin de pouvoir
316
364
  faire une recherche sur les attributs souhaités.
317
365
 
318
366
  Exemple :
367
+
319
368
  ```ruby
320
369
  # app/models/document.rb
321
370
  searchable_attributes :name_fr, :name_en
322
371
  ```
323
372
 
324
373
  Un champ recherche est disponible dans la vue :
374
+
325
375
  ![table_search_field](doc/images/table_search_field.png)
326
376
 
327
377
  ```ruby
@@ -352,13 +402,14 @@ La méthode ```table_search_pagination``` contient 3 arguments :
352
402
  * args
353
403
 
354
404
  Exemple :
405
+
355
406
  ```ruby
356
407
  # app/controllers/document_controller.rb
357
408
  @documents = Document.table_search_pagination(params, session)
358
409
  ```
359
410
 
360
411
  Dans le **model**, insérer la méthode ```searchable_attributes``` afin de pouvoir
361
- faire une recherche pour les attributs souhaités.
412
+ faire une recherche sur les attributs souhaités.
362
413
 
363
414
  Exemple :
364
415
  ```ruby
@@ -380,7 +431,7 @@ Exemple :
380
431
  = table store: @documents
381
432
  ```
382
433
 
383
- Les actions par défauts peuvent être modifiées (voir exemple complexe) :
434
+ Les actions par défauts peuvent être modifiées ([voir exemple complexe](#Complex-Example-table)) :
384
435
 
385
436
  * edit
386
437
  * view
@@ -425,7 +476,7 @@ L'ajout de colonnes à travers la méthode ```add``` contient plusieurs argument
425
476
 
426
477
  #### Complex Example table
427
478
 
428
- Si on souhaite voir apparaître des liasions avec d'autres tables il faut pour
479
+ Si on souhaite voir apparaître certaines liasions avec d'autres tables il faut pour
429
480
  cela :
430
481
 
431
482
  Dans le controlleur, insérer la méthode ```table_search_pagination``` en ajoutant
@@ -439,7 +490,7 @@ Exemple :
439
490
 
440
491
  Dans la vue, insérer la méthod ```table```.
441
492
  NB: On peut créer ces propres méthodes comme ```user_name``` dans notre model "Document" et
442
- l'utiliser dans le data_index.
493
+ l'appeler comme valeur pour la clef ```data_index```.
443
494
 
444
495
  ```ruby
445
496
  # app/views/documents/index.html.haml
@@ -472,12 +523,12 @@ arguments = { sortable: {
472
523
  LEFT OUTER JOIN users ON users.id = products_users.user_id"
473
524
  } }
474
525
 
475
- @documents = Document.includes(:users).table_search_pagination(params, session,
476
- arguments)
526
+ @documents = Document.includes(:users).table_search_pagination(params, session, arguments)
477
527
  ```
478
528
 
479
529
  Ici l'argument sortable signifie que l'on souhaite s'interresser à la
480
530
  fonctionnalité de trie.
531
+
481
532
  Pour celà il faut :
482
533
 
483
534
  * définir le nom de la colonne triéé à travers l'argument ```column:``` (string)
@@ -524,7 +575,7 @@ activerecord:
524
575
 
525
576
  ![table_panel](doc/images/table_panel.png)
526
577
 
527
- Le composant ```table_panel``` est un tableau dans un panel.
578
+ Le composant ```table_panel``` est un [tableau](#table) dans un [panel](#panel).
528
579
 
529
580
  ```ruby
530
581
  = table_panel store: @users
@@ -547,8 +598,9 @@ Le composant ```table_panel``` est un tableau dans un panel.
547
598
 
548
599
  ![list](doc/images/list.png)
549
600
 
550
- Par défaut une liste à pour tag ```<li>```. Mais elle peut se transformer en lien ```<a>```
551
- à travers l'option ```type:```. Par défaut le tag ```<li>``` est présent.
601
+ Par défaut une liste à pour tag ```<li>```.
602
+ Mais elle peut se transformer en lien ```<a>``` à travers l'option ```type:```.
603
+ Par défaut le tag ```<li>``` est présent.
552
604
 
553
605
  ```ruby
554
606
  = list_group type: :link do |lg|
@@ -581,7 +633,24 @@ L'élement link est un [component](#component).
581
633
  d.link 'Test2', url: '#test2', status: :active
582
634
  ```
583
635
 
584
- ### Label
636
+ ### Etiquette
637
+
638
+ ![list](doc/images/etiquette.png)
639
+
640
+
641
+ NB : Les méthodes ```Tag, label``` sont déjà utilisées par Rails.
642
+ L'élément ```etiquette``` à pour ```options``` un Hash acceptant les clefs :
643
+
644
+ * [state](#state-values)
645
+ * [glyph](#glyph-values)
646
+
647
+ Exemple :
648
+
649
+ ```ruby
650
+ = etiquette 'label'
651
+ = etiquette 'label 2', state: :success
652
+ = etiquette 'label 2', state: :danger
653
+ ```
585
654
 
586
655
  ### Row
587
656
 
@@ -720,9 +789,16 @@ UiBibz::Ui::Panel.new('Exemple', { state: :success }, { class: 'exemple'}).rende
720
789
  panel 'Exemple', { state: :success }, { class: 'exemple' }
721
790
  ```
722
791
 
723
- # A faire :
792
+ # Roadmap :
793
+
794
+ Pour la V2.
724
795
 
725
- * progress bar
726
- * media
796
+ * créer des stores pour les listes, breadcrumb
797
+ * créer une meilleure documentation
798
+ * créer d'autres extensions, plugins et une guideline
799
+ * donner le choix de la dépendence boostrap et awesomefont en CDN ou en local
800
+ * mise à jour vers bootstrap 4
801
+ * créer Ui-Bibz Core à partir de cette librairie ( pour l'insérer dans un nouveau
802
+ framework Ui-Bibz utilisant simple_form pour les champs formulaires ).
727
803
  ...
728
804
 
Binary file
Binary file
@@ -1,8 +1,7 @@
1
1
  module UiBibz::Helpers::UiHelper
2
2
 
3
3
  def panel content = nil, options = nil, html_options = nil, &block
4
- is_tap = (content[:tap] if content.kind_of?(Hash)) || (options[:tap] unless options.nil?)
5
- if is_tap
4
+ if is_tap(content, options)
6
5
  UiBibz::Ui::Panel.new(content, options, html_options).tap(&block).render
7
6
  else
8
7
  UiBibz::Ui::Panel.new(content, options, html_options, &block).render
@@ -14,8 +13,8 @@ module UiBibz::Helpers::UiHelper
14
13
  UiBibz::Ui::Alert.new(content, options, html_options, &block).render
15
14
  end
16
15
 
17
- # Use "lab" instead of "label" : due to "actionview (4.2.0) lib/action_view/helpers/form_helper.rb" conflict
18
- def lab content = nil, options = nil, html_options = nil, &block
16
+ # Use "etiquette" instead of "label" : due to "actionview (4.2.0) lib/action_view/helpers/form_helper.rb" conflict
17
+ def etiquette content = nil, options = nil, html_options = nil, &block
19
18
  UiBibz::Ui::Label.new(content, options, html_options, &block).render
20
19
  end
21
20
 
@@ -38,8 +37,7 @@ module UiBibz::Helpers::UiHelper
38
37
  # Table section begin ------------------------------------------------------
39
38
 
40
39
  def table content = nil, options = nil, html_options = nil, &block
41
- is_tap = (content[:tap] if content.kind_of?(Hash)) || (options[:tap] unless options.nil?)
42
- if is_tap
40
+ if is_tap(content, options)
43
41
  UiBibz::Ui::Table.new(content, options, html_options).tap(&block).render
44
42
  else
45
43
  UiBibz::Ui::Table.new(content, options, html_options, &block).render
@@ -59,8 +57,7 @@ module UiBibz::Helpers::UiHelper
59
57
  end
60
58
 
61
59
  def table_panel content = nil, options = nil, html_options = nil, &block
62
- is_tap = (content[:tap] if content.kind_of?(Hash)) || (options[:tap] unless options.nil?)
63
- if is_tap
60
+ if is_tap(content, options)
64
61
  UiBibz::Ui::TablePanel.new(content, options, html_options).tap(&block).render
65
62
  else
66
63
  UiBibz::Ui::TablePanel.new(content, options, html_options, &block).render
@@ -105,4 +102,18 @@ module UiBibz::Helpers::UiHelper
105
102
  UiBibz::Ui::Glyph.new(content, options, html_options, &block).render
106
103
  end
107
104
 
105
+ def progress_bar percentage = nil, options = nil, html_options = nil, &block
106
+ if is_tap(percentage, options)
107
+ UiBibz::Ui::ProgressBar.new(percentage, options, html_options).tap(&block).render
108
+ else
109
+ UiBibz::Ui::ProgressBar.new(percentage, options, html_options, &block).render
110
+ end
111
+ end
112
+
113
+ private
114
+
115
+ def is_tap content, options
116
+ (content[:tap] if content.kind_of?(Hash)) || (options[:tap] unless options.nil?)
117
+ end
118
+
108
119
  end
@@ -31,7 +31,7 @@ module UiBibz::Ui
31
31
  #
32
32
  # ==== Examples
33
33
  #
34
- # UiBibz::Ui::Label.new(content, type: :success).render
34
+ # UiBibz::Ui::Label.new(content, state: :success).render
35
35
  #
36
36
  # UiBibz::Ui::Label.new() do
37
37
  # #content
@@ -0,0 +1,103 @@
1
+ module UiBibz::Ui
2
+
3
+ # Create a NavLink
4
+ #
5
+ # This element is an extend of UiBibz::Ui::Component.
6
+ #
7
+ # ==== Attributes
8
+ #
9
+ # * +content+ - Content of element
10
+ # * +options+ - Options of element
11
+ # * +html_options+ - Html Options of element
12
+ #
13
+ # ==== Options
14
+ #
15
+ # You can add HTML attributes using the +html_options+.
16
+ # You can pass arguments in options attribute:
17
+ # * +state+ - State of élement with symbol value:
18
+ # (+:default+, +:primary+, +:info+, +:warning+, +:danger+)
19
+ # * label - String (default: "percentage%")
20
+ # * percentage_min - Integer (default: 0)
21
+ # * percentage_max - Integer (default: 100)
22
+ # * sr_only - Boolean to show label (default: false)
23
+ # * type
24
+ # (+:striped+, +:animated+)
25
+ #
26
+ # ==== Signatures
27
+ #
28
+ # UiBibz::Ui::Bar.new(percentage, options = nil, html_options = nil)
29
+ #
30
+ # UiBibz::Ui::Bar.new(options = nil, html_options = nil) do
31
+ # percentage
32
+ # end
33
+ #
34
+ # ==== Examples
35
+ #
36
+ # UiBibz::Ui::Bar.new(10)
37
+ # # or
38
+ # UiBibz::Ui::Bar.new(10, { state: :success, sr_only: true, label: 'Loading...' },{ class: 'test' }).render
39
+ # # or
40
+ # UiBibz::Ui::Bar.new({ state: :primary }) do
41
+ # 40
42
+ # end.render
43
+ #
44
+ class Bar < Component
45
+
46
+ def initialize content = nil, options = nil, html_options = nil, &block
47
+ super
48
+ end
49
+
50
+ def render
51
+ content_tag :div, progressbar_inner_html, class_and_html_options(['progress-bar', type]).merge(bar_html_options)
52
+ end
53
+
54
+ private
55
+
56
+ def bar_html_options
57
+ {
58
+ "role" => 'progressbar',
59
+ "aria-valuenow" => percentage,
60
+ "aria-valuemin" => percentage_min,
61
+ "aria-valuemax" => percentage_max,
62
+ "style" => "width: #{ percentage }%"
63
+ }
64
+ end
65
+
66
+ def progressbar_inner_html
67
+ sr_only ? content_tag(:span, label, class: 'sr-only') : label
68
+ end
69
+
70
+ def percentage
71
+ @content || 0
72
+ end
73
+
74
+ def sr_only
75
+ @options[:sr_only] || false
76
+ end
77
+
78
+ def percentage_min
79
+ @options[:percentage_min] || 0
80
+ end
81
+
82
+ def percentage_max
83
+ @options[:percentage_max] || 100
84
+ end
85
+
86
+ def label
87
+ @options[:label].nil? ? "#{ percentage }%" : @options[:label]
88
+ end
89
+
90
+ def type
91
+ if @options[:type] == :animated
92
+ "progress-bar-striped active"
93
+ elsif @options[:type]
94
+ "progress-bar-#{ @options[:type] }"
95
+ end
96
+ end
97
+
98
+ def state
99
+ "progress-bar-#{ @options[:state] }" unless @options[:state].nil?
100
+ end
101
+
102
+ end
103
+ end
@@ -0,0 +1,79 @@
1
+ require 'ui_bibz/ui/progress_bar/components/bar'
2
+ module UiBibz::Ui
3
+
4
+ # Create a progress bar
5
+ #
6
+ # This element is an extend of UiBibz::Ui::Component.
7
+ #
8
+ # ==== Attributes
9
+ #
10
+ # * +content+ - Content of element
11
+ # * +options+ - Options of element
12
+ # * +html_options+ - Html Options of element
13
+ #
14
+ # ==== Options
15
+ #
16
+ # You can add HTML attributes using the +html_options+.
17
+ # You can pass arguments in options attribute:
18
+ # * +state+ - State of élement with symbol value:
19
+ # (+:default+, +:primary+, +:info+, +:warning+, +:danger+)
20
+ # * label - String (default: "percentage%")
21
+ # * tap - Boolean (true: To add several bars)
22
+ # * percentage_min - Integer (default: 0)
23
+ # * percentage_max - Integer (default: 100)
24
+ # * sr_only - Boolean to show label (default: false)
25
+ # * type
26
+ # (+:striped+, +:animated+)
27
+ #
28
+ #
29
+ # ==== Signatures
30
+ #
31
+ # UiBibz::Ui::ProgressBar.new(percentage, options = nil, html_options = nil)
32
+ #
33
+ # UiBibz::Ui::ProgressBar.new(options = nil, html_options = nil) do
34
+ # percentage
35
+ # end
36
+ #
37
+ # UiBibz::Ui::ProgressBar.new(tap: true).tap do |pb|
38
+ # pb.bar percentage, options = nil, html_options = nil
39
+ # pb.bar options = nil, html_options = nil do
40
+ # percentage
41
+ # end
42
+ # end
43
+ #
44
+ # ==== Examples
45
+ #
46
+ # UiBibz::Ui::ProgressBar.new(50)
47
+ # # or
48
+ # UiBibz::Ui::ProgressBar.new(10, { state: :success, sr_only: false, label: 'Loading...' },{ class: 'test' }).render
49
+ # # or
50
+ # UiBibz::Ui::ProgressBar.new(tap: true).tap |pb|
51
+ # pb.bar 10, { state: :success, sr_only: false, label: 'Loading...' },{ class: 'test' }
52
+ # pb.bar { state: :primary } do
53
+ # 20
54
+ # end
55
+ # end.render
56
+ #
57
+ class ProgressBar < Component
58
+
59
+ def initialize content = nil, options = nil, html_options = nil, &block
60
+ super
61
+ @bars = []
62
+ end
63
+
64
+ def render
65
+ content_tag :div, content, class: 'progress'
66
+ end
67
+
68
+ def bar content = nil, options = nil, html_options = nil, &block
69
+ @bars << Bar.new(content, options, html_options, &block).render
70
+ end
71
+
72
+ private
73
+
74
+ def content
75
+ @options[:tap] ? @bars.join().html_safe : Bar.new(@content, @options, @html_options).render
76
+ end
77
+
78
+ end
79
+ end
@@ -107,7 +107,7 @@ module UiBibz::Ui
107
107
  end
108
108
 
109
109
  def type
110
- "table-#{ @options[:type] }"
110
+ "table-#{ @options[:type] }" unless @options[:type].nil?
111
111
  end
112
112
 
113
113
  def table_html
@@ -29,7 +29,7 @@ module UiBibz::Ui
29
29
  private
30
30
 
31
31
  def dropdown_action record
32
- UiBibz::Ui::Dropdown.new(dropdown_action_name, { position: :right, glyph: actions_glyph }, class: 'btn-group-xs').tap do |d|
32
+ UiBibz::Ui::Dropdown.new(dropdown_action_name, { position: :right, glyph: actions_glyph }, class: 'btn-group-xs dropdown-action').tap do |d|
33
33
  unless @actions.nil?
34
34
  actions_links(record).each do |l|
35
35
  d.list l.html_safe
@@ -1,3 +1,3 @@
1
1
  module UiBibz
2
- VERSION = "0.9.0"
2
+ VERSION = "1.0.0"
3
3
  end
data/lib/ui_bibz.rb CHANGED
@@ -1,6 +1,4 @@
1
-
2
1
  require 'action_view'
3
- #require 'haml/helpers'
4
2
  require 'will_paginate'
5
3
  require 'will-paginate-i18n'
6
4
 
@@ -8,12 +6,6 @@ module UiBibz
8
6
 
9
7
  mattr_accessor :app_root
10
8
 
11
- # Yield self on setup for nice config blocks
12
- # Maybe remove ?
13
- def self.setup
14
- yield self
15
- end
16
-
17
9
  module Ui
18
10
  autoload :Alert, "ui_bibz/ui/alert"
19
11
  autoload :Breadcrumb, "ui_bibz/ui/breadcrumb/breadcrumb"
@@ -32,6 +24,7 @@ module UiBibz
32
24
  autoload :ListGroup, "ui_bibz/ui/list/list_group"
33
25
  autoload :Nav, "ui_bibz/ui/nav/nav"
34
26
  autoload :Panel, "ui_bibz/ui/panel"
27
+ autoload :ProgressBar, "ui_bibz/ui/progress_bar/progress_bar"
35
28
  autoload :Row, "ui_bibz/ui/grid/components/row"
36
29
  autoload :Tab, "ui_bibz/ui/nav/tab"
37
30
  autoload :Table, "ui_bibz/ui/table/table"
@@ -56,5 +49,4 @@ module UiBibz
56
49
 
57
50
  end
58
51
 
59
-
60
52
  require "ui_bibz/rails/engine"
@@ -109,8 +109,7 @@ class TableTest < ActionView::TestCase
109
109
  options = { actionable: true }
110
110
  action = UiBibz::Ui::Actionable.new(@store, options)
111
111
  actual = action.body @store.records.first, []
112
- expected = ["<td><div class=\"btn-group-xs dropdown\"><button class=\"btn btn-default dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\" aria-expanded=\"false\"><i class=\"glyph fa fa-ellipsis-v fa-fw\"></i> Actions <span class=\"caret\"></span></button><ul class=\"dropdown-menu dropdown-menu-right\" role=\"menu\"></ul></div></td>"]
113
-
112
+ expected = ["<td><div class=\"btn-group-xs dropdown-action dropdown\"><button class=\"btn btn-default dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\" aria-expanded=\"false\"><i class=\"glyph fa fa-ellipsis-v fa-fw\"></i> Actions <span class=\"caret\"></span></button><ul class=\"dropdown-menu dropdown-menu-right\" role=\"menu\"></ul></div></td>"]
114
113
 
115
114
  assert_equal expected, actual
116
115
  end
data/test/ui_bibz_test.rb CHANGED
@@ -4,10 +4,4 @@ class UiBibzTest < ActiveSupport::TestCase
4
4
  test "truth" do
5
5
  assert_kind_of Module, UiBibz
6
6
  end
7
-
8
- test 'setup block yields self' do
9
- UiBibz.setup do |config|
10
- assert_equal UiBibz, config
11
- end
12
- end
13
7
  end
@@ -20,8 +20,8 @@ class UiHelperTest < ActionView::TestCase
20
20
  assert_equal expected, actual
21
21
  end
22
22
 
23
- test 'label' do
24
- actual = lab 'toto', state: :success, glyph: 'pencil'
23
+ test 'etiquette' do
24
+ actual = etiquette 'toto', state: :success, glyph: 'pencil'
25
25
  expected = "<span class=\"label-success label\"><i class=\"glyph fa fa-pencil\"></i> toto</span>"
26
26
 
27
27
  assert_equal expected, actual
@@ -41,4 +41,22 @@ class UiHelperTest < ActionView::TestCase
41
41
  assert_equal expected, actual
42
42
  end
43
43
 
44
+ test 'progress bar' do
45
+ actual = progress_bar 30
46
+ expected = "<div class=\"progress\"><div class=\"progress-bar\" role=\"progressbar\" aria-valuenow=\"30\" aria-valuemin=\"0\" aria-valuemax=\"100\" style=\"width: 30%\">30%</div></div>"
47
+
48
+ assert_equal expected, actual
49
+ end
50
+
51
+ test 'progress bar with several bars' do
52
+ actual = progress_bar(tap: true) do |pb|
53
+ pb.bar 20, type: :animated
54
+ pb.bar 30, state: :success
55
+ pb.bar 10, type: :striped
56
+ end
57
+ expected = "<div class=\"progress\"><div class=\"progress-bar progress-bar-striped active\" role=\"progressbar\" aria-valuenow=\"20\" aria-valuemin=\"0\" aria-valuemax=\"100\" style=\"width: 20%\">20%</div><div class=\"progress-bar-success progress-bar\" role=\"progressbar\" aria-valuenow=\"30\" aria-valuemin=\"0\" aria-valuemax=\"100\" style=\"width: 30%\">30%</div><div class=\"progress-bar progress-bar-striped\" role=\"progressbar\" aria-valuenow=\"10\" aria-valuemin=\"0\" aria-valuemax=\"100\" style=\"width: 10%\">10%</div></div>"
58
+
59
+ assert_equal expected, actual
60
+ end
61
+
44
62
  end
data/ui_bibz.gemspec CHANGED
@@ -9,9 +9,9 @@ Gem::Specification.new do |s|
9
9
  s.version = UiBibz::VERSION
10
10
  s.authors = ["Thooams"]
11
11
  s.email = ["thooams@gmail.com"]
12
- s.homepage = "https://github.com/thooams/ui-bibz"
13
- s.summary = "A Rails plugin with Boostrap framework..."
14
- s.description = "A Rails plugin with Boostrap framework..."
12
+ s.homepage = "http://thooams.github.io/Ui-Bibz/"
13
+ s.summary = "A Rails Bootstrap framework..."
14
+ s.description = "A Rails Boostrap framework..."
15
15
  s.license = "MIT"
16
16
 
17
17
  s.files = `git ls-files`.split("\n")
@@ -24,14 +24,14 @@
24
24
  width: 75px
25
25
  display: inline-block
26
26
 
27
- .table-hover>tbody>tr:hover
28
- td:last-child .dropdown
27
+ .table>tbody>tr:hover
28
+ td:last-child .dropdown-action
29
29
  display: block
30
30
 
31
- .table-hover>tbody>tr
31
+ .table>tbody>tr
32
32
  td:last-child
33
33
  height: 39px
34
- .dropdown
34
+ .dropdown-action
35
35
  display: none
36
36
 
37
37
  .table-search-field
@@ -42,5 +42,5 @@
42
42
 
43
43
  .table
44
44
  .action
45
- width: 92px
45
+ width: 100px
46
46
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ui_bibz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thooams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-06 00:00:00.000000000 Z
11
+ date: 2015-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -164,7 +164,7 @@ dependencies:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
- description: A Rails plugin with Boostrap framework...
167
+ description: A Rails Boostrap framework...
168
168
  email:
169
169
  - thooams@gmail.com
170
170
  executables: []
@@ -188,10 +188,12 @@ files:
188
188
  - doc/images/button_group.png
189
189
  - doc/images/button_link.png
190
190
  - doc/images/button_split_dropdown.png
191
+ - doc/images/etiquette.png
191
192
  - doc/images/glyph.png
192
193
  - doc/images/list.png
193
194
  - doc/images/nav.png
194
195
  - doc/images/panel.png
196
+ - doc/images/progress_bar.png
195
197
  - doc/images/table.png
196
198
  - doc/images/table_pagination_per_page.png
197
199
  - doc/images/table_panel.png
@@ -227,6 +229,8 @@ files:
227
229
  - lib/ui_bibz/ui/nav/components/nav_link.rb
228
230
  - lib/ui_bibz/ui/nav/nav.rb
229
231
  - lib/ui_bibz/ui/panel.rb
232
+ - lib/ui_bibz/ui/progress_bar/components/bar.rb
233
+ - lib/ui_bibz/ui/progress_bar/progress_bar.rb
230
234
  - lib/ui_bibz/ui/table/components/actions.rb
231
235
  - lib/ui_bibz/ui/table/components/column.rb
232
236
  - lib/ui_bibz/ui/table/components/columns.rb
@@ -309,7 +313,7 @@ files:
309
313
  - ui_bibz.gemspec
310
314
  - vendor/assets/javascripts/ui_bibz.js.coffee
311
315
  - vendor/assets/stylesheets/ui_bibz.sass
312
- homepage: https://github.com/thooams/ui-bibz
316
+ homepage: http://thooams.github.io/Ui-Bibz/
313
317
  licenses:
314
318
  - MIT
315
319
  metadata: {}
@@ -332,7 +336,7 @@ rubyforge_project:
332
336
  rubygems_version: 2.4.5
333
337
  signing_key:
334
338
  specification_version: 4
335
- summary: A Rails plugin with Boostrap framework...
339
+ summary: A Rails Bootstrap framework...
336
340
  test_files:
337
341
  - test/dummy/README.rdoc
338
342
  - test/dummy/Rakefile