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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 411aa64aebeac378f001123d10ae4c7dd45aa7d2f1a92c3593a0687cb9e105ac
4
- data.tar.gz: 64bbc79971792a6f68c2f084d65b47631942281ff28faa9a52da15e3595ba020
3
+ metadata.gz: c58a3f67ab69ad134f50e569b2cb7d2d39529f145c5eede4e6acdc037e382080
4
+ data.tar.gz: 5f45db82e9c4b3cc40706dea5e951a852a51864be8d2819588ffd72e847b320d
5
5
  SHA512:
6
- metadata.gz: 67763e55b0cf99dfcef136bc5a0f822a91bfff6295c1b1780486b8c90405abdda5ec4a7c18d34c4043db97289a332dd2eff8cf238aec66db70e43424fdfa9bf2
7
- data.tar.gz: f5eb112de819b9bc34b99034c5a1dd73f94871295fd2bf8b8ea5cc5c5eecc067bb90f4c59f0ba927ca8f1a283239a101e5502c3a536b944c10cc709841d306cc
6
+ metadata.gz: f5b7a05cb8ea9c58dc40286375665e0a2682838fb9cd844423344f13d620863797b589e6cc6a3c9bf32bc11bbaa623df07b128a2d6215d986f1c40e91cd28d5e
7
+ data.tar.gz: e1610bec38099df78e3af49329b11d0466aa18b756551efda35f22f40ba2cfe50baada829e5ab10d5e4df98c67d06a57f640c32c261a25fc8c958c096c2049cb
data/.circleci/config.yml CHANGED
@@ -60,4 +60,7 @@ jobs:
60
60
  path: /tmp/test-results
61
61
  - store_artifacts:
62
62
  path: /tmp/test-results
63
- destination: test-results
63
+ destination: test-results
64
+ - store_artifacts:
65
+ path: ./coverage
66
+ destination: code-coverage
data/Gemfile CHANGED
@@ -10,4 +10,5 @@ group :test do
10
10
  gem "webdrivers", "~> 3.0"
11
11
  gem 'watir-rspec'
12
12
  gem 'rspec_junit_formatter'
13
+ gem 'simplecov', require: false
13
14
  end
data/Gemfile.lock CHANGED
@@ -19,6 +19,7 @@ GEM
19
19
  coderay (1.1.1)
20
20
  concurrent-ruby (1.0.5)
21
21
  diff-lcs (1.2.5)
22
+ docile (1.1.5)
22
23
  dry-configurable (0.7.0)
23
24
  concurrent-ruby (~> 1.0)
24
25
  dry-container (0.6.0)
@@ -27,6 +28,7 @@ GEM
27
28
  dry-inflector (0.1.2)
28
29
  ffi (1.9.23)
29
30
  ice_nine (0.11.2)
31
+ json (2.1.0)
30
32
  method_source (0.8.2)
31
33
  mini_portile2 (2.3.0)
32
34
  mustermann (1.0.2)
@@ -65,6 +67,11 @@ GEM
65
67
  selenium-webdriver (3.11.0)
66
68
  childprocess (~> 0.5)
67
69
  rubyzip (~> 1.2)
70
+ simplecov (0.15.1)
71
+ docile (~> 1.1.0)
72
+ json (>= 1.8, < 3)
73
+ simplecov-html (~> 0.10.0)
74
+ simplecov-html (0.10.2)
68
75
  sinatra (2.0.1)
69
76
  mustermann (~> 1.0)
70
77
  rack (~> 2.0)
@@ -98,6 +105,7 @@ DEPENDENCIES
98
105
  rspec
99
106
  rspec-html-matchers
100
107
  rspec_junit_formatter
108
+ simplecov
101
109
  voom-presenters!
102
110
  watir (~> 6.10.3)
103
111
  watir-rspec
data/README.md CHANGED
@@ -9,6 +9,10 @@ A POM client can fully render user interface from POM.
9
9
 
10
10
  ## Demo
11
11
 
