voom-presenters 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +4 -1
  3. data/Gemfile +1 -0
  4. data/Gemfile.lock +8 -0
  5. data/README.md +12 -0
  6. data/app/demo/components/date_fields.pom +96 -0
  7. data/app/demo/components/datetime_fields.pom +106 -0
  8. data/app/demo/components/nav/drawer.pom +1 -1
  9. data/app/demo/components/nav/menu.pom +1 -1
  10. data/app/demo/components/time_fields.pom +59 -0
  11. data/app/demo/components/toggles.pom +28 -1
  12. data/app/demo/events/actions/autocomplete.pom +32 -0
  13. data/app/demo/events/actions/deletes.pom +24 -0
  14. data/app/demo/events/actions/dialog.pom +19 -0
  15. data/app/demo/{event/actions/dialog → events/actions/dialogs}/show_dialog.pom +0 -0
  16. data/app/demo/{event/actions/dialog → events/actions/dialogs}/trigger.pom +0 -0
  17. data/app/demo/events/actions/loads.pom +19 -0
  18. data/app/demo/events/actions/posts.pom +23 -0
  19. data/app/demo/{event/new_text.pom → events/actions/replace_text.pom} +0 -0
  20. data/app/demo/events/actions/replaces.pom +21 -0
  21. data/app/demo/events/actions/snackbar.pom +19 -0
  22. data/app/demo/events/actions/toggle_visiblity.pom +21 -0
  23. data/app/demo/events/actions/updates.pom +24 -0
  24. data/app/demo/events/field_level.pom +20 -0
  25. data/app/demo/events/form_level.pom +24 -0
  26. data/app/demo/events/nav/drawer.pom +21 -0
  27. data/app/demo/events.pom +8 -77
  28. data/app/demo/formatting_tokens.pom +125 -0
  29. data/app/demo/index.pom +12 -5
  30. data/app/demo/markdown.pom +33 -40
  31. data/app/demo/shared/context_list.pom +2 -2
  32. data/app/demo/styles.pom +1 -0
  33. data/config.ru +9 -0
  34. data/lib/voom/presenters/dsl/components/base.rb +5 -0
  35. data/lib/voom/presenters/dsl/components/card.rb +2 -0
  36. data/lib/voom/presenters/dsl/components/content.rb +2 -0
  37. data/lib/voom/presenters/dsl/components/date_field.rb +21 -0
  38. data/lib/voom/presenters/dsl/components/datetime_base.rb +48 -0
  39. data/lib/voom/presenters/dsl/components/datetime_field.rb +23 -0
  40. data/lib/voom/presenters/dsl/components/expansion_panel.rb +1 -0
  41. data/lib/voom/presenters/dsl/components/form.rb +2 -0
  42. data/lib/voom/presenters/dsl/components/grid.rb +2 -0
  43. data/lib/voom/presenters/dsl/components/mixins/date_time_fields.rb +29 -0
  44. data/lib/voom/presenters/dsl/components/mixins/text_fields.rb +0 -6
  45. data/lib/voom/presenters/dsl/components/table.rb +1 -1
  46. data/lib/voom/presenters/dsl/components/time_field.rb +21 -0
  47. data/lib/voom/presenters/dsl/user_interface.rb +3 -0
  48. data/lib/voom/presenters/helpers/rails/currency.rb +16 -0
  49. data/lib/voom/presenters/helpers/rails/model_table.rb +52 -0
  50. data/lib/voom/presenters/helpers/rails.rb +4 -34
  51. data/lib/voom/presenters/settings.rb +14 -0
  52. data/lib/voom/presenters/version.rb +1 -1
  53. data/lib/voom/presenters/web_client/app.rb +8 -0
  54. data/public/bundle.css +676 -0
  55. data/public/bundle.js +3314 -1151
  56. data/views/mdc/assets/js/components/datetime.js +36 -0
  57. data/views/mdc/assets/js/components/events/base.js +5 -5
  58. data/views/mdc/assets/js/components/forms.js +2 -2
  59. data/views/mdc/assets/js/components/initialize.js +2 -2
  60. data/views/mdc/assets/js/components/switches.js +1 -1
  61. data/views/mdc/assets/js/components/text-fields.js +2 -4
  62. data/views/mdc/assets/scss/components/datetime.scss +19 -0
  63. data/views/mdc/assets/scss/components/textfield.scss +7 -0
  64. data/views/mdc/assets/scss/components/vendor/flatpickr.min.css +13 -0
  65. data/views/mdc/components/date.erb +1 -0
  66. data/views/mdc/components/{date_time.erb → datetime.erb} +13 -8
  67. data/views/mdc/components/icon.erb +2 -0
  68. data/views/mdc/components/text_field.erb +3 -2
  69. data/views/mdc/components/time.erb +1 -0
  70. data/views/mdc/layout.erb +1 -0
  71. data/views/mdc/package-lock.json +5 -0
  72. data/views/mdc/package.json +1 -1
  73. metadata +33 -18
  74. data/LICENSE.txt +0 -21
  75. data/app/demo/event/actions/nav/drawer.pom +0 -5
  76. data/app/demo/event/actions/nav/menu.pom +0 -19
  77. data/app/demo/event/actions.rb +0 -86
  78. data/app/demo/event/autocomplete.pom +0 -27
  79. data/app/demo/event/field_level.pom +0 -22
  80. data/app/demo/event/form_level.pom +0 -26
  81. data/app/demo/event/nav/drawer.pom +0 -5
  82. data/app/demo/event/nav/menu.pom +0 -14
  83. data/lib/voom/presenters/dsl/components/date_time.rb +0 -17
  84. data/lib/voom/presenters/helpers/currency.rb +0 -14
  85. data/views/mdc/assets/js/components/date-time.js +0 -6
@@ -0,0 +1,16 @@
1
+ module Voom
2
+ module Presenters
3
+ module Helpers
4
+ module Rails
5
+ module Currency
6
+ include ActionView::Helpers::NumberHelper
7
+
8
+ def cents_to_currency(amount)
9
+ number_to_currency(amount.to_f / 100)
10
+ end
11
+
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,52 @@
1
+ module Voom
2
+ module Presenters
3
+ module Helpers
4
+ module Rails
5
+ module ModelTable
6
+ # Build a a table from a Rails model
7
+ def table_for(query_,
8
+ empty_icon: nil,
9
+ except: [:id, :created_at, :updated_at],
10
+ selectable: false, &block)
11
+ row1 = query_.first
12
+ if row1
13
+ __columns__ = row1.class.columns
14
+ table selectable: selectable do
15
+ _table_header_(__columns__, except)
16
+
17
+ query_.each do |item_|
18
+ row do
19
+ _table_row_(__columns__, block, except, item_)
20
+ end
21
+ end
22
+ end
23
+ else
24
+ body "You have no #{query_.arel_table.name.pluralize}", level: 2
25
+ icon empty_icon, size: '10rem' if empty_icon
26
+ end
27
+ end
28
+
29
+
30
+ private
31
+ def _table_row_(__columns__, block, except, item_)
32
+ __columns__.each do |col|
33
+ next if except.include?(col.name.to_sym)
34
+ column item_.send(col.name.to_sym) do
35
+ self.instance_exec(item_, col.name.to_sym, &block) if block
36
+ end
37
+ end
38
+ end
39
+
40
+ def _table_header_(__columns__, except)
41
+ header do
42
+ __columns__.each do |col|
43
+ column col.name.titleize unless except.include?(col.name.to_sym)
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ end
50
+ end
51
+ end
52
+ end
@@ -1,13 +1,14 @@
1
1
  if defined?(Rails)
2
- require_relative 'currency'
2
+ require_relative 'rails/currency'
3
+ require_relative 'rails/model_table'
3
4
 
4
5
  module Voom
5
6
  module Presenters
6
7
  module Helpers
7
8
  module Rails
8
9
  include ActionView::Helpers::AssetUrlHelper
9
- include Voom::Presenters::Helpers::Currency
10
-
10
+ include Voom::Presenters::Helpers::Rails::Currency
11
+ include Voom::Presenters::Helpers::Rails::ModelTable
11
12
  def default_url_options
12
13
  {}
13
14
  end
@@ -23,37 +24,6 @@ if defined?(Rails)
23
24
  end
24
25
  path
25
26
  end
26
-
27
- def table_for(query_,
28
- empty_icon: nil,
29
- except: [:id, :created_at, :updated_at],
30
- selectable: false, &block)
31
- row1 = query_.first
32
- if row1
33
- __columns__ = row1.class.columns
34
- table selectable: selectable do
35
- header do
36
- __columns__.each do |col|
37
- column col.name.titleize unless except.include?(col.name.to_sym)
38
- end
39
- end
40
-
41
- query_.each do |item_|
42
- row do
43
- __columns__.each do |col|
44
- next if except.include?(col.name.to_sym)
45
- column item_.send(col.name.to_sym) do
46
- self.instance_exec(item_, col.name.to_sym, &block) if block
47
- end
48
- end
49
- end
50
- end
51
- end
52
- else
53
- body "You have no #{query_.arel_table.name.pluralize}", level: 2
54
- icon empty_icon, size: '10rem' if empty_icon
55
- end
56
- end
57
27
  end
58
28
  end
59
29
  end
@@ -29,6 +29,20 @@ module Voom
29
29
  # end
30
30
  setting :prepare_context, []
31
31
  end
32
+ setting :components do
33
+ setting :defaults do
34
+ setting :datetime do
35
+ setting :format, 'F j, Y h:i K'
36
+ end
37
+ setting :date do
38
+ setting :format, 'F j, Y'
39
+ end
40
+ setting :time do
41
+ setting :format, 'h:i K'
42
+ setting :time_24hr, false
43
+ end
44
+ end
45
+ end
32
46
  end
33
47
  end
34
48
  end
@@ -1,5 +1,5 @@
1
1
  module Voom
2
2
  module Presenters
3
- VERSION = '0.1.5'.freeze
3
+ VERSION = '0.1.6'.freeze
4
4
  end
5
5
  end
@@ -63,6 +63,14 @@ module Voom
63
63
  "#{affects}color: #{comp.color};" unless %w(primary secondary).include?(comp.color.to_s) || comp.color.nil?
64
64
  end
65
65
 
66
+ def snake_to_camel(hash, except:[])
67
+ Hash[hash.map{ |k, v|
68
+ next [k,v] if except.include?(k)
69
+ newKey = k.to_s.split('_').collect(&:capitalize).join
70
+ newKey[0] = newKey[0].downcase
71
+ [newKey, v] }
72
+ ]
73
+ end
66
74
  end
67
75
 
68
76
  get '/' do