12
+ [Demo](https://powerful-bastion-96181.herokuapp.com)
13
+
14
+ Or to run locally:
15
+
12
16
  git clone git@github.com:rx/presenters.git
13
17
  cd presenters/
14
18
  bundle install
@@ -30,6 +34,14 @@ Then posts it to the reference web client.
30
34
  That result is then saved to a file and opened up with a browser.
31
35
 
32
36
  curl localhost:9292/pom/index > $TMPDIR/index.json && curl -d "@$TMPDIR/index.json" -X POST localhost:9292/index > $TMPDIR/index.html && open $TMPDIR/index.html
37
+
38
+ ## Status
39
+ This project is in a pre-beta status. It is changing frequently as the first user interfaces are being built with it.
40
+ Any use should be for internal use only until the status becomes beta.
41
+
42
+ [![CircleCI](https://circleci.com/gh/rx/presenters.svg?style=svg)](https://circleci.com/gh/rx/presenters)
43
+ [![Maintainability](https://api.codeclimate.com/v1/badges/8fcea717485230e60f27/maintainability)](https://codeclimate.com/github/rx/presenters/maintainability)
44
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg?style=plastic)](https://raw.githubusercontent.com/rx/presenters/master/LICENSE)
33
45
 
34
46
  ## Usage
35
47
 
@@ -0,0 +1,96 @@
1
+ require 'date'
2
+
3
+ Voom::Presenters.define(:date_fields) do
4
+ helpers Demo::Helpers::IndentedGrid
5
+ attach :top_nav
6
+ attach :component_drawer
7
+
8
+ indented_grid do
9
+ display 'Date Fields'
10
+ body <<~DOC
11
+ A date separates user display format from the value format.
12
+
13
+ The default date user display [format](/formatting_tokens#date) can be configured globally using the following:
14
+
15
+ ````
16
+ Voom::Presenters::Settings.configure do |config|
17
+ config.presenters.components.defaults.date.format = 'F j, Y'
18
+ end
19
+ ````
20
+
21
+ The value format for date times can be the following:
22
+
23
+ * Ruby Time/DateTime objects.
24
+ * ISO/Chronologically Date Strings, e.g. "2017-02-26"
25
+ DOC
26
+ grid do
27
+ column 6 do
28
+ date_field name: :skydive_at,
29
+ format: 'F j, Y' do
30
+ label 'Select your date to skydive'
31
+ icon :event
32
+ event :change do
33
+ replaces :context_list, :context_list, hide_time: true
34
+ end
35
+ end
36
+ end
37
+ column 6 do
38
+ attach :context_list, hide_time: true
39
+ end
40
+ end
41
+ grid do
42
+ column 6 do
43
+ title 'Min Date'
44
+ date_field min_date: "2020-01-01"
45
+
46
+ title 'Max Date'
47
+ date_field max_date: "2017-12-15"
48
+
49
+ title 'Min Date (today)'
50
+ date_field min_date: :today
51
+
52
+ title 'Min (today), Max (14 days from now)'
53
+ date_field min_date: :today, max_date: DateTime.now.next_day(14) # Or in rails Time.now + 14.days
54
+
55
+ title 'Disabling specific dates'
56
+ date_field disable: ["2025-01-30", "2025-02-21", "2025-03-08", DateTime.new(2025, 4, 9)]
57
+
58
+ title 'Disable range of dates'
59
+ date_field disable: [
60
+ {
61
+ from: "2025-04-01",
62
+ to: "2025-05-01"
63
+ },
64
+ {
65
+ from: "2025-09-01",
66
+ to: "2025-12-01"
67
+ }
68
+ ]
69
+
70
+ title 'Enabling specific dates'
71
+ date_field enable: [
72
+ {
73
+ from: "2025-04-01",
74
+ to: "2025-05-01"
75
+ },
76
+ {
77
+ from: "2025-09-01",
78
+ to: "2025-12-01"
79
+ }
80
+ ]
81
+ title 'Selecting multiple dates'
82
+ date_field mode: :multiple
83
+
84
+ title 'Preloading multiple dates'
85
+ date_field mode: :multiple do
86
+ value ["2016-10-20", "2016-11-04"]
87
+ end
88
+
89
+ title 'Range'
90
+ date_field mode: :range
91
+ end
92
+ end
93
+
94
+ end
95
+ attach :code, file: __FILE__
96
+ end
@@ -0,0 +1,106 @@
1
+ require 'date'
2
+
3
+ Voom::Presenters.define(:datetime_fields) do
4
+ helpers Demo::Helpers::IndentedGrid
5
+ attach :top_nav
6
+ attach :component_drawer
7
+
8
+ indented_grid do
9
+ display 'Date Time'
10
+ body <<~DOC
11
+ A date time separates user display format from the value format.
12
+
13
+ The default date time user display [format](/formatting_tokens#date) can be configured globally using the following:
14
+
15
+ ````
16
+ Voom::Presenters::Settings.configure do |config|
17
+ config.presenters.components.defaults.datetime.format = 'F j, Y H:i'
18
+ end
19
+ ````
20
+
21
+ The value format for date times can be the following:
22
+
23
+ * Ruby Time/DateTime objects.
24
+ * ISO Date Strings, e.g. "2017-02-26T19:40:03.243Z"
25
+ * Chronologically Date Strings, e.g., YYYY-MM-DD HH:MM
26
+ DOC
27
+ grid do
28
+ column 6 do
29
+ datetime_field name: :skydive_at,
30
+ format: 'F j, Y h:i' do
31
+ label 'Select your date and time to skydive'
32
+ icon :event
33
+ event :change do
34
+ replaces :context_list, :context_list, hide_time: true
35
+ end
36
+ end
37
+ end
38
+ column 6 do
39
+ attach :context_list, hide_time: true
40
+ end
41
+ end
42
+ grid do
43
+ column 6 do
44
+ title 'Min Date'
45
+ datetime_field min_date: "2020-01-01 00:15"
46
+
47
+ title 'Max Date'
48
+ datetime_field max_date: "2017-12-15 02:00"
49
+
50
+ title 'Min Date (today)'
51
+ datetime_field min_date: :today
52
+
53
+ title 'Min (today), Max (14 days from now)'
54
+ datetime_field min_date: :today, max_date: DateTime.now.next_day(14) # Or in rails Time.now + 14.days
55
+
56
+ title 'Disabling specific dates'
57
+ datetime_field disable: ["2025-01-30", "2025-02-21", "2025-03-08", DateTime.new(2025, 4, 9)]
58
+
59
+ title 'Disable range of dates'
60
+ datetime_field disable: [
61
+ {
62
+ from: "2025-04-01",
63
+ to: "2025-05-01"
64
+ },
65
+ {
66
+ from: "2025-09-01",
67
+ to: "2025-12-01"
68
+ }
69
+ ]
70
+
71
+ title 'Enabling specific dates'
72
+ datetime_field enable: [
73
+ {
74
+ from: "2025-04-01",
75
+ to: "2025-05-01"
76
+ },
77
+ {
78
+ from: "2025-09-01",
79
+ to: "2025-12-01"
80
+ }
81
+ ]
82
+ title 'Selecting multiple dates'
83
+ datetime_field mode: :multiple
84
+
85
+ title 'Preloading multiple dates'
86
+ datetime_field mode: :multiple do
87
+ value ["2016-10-20", "2016-11-04"]
88
+ end
89
+
90
+ title 'Min Time'
91
+ datetime_field min_time: "9:00"
92
+
93
+ title 'Max Time'
94
+ datetime_field max_time: "20:00"
95
+
96
+ title 'Range'
97
+ datetime_field mode: :range
98
+
99
+ title '24 hour time'
100
+ datetime_field time_24hr: true, format: 'H:i'
101
+ end
102
+ end
103
+
104
+ end
105
+ attach :code, file: __FILE__
106
+ end
@@ -1,5 +1,5 @@
1
1
  Voom::Presenters.define(:component_drawer) do
2
- drawer 'Presenters Demo' do
2
+ drawer 'Components' do
3
3
  attach :component_menu
4
4
  end
5
5
  end
@@ -2,7 +2,7 @@ Voom::Presenters.define('component_menu') do
2
2
  helpers Voom::Presenters::Helpers::Inflector
3
3
  menu side: :left do
4
4
  %i(cards lists expansion_panels tables text_fields selects buttons fabs fabs_mini dialogs layouts headers drawers
5
- footers menus toggles chips snackbar badges tooltips hidden_fields text_areas forms icons).sort.each do |comp|
5
+ footers menus toggles chips snackbar badges tooltips hidden_fields text_areas forms icons datetime_fields date_fields time_fields).sort.each do |comp|
6
6
  item titleize(comp) do
7
7
  event :click do
8
8
  loads comp
@@ -0,0 +1,59 @@
1
+ require 'date'
2
+
3
+ Voom::Presenters.define(:time_fields) do
4
+ helpers Demo::Helpers::IndentedGrid
5
+ attach :top_nav
6
+ attach :component_drawer
7
+
8
+ indented_grid do
9
+ display 'Time Field'
10
+ body <<~DOC
11
+ A time field separates user display format from the value format.
12
+
13
+ The default time user display [format](/formatting_tokens#time) can be configured globally using the following:
14
+
15
+ ````
16
+ Voom::Presenters::Settings.configure do |config|
17
+ config.presenters.components.defaults.time.format = 'h:i K'
18
+ end
19
+ ````
20
+
21
+ The value format for date times can be the following, they are expected to be in 24 hour time:
22
+
23
+ * Ruby Time/DateTime objects.
24
+ * Chronologically Time Strings, e.g., HH:MM
25
+ DOC
26
+ grid do
27
+ column 6 do
28
+ time_field name: :skydive_at,
29
+ format: 'H:i' do
30
+ label 'Select your time to skydive'
31
+ icon :event
32
+ event :change do
33
+ replaces :context_list, :context_list, hide_time: true
34
+ end
35
+ end
36
+ end
37
+ column 6 do
38
+ attach :context_list, hide_time: true
39
+ end
40
+ end
41
+ grid do
42
+ column 6 do
43
+ title 'Min Time'
44
+ time_field min_time: "9:00"
45
+
46
+ title 'Max Time'
47
+ time_field max_time: "20:00"
48
+
49
+ title 'Range'
50
+ time_field min_time: "16:00", max_time: "20:00"
51
+
52
+ title '24 hour time'
53
+ time_field time_24hr: true
54
+ end
55
+ end
56
+
57
+ end
58
+ attach :code, file: __FILE__
59
+ end
@@ -17,13 +17,40 @@ Voom::Presenters.define(:toggles) do
17
17
  radio_button
18
18
 
19
19
  headline 'ICON TOGGLE'
20
- icon_toggle 'format_bold', checked: true
20
+ icon_toggle 'format_bold', checked: true
21
21
  icon_toggle 'format_italic'
22
22
 
23
23
  headline 'SWITCH'
24
24
  switch checked: true
25
25
  switch
26
26
 
27
+ grid do
28
+ column 6 do
29
+ display 'Field Level Events'
30
+ heading 'Text Fields'
31
+ body 'This demonstrates that a change event will submit the field value to the event action. '\
32
+ 'This works with posts and replace actions'
33
+ switch name: :myfield do
34
+ event :change do
35
+ replaces :context_list, :context_list
36
+ end
37
+ end
38
+
39
+ display 'Posts in Form'
40
+ body 'This demonstrates that a change event on **ANY** form input will send all the form inputs to the event action. '\
41
+ 'This works with posts and replace actions'
42
+ form do
43
+ switch name: :myfield
44
+ switch name: :myfield2
45
+ event :change do
46
+ replaces :context_list, :context_list
47
+ end
48
+ end
49
+ end
50
+ column 6 do
51
+ attach :context_list
52
+ end
53
+ end
27
54
  attach :code, file: __FILE__
28
55
  end
29
56
  end
@@ -0,0 +1,32 @@
1
+ Voom::Presenters.define(:autocomplete_action) do
2
+ helpers Demo::Helpers::IndentedGrid
3
+ attach :top_nav
4
+ attach :events_drawer
5
+
6
+ indented_grid do
7
+
8
+ heading 'Autocomplete'
9
+ title 'Work In Progress'
10
+ body 'Provides a text field that when typed into will fetch a set of items to select base on what was typed.',
11
+ 'Useful for providing search clues as the user types.',
12
+ 'The search command returned should either an array of text terms found,
13
+ or optionally an id that will also be sumbitted using the same name as plus `_id` as the text field.'
14
+
15
+
16
+ heading 'Search'
17
+ content id: :search_field do
18
+ text_field name: :search, full_width: false do
19
+ label 'Search Silicon Valley'
20
+ event :input do
21
+ autocomplete '/_search_'
22
+ end
23
+ event :change do
24
+ replaces :context_list, :context_list, title: 'Search Results'
25
+ end
26
+ end
27
+ end
28
+ attach :context_list, title: 'Search Results'
29
+ end
30
+
31
+ attach :code, file: __FILE__
32
+ end
@@ -0,0 +1,24 @@
1
+ Voom::Presenters.define(:deletes_action) do
2
+ helpers Demo::Helpers::IndentedGrid
3
+ attach :top_nav
4
+ attach :events_drawer
5
+
6
+ indented_grid do
7
+ heading 'Deletes'
8
+ body 'Issues a DEL to a given url',
9
+ 'Generally used to destroy/delete a restful resource.'
10
+ body '*Note: Will generate a 404.*'
11
+
12
+ title 'Deletes'
13
+ body 'issues a DELETE to the passed path'
14
+ content do
15
+ button 'deletes' do
16
+ event :click do
17
+ # Will generate an error
18
+ deletes 'deletepath', {optional: :params}
19
+ end
20
+ end
21
+ end
22
+ end
23
+ attach :code, file: __FILE__
24
+ end
@@ -0,0 +1,19 @@
1
+ Voom::Presenters.define(:dialog_action) do
2
+ helpers Demo::Helpers::IndentedGrid
3
+ attach :top_nav
4
+ attach :events_drawer
5
+
6
+ indented_grid do
7
+ heading 'Dialog'
8
+ body 'A dialog event displays a, you guessed it, dialog.'
9
+
10
+ title 'Dialog'
11
+ button 'dialog' do
12
+ event :click do
13
+ dialog :my_dialog
14
+ end
15
+ end
16
+ attach :show_dialog
17
+ end
18
+ attach :code, file: __FILE__
19
+ end
@@ -0,0 +1,19 @@
1
+ Voom::Presenters.define(:toggle_visibility_action) do
2
+ helpers Demo::Helpers::IndentedGrid
3
+ attach :top_nav
4
+ attach :events_drawer
5
+
6
+ indented_grid do
7
+ heading 'Loads'
8
+ body 'Loads a new presenter, replacing the whole page.'
9
+
10
+ subheading context['reloaded'] ? "Reloaded" : 'Loads'
11
+ button 'loads' do
12
+ event :click do
13
+ loads :events, reloaded: true
14
+ end
15
+ end
16
+ heading context['reloaded'] ? "Reloaded" : 'Loaded'
17
+ end
18
+ attach :code, file: __FILE__
19
+ end
@@ -0,0 +1,23 @@
1
+ Voom::Presenters.define(:posts_action) do
2
+ helpers Demo::Helpers::IndentedGrid
3
+ attach :top_nav
4
+ attach :events_drawer
5
+
6
+ indented_grid do
7
+ heading 'Posts'
8
+ body 'Issues a POST to a given url',
9
+ 'Generally used to create a restful resource or issue a command.'
10
+ body '*Note: Will generate a 404.*'
11
+
12
+ title 'Posts'
13
+ body "issues a POST to the passed path\nAlias: creates"
14
+ content shows_errors: false do
15
+ button 'posts' do
16
+ event :click do
17
+ posts 'postpath', {optional: :params}
18
+ end
19
+ end
20
+ end
21
+ end
22
+ attach :code, file: __FILE__
23
+ end
@@ -0,0 +1,21 @@
1
+ Voom::Presenters.define(:replaces_action) do
2
+ helpers Demo::Helpers::IndentedGrid
3
+ attach :top_nav
4
+ attach :events_drawer
5
+
6
+ indented_grid do
7
+ heading 'Replaces'
8
+ body 'Replaces will replace content on the page with another presenter.',
9
+ 'It takes the id of what to replace, usually a content block. And the presenter to replace it with.',
10
+ "You pass parameters to it as the last argument."
11
+
12
+ subheading 'Replaces'
13
+ button 'replaces' do
14
+ event :click do
15
+ replaces :replace_me, :replace_text, text: "I was replaced"
16
+ end
17
+ end
18
+ attach :replace_text
19
+ end
20
+ attach :code, file: __FILE__
21
+ end
@@ -0,0 +1,19 @@
1
+ Voom::Presenters.define(:snackbar_action) do
2
+ helpers Demo::Helpers::IndentedGrid
3
+ attach :top_nav
4
+ attach :events_drawer
5
+
6
+ indented_grid do
7
+ heading 'Snackbar'
8
+ body 'Displays the snackbar at the bottom of the screen.',
9
+ 'Useful for inplace editing notifications of success'
10
+
11
+ subheading 'Snackbar'
12
+ button 'snackbar' do
13
+ event :click do
14
+ snackbar 'I want a snack!'
15
+ end
16
+ end
17
+ end
18
+ attach :code, file: __FILE__
19
+ end
@@ -0,0 +1,21 @@
1
+ Voom::Presenters.define(:toggle_visibility_action) do
2
+ helpers Demo::Helpers::IndentedGrid
3
+ attach :top_nav
4
+ attach :events_drawer
5
+
6
+ indented_grid do
7
+ heading 'Toggle Visibility'
8
+ body 'Allows you to toggle visiblity of content on and off on events.',
9
+ 'Takes the id of the element to toggle.',
10
+ "Optionally takes :on or :off to force visiblity."
11
+
12
+ subheading 'Toggle Visibility'
13
+ button 'toggle visiblity' do
14
+ event :click do
15
+ toggle_visiblity :toggle_me
16
+ end
17
+ end
18
+ heading 'Sometimes I appear', id: :toggle_me
19
+ end
20
+ attach :code, file: __FILE__
21
+ end
@@ -0,0 +1,24 @@
1
+ Voom::Presenters.define(:updates_action) do
2
+ helpers Demo::Helpers::IndentedGrid
3
+ attach :top_nav
4
+ attach :events_drawer
5
+
6
+ indented_grid do
7
+ heading 'Updates'
8
+ body 'Issues a PUT to a given url',
9
+ 'Generally used to update a restful resource.'
10
+ body '*Note: Will generate a 404.*'
11
+
12
+ title 'Updates'
13
+ body 'issues a PUT to the passed path'
14
+ content do
15
+ button 'updates' do
16
+ event :click do
17
+ # This goes nowhere
18
+ updates 'updatepath', {optional: :params}
19
+ end
20
+ end
21
+ end
22
+ end
23
+ attach :code, file: __FILE__
24
+ end
@@ -0,0 +1,20 @@
1
+ Voom::Presenters.define(:field_level_events) do
2
+ helpers Demo::Helpers::IndentedGrid
3
+ attach :top_nav
4
+ attach :events_drawer
5
+
6
+ indented_grid do
7
+ display 'Field Level Events'
8
+ heading 'Text Fields'
9
+ body 'This demonstrates that a change event will submit the field value to the event action. '\
10
+ 'This works with posts and replace actions'
11
+ text_field name: :myfield do
12
+ label 'Data to post'
13
+ event :change do
14
+ replaces :context_list, :context_list
15
+ end
16
+ end
17
+ attach :context_list
18
+ end
19
+ attach :code, file: __FILE__
20
+ end
@@ -0,0 +1,24 @@
1
+ Voom::Presenters.define(:form_level_events) do
2
+ helpers Demo::Helpers::IndentedGrid
3
+
4
+ attach :top_nav
5
+ attach :events_drawer
6
+
7
+ indented_grid do
8
+ display 'Posts in Form'
9
+ body 'This demonstrates that a change event on **ANY** form input will send all the form inputs to the event action. '\
10
+ 'This works with posts and replace actions'
11
+ form do
12
+ text_field name: :myfield do
13
+ label 'Data to post'
14
+ end
15
+ text_field name: :myfield2 do
16
+ label 'More Data to post'
17
+ end
18
+ event :change do
19
+ replaces :context_list, :context_list
20
+ end
21
+ end
22
+ attach :context_list
23
+ end
24
+ end