glib-web 0.5.6 → 0.5.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: 7d6201614facf8b8352af39682f255c003b37066
4
- data.tar.gz: d69c8902174e35efb9c4fa0775bc32a800024f57
3
+ metadata.gz: d3229621ccc977c76e4adc70e1ab7271a76daf08
4
+ data.tar.gz: fa4e7c9f17a1d9c6b6cd770771730e13f583eb7e
5
5
  SHA512:
6
- metadata.gz: 672842487e7541cf841b06892e463996e30a4a53a9489fdff1611267bf0fffbd4b30e847b55651a1f042b3328aed3eaa159d5104122f67a03f9913902b493357
7
- data.tar.gz: 3b5c5b1a91b50e499ad68acac8d3b2059556471255f2c72817dc0dbe725735cb9fb3a589e4ee18f3ea26cc8ebed20412bfbf2fbd7622479b40a8760cb00ab459
6
+ metadata.gz: 2c1cf1ee7207ee7fa8276d6e94df95a6079bc011f429a0d9ca87a1305e4bb7201da04d13cda66de0c5872e7e1604374065dd307144e8e8d3110fcae424d5ae9f
7
+ data.tar.gz: '09fb824243fc37c0cd3ce3d6f0d0b6a85944ab02fa5b88383df8be9ff93394608fc1e0c394b9eadfa7fa51dbd854da3e8cf7ee4ed1da2895cfcdec06509a731e'
@@ -13,7 +13,7 @@ module Glib
13
13
  str.slice(0,1).capitalize + str.slice(1..-1)
14
14
  end
15
15
 
16
- def add_singleton_element type, name, *args
16
+ def add_singleton_element(type, name, *args)
17
17
  name_components = name.to_s.split('_')
18
18
  json.set! type, "#{name_components.join('/')}" if type
19
19
  args = [yield] if block_given?
@@ -22,7 +22,7 @@ module Glib
22
22
  "#{self.class.name}::#{name_components.map{ |str| capitalize_first_letter_and_leave_others_alone(str) }.join('::')}".constantize.new(json, @page).props(*args)
23
23
  end
24
24
 
25
- def add_element_to_array type, name, *args
25
+ def add_element_to_array(type, name, *args)
26
26
  json.child! do
27
27
  add_singleton_element type, name, *args
28
28
  end
@@ -99,9 +99,12 @@ module Glib
99
99
  # options[:leftItems]&.call @menu_builder
100
100
  # end
101
101
  # json.logoUrl "http://localhost:3000/assets/logo_dark-02d9b6a91fdbf22515da7b921d31367b70696214415f6789d2f90232e4a287b7.svg"
102
- json.rightItems do
103
- options[:rightItems]&.call @menu_builder
104
- end
102
+
103
+ # json.rightItems do
104
+ # options[:rightItems]&.call @menu_builder
105
+ # end
106
+
107
+ @view_builder.add_singleton_view('appBar', options)
105
108
  end
106
109
  end
107
110
 
@@ -1,6 +1,9 @@
1
1
  module Glib
2
2
  module JsonUi
3
3
  module StylingHelper
4
+
5
+ ### Padding
6
+
4
7
  def glib_json_padding_body
5
8
  { top: 12, left: 20, right: 20, bottom: 12 }
6
9
  end
@@ -9,6 +12,12 @@ module Glib
9
12
  { top: 12, bottom: 12, left: 16, right: 16 }
10
13
  end
11
14
 
15
+ ###
16
+
17
+
18
+
19
+ ### Image
20
+
12
21
  def glib_json_image_standard_url
13
22
  'https://cdn-images-1.medium.com/max/1200/1*Qc0XxYm-qAZL-7tjjlNfrg.png'
14
23
  end
@@ -20,6 +29,19 @@ module Glib
20
29
  def glib_json_image_blob_key
21
30
  'o6CKzNt67PWnkPdUEnWMt7pr'
22
31
  end
32
+
33
+ ###
34
+
35
+
36
+
37
+ ### Color
38
+
39
+ def glib_color_panel_background
40
+ '#b3bac2'
41
+ end
42
+
43
+ ###
44
+
23
45
  end
24
46
  end
25
47
  end
@@ -15,6 +15,10 @@ module Glib
15
15
  end
16
16
  end
17
17
 
18
+ def add_singleton_view(name, *args)
19
+ add_singleton_element 'view', name, *args
20
+ end
21
+
18
22
  def method_missing(m, *args)
19
23
  add_view m, *args
20
24
  end
@@ -152,26 +156,22 @@ module Glib
152
156
  block.call page.menu_builder
153
157
  end
154
158
  end
159
+ end
155
160
 
156
- # Should be deprecated
157
- # def tabButtons(block)
158
- # json.tabButtons do
159
- # block.call page.menu_builder
160
- # end
161
- # end
162
-
163
- # def options(options)
164
- # current_url = page.context.request.base_url + page.context.request.fullpath
161
+ class AppBar < View
162
+ color :color
165
163
 
166
- # buttons ->(menu) do
167
- # options.each do |tab|
168
- # menu.button text: tab[:text], disabled: tab[:url] == current_url, onClick: ->(action) do
169
- # action.windows_reload url: tab[:url]
170
- # end
171
- # end
164
+ # def leftButtons(block)
165
+ # json.leftButtons do
166
+ # block.call page.menu_builder
172
167
  # end
173
168
  # end
174
169
 
170
+ def rightButtons(block)
171
+ json.rightButtons do
172
+ block.call page.menu_builder
173
+ end
174
+ end
175
175
  end
176
176
 
177
177
  class Datetime < View
@@ -182,4 +182,4 @@ module Glib
182
182
 
183
183
  end
184
184
  end
185
- end
185
+ end
@@ -5,6 +5,8 @@ json_ui_page json do |page|
5
5
 
6
6
  page.list sections: [
7
7
  ->(section) do
8
+ render "#{@path_prefix}/actions/reload", section: section
9
+ end, ->(section) do
8
10
  render "#{@path_prefix}/actions/dialogs", section: section
9
11
  end, ->(section) do
10
12
  render "#{@path_prefix}/actions/snackbars", section: section
@@ -16,8 +18,6 @@ json_ui_page json do |page|
16
18
  render "#{@path_prefix}/actions/timeouts", section: section
17
19
  end, ->(section) do
18
20
  render "#{@path_prefix}/actions/http", section: section
19
- end, ->(section) do
20
- render "#{@path_prefix}/actions/reload", section: section
21
21
  end
22
22
  ]
23
23
  end
@@ -4,11 +4,14 @@ json_ui_page json do |page|
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page
5
5
 
6
6
  page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', padding: glib_json_padding_body, childViews: ->(form) do
7
- form.fields_text name: 'user[name]', width: 'matchParent', label: 'Search', styleClasses: ['outlined', 'rounded']
7
+ form.fields_text name: 'user[name]', width: 'matchParent', label: 'Search', placeholder: 'Enter a keyword', styleClasses: ['outlined', 'rounded']
8
8
 
9
9
  form.spacer height: 14
10
10
  form.fields_password name: 'user[password]', width: 'matchParent', label: 'Password', placeholder: 'Type your password', styleClass: 'outlined'
11
11
 
12
+ form.spacer height: 14
13
+ form.fields_textarea name: 'user[bio]', width: 'matchParent', label: 'Bio', placeholder: 'Enter your bio', styleClasses: ['outlined']
14
+
12
15
  form.spacer height: 14
13
16
  form.fields_stripeToken name: 'user[stripe_token_outlined]', width: 'matchParent', publicKey: 'pk_test_TYooMQauvdEDq54NiTphI7jx', styleClass: 'outlined'
14
17
 
@@ -41,6 +41,17 @@ json_ui_page json do |page|
41
41
  action.windows_open url: json_ui_garage_url(path: 'pages/full_width')
42
42
  end
43
43
  end
44
+ end,
45
+ ->(section) do
46
+ section.header padding: glib_json_padding_list, childViews: ->(header) do
47
+ header.h2 text: 'Misc (Web Only)'
48
+ end
49
+
50
+ section.rows builder: ->(template) do
51
+ template.thumbnail title: 'Nested Scroll', onClick: ->(action) do
52
+ action.windows_open url: json_ui_garage_url(path: 'pages/nested_scroll')
53
+ end
54
+ end
44
55
  end
45
56
  ]
46
57
 
@@ -1,19 +1,18 @@
1
1
  json.title 'Pages'
2
2
 
3
- json_ui_page json do |page|
4
- render "#{@path_prefix}/nav_menu", json: json, page: page
5
-
6
- page.header padding: glib_json_padding_body, backgroundColor: '#b3bac2', childViews: ->(header) do
7
- header.h1 text: 'Header'
8
- end
3
+ page = json_ui_page json
4
+ render "#{@path_prefix}/nav_menu", json: json, page: page
9
5
 
10
- page.footer padding: glib_json_padding_body, backgroundColor: '#b3bac2', childViews: ->(footer) do
11
- footer.h1 text: 'Footer'
12
- end
6
+ page.header padding: glib_json_padding_body, backgroundColor: '#b3bac2', childViews: ->(header) do
7
+ header.h1 text: 'Header'
8
+ end
9
+
10
+ page.footer padding: glib_json_padding_body, backgroundColor: '#b3bac2', childViews: ->(footer) do
11
+ footer.h1 text: 'Footer'
12
+ end
13
13
 
14
- page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
15
- (1..100).each do |index|
16
- scroll.label text: 'Content'
17
- end
14
+ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
15
+ (1..100).each do |index|
16
+ scroll.label text: 'Content'
18
17
  end
19
18
  end
@@ -1,21 +1,33 @@
1
1
  json.title 'Pages'
2
2
 
3
- json_ui_page json do |page|
4
- render "#{@path_prefix}/nav_menu", json: json, page: page
5
-
6
- page.rightNavButtons do |menu|
7
- menu.button icon: 'search', onClick: ->(action) do
8
- action.dialogs_alert message: 'Perform some action'
9
- end
10
- menu.button icon: { name: 'star', badge: { text: '1', backgroundColor: '#ff0000' } }, onClick: ->(action) do
11
- action.dialogs_alert message: 'Perform some action'
12
- end
13
- menu.button icon: { name: 'map', badge: '2' }, onClick: ->(action) do
14
- action.dialogs_alert message: 'Perform some action'
15
- end
16
- end
3
+ page = json_ui_page json
4
+
5
+ render "#{@path_prefix}/nav_menu", json: json, page: page
17
6
 
18
- page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
19
- scroll.label text: 'See the right menu buttons on the nav bar'
7
+ page.navBar backgroundColor: '#a8c4e3', rightButtons: ->(menu) do
8
+ menu.button icon: 'search', onClick: ->(action) do
9
+ action.dialogs_alert message: 'Perform some action'
10
+ end
11
+ menu.button icon: { name: 'star', badge: { text: '1', backgroundColor: '#ff0000' } }, onClick: ->(action) do
12
+ action.dialogs_alert message: 'Perform some action'
13
+ end
14
+ menu.button icon: { name: 'map', badge: '2' }, onClick: ->(action) do
15
+ action.dialogs_alert message: 'Perform some action'
20
16
  end
21
17
  end
18
+
19
+ # page.rightNavButtons do |menu|
20
+ # menu.button icon: 'search', onClick: ->(action) do
21
+ # action.dialogs_alert message: 'Perform some action'
22
+ # end
23
+ # menu.button icon: { name: 'star', badge: { text: '1', backgroundColor: '#ff0000' } }, onClick: ->(action) do
24
+ # action.dialogs_alert message: 'Perform some action'
25
+ # end
26
+ # menu.button icon: { name: 'map', badge: '2' }, onClick: ->(action) do
27
+ # action.dialogs_alert message: 'Perform some action'
28
+ # end
29
+ # end
30
+
31
+ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
32
+ scroll.label text: 'See the right menu buttons on the nav bar'
33
+ end
@@ -0,0 +1,40 @@
1
+ json.title 'Pages'
2
+
3
+ page = json_ui_page json
4
+ render "#{@path_prefix}/nav_menu", json: json, page: page
5
+
6
+ # page.template 'fullWidth'
7
+
8
+ page.header childViews: ->(header) do
9
+ header.panels_vertical width: 'matchParent', styleClass: 'card', padding: glib_json_padding_body, childViews: ->(vertical) do
10
+ vertical.h1 text: 'Header'
11
+ end
12
+ header.spacer height: 10
13
+ end
14
+
15
+ page.footer childViews: ->(footer) do
16
+ footer.spacer height: 10
17
+ footer.panels_vertical width: 'matchParent', styleClass: 'card', padding: glib_json_padding_body, childViews: ->(vertical) do
18
+ vertical.h1 text: 'Footer'
19
+ end
20
+ end
21
+
22
+ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
23
+ scroll.label text: 'Inner Header'
24
+ scroll.label text: 'Inner Header'
25
+ scroll.label text: 'Inner Header'
26
+ scroll.spacer height: 20
27
+
28
+ scroll.panels_vertical width: 'matchParent', styleClass: 'card', backgroundColor: glib_color_panel_background, padding: glib_json_padding_body.merge(right: nil), childViews: ->(padder) do
29
+ padder.panels_scroll width: 'matchParent', height: 300, childViews: ->(inner_scroll) do
30
+ (1..100).each do |index|
31
+ inner_scroll.label text: 'Content'
32
+ end
33
+ end
34
+ end
35
+
36
+ scroll.spacer height: 20
37
+ scroll.label text: 'Inner Footer'
38
+ scroll.label text: 'Inner Footer'
39
+ scroll.label text: 'Inner Footer'
40
+ end
@@ -1,16 +1,37 @@
1
1
  json.title 'Panels'
2
2
 
3
- image_url1 = 'http://ichef.bbci.co.uk/news/976/cpsprodpb/18106/production/_97266589_gettyimages-474547165.jpg'
3
+ image_url1 = 'https://ichef.bbci.co.uk/news/976/cpsprodpb/18106/production/_97266589_gettyimages-474547165.jpg'
4
4
  image_url2 = 'https://s.abcnews.com/images/International/Guam03-gty-jrl-170809_16x9_992.jpg'
5
5
 
6
6
  json_ui_page json do |page|
7
7
  render "#{@path_prefix}/nav_menu", json: json, page: page
8
-
8
+
9
9
  page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
10
- scroll.h1 text: 'Carousel panel'
10
+ scroll.label text: "\n"
11
+ scroll.h1 text: 'Carousel with labels'
12
+ scroll.panels_carousel width: 'matchParent', childViews: ->(carousel) do
13
+ carousel.label text: 'Item 1'
14
+ carousel.label text: 'Item 2'
15
+ end
16
+
17
+ scroll.label text: "\n"
18
+ scroll.h1 text: 'Carousel with images'
11
19
  scroll.panels_carousel width: 'matchParent', childViews: ->(carousel) do
12
20
  carousel.image url: image_url1, width: 'matchParent'
13
21
  carousel.image url: image_url2, width: 'matchParent'
14
22
  end
23
+
24
+ scroll.label text: "\n"
25
+ scroll.h1 text: 'Carousel with complex layout'
26
+ scroll.panels_carousel width: 'matchParent', childViews: ->(carousel) do
27
+ carousel.panels_vertical childViews: ->(panel) do
28
+ panel.h3 text: 'Item 1'
29
+ panel.image url: image_url1, width: 'matchParent'
30
+ end
31
+ carousel.panels_vertical childViews: ->(panel) do
32
+ panel.h3 text: 'Item 2'
33
+ panel.image url: image_url2, width: 'matchParent'
34
+ end
35
+ end
15
36
  end
16
37
  end
@@ -0,0 +1,22 @@
1
+ json.title 'Views'
2
+
3
+ page = json_ui_page json
4
+ render "#{@path_prefix}/nav_menu", json: json, page: page
5
+
6
+ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
7
+ # TODO: Scrape all names from https://material.io/resources/icons
8
+ icon_names = [
9
+ 'info', 'info', 'info', 'info', 'info', 'info', 'info', 'info',
10
+ 'info', 'info', 'info', 'info', 'info', 'info', 'info', 'info',
11
+ 'info', 'info', 'info', 'info', 'info', 'info', 'info', 'info',
12
+ ]
13
+ icon_names.each do |icon_name|
14
+ scroll.panels_column lg: { cols: 2 }, childViews: ->(column) do
15
+ column.panels_horizontal align: 'middle', childViews: ->(horizontal) do
16
+ horizontal.icon spec: icon_name
17
+ horizontal.spacer width: 6
18
+ horizontal.label text: icon_name
19
+ end
20
+ end
21
+ end
22
+ end
@@ -11,10 +11,10 @@ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
11
11
  scroll.spacer height: 6
12
12
  scroll.avatar url: glib_json_image_avatar_url
13
13
 
14
- scroll.spacer height: 20
15
- scroll.h2 text: 'Icon'
16
- scroll.spacer height: 6
17
- scroll.icon spec: 'info'
14
+ # scroll.spacer height: 20
15
+ # scroll.h2 text: 'Icon'
16
+ # scroll.spacer height: 6
17
+ # scroll.icon spec: 'info'
18
18
 
19
19
  scroll.spacer height: 20
20
20
  scroll.h2 text: 'Image with base64 data'
@@ -16,15 +16,15 @@ json_ui_page json do |page|
16
16
  template.thumbnail title: 'Images', onClick: ->(action) do
17
17
  action.windows_open url: json_ui_garage_url(path: 'views/images')
18
18
  end
19
- template.thumbnail title: 'Carousels', onClick: ->(action) do
20
- action.windows_open url: json_ui_garage_url(path: 'views/carousels')
21
- end
22
19
  template.thumbnail title: 'Charts', onClick: ->(action) do
23
20
  action.windows_open url: json_ui_garage_url(path: 'views/charts')
24
21
  end
25
22
  template.thumbnail title: 'Banners', onClick: ->(action) do
26
23
  action.windows_open url: json_ui_garage_url(path: 'views/banners')
27
24
  end
25
+ template.thumbnail title: 'Icons', onClick: ->(action) do
26
+ action.windows_open url: json_ui_garage_url(path: 'views/icons')
27
+ end
28
28
  template.thumbnail title: 'Misc', onClick: ->(action) do
29
29
  action.windows_open url: json_ui_garage_url(path: 'views/misc')
30
30
  end
@@ -20,21 +20,21 @@ module Glib
20
20
  end
21
21
  @__log_dir
22
22
  end
23
-
23
+
24
24
  def __log_file
25
25
  @__log_file ||= "#{self.method_name}.json"
26
26
  end
27
-
27
+
28
28
  def __log json
29
29
  File.open("#{File.join(__log_dir, __log_file)}", "w") do |f|
30
30
  f << JSON.pretty_generate( JSON.parse(json) )
31
31
  end
32
32
  json
33
33
  end
34
-
34
+
35
35
  def __get_previous_result_from_git
36
36
  `git checkout -- "#{File.join(__log_dir, __log_file)}" > /dev/null 2>&1` if __git_is_available?
37
- File.exists?(File.join(__log_dir, __log_file)) ? File.open(File.join(__log_dir, __log_file)).read : "\{\}"
37
+ File.exist?(File.join(__log_dir, __log_file)) ? File.open(File.join(__log_dir, __log_file)).read : "\{\}"
38
38
  end
39
39
  end
40
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -158,6 +158,7 @@ files:
158
158
  - app/views/json_ui/garage/pages/layout.json.jbuilder
159
159
  - app/views/json_ui/garage/pages/loading_indicator.json.jbuilder
160
160
  - app/views/json_ui/garage/pages/nav_buttons.json.jbuilder
161
+ - app/views/json_ui/garage/pages/nested_scroll.json.jbuilder
161
162
  - app/views/json_ui/garage/pages/tab_bar.json.jbuilder
162
163
  - app/views/json_ui/garage/panels/_styled.json.jbuilder
163
164
  - app/views/json_ui/garage/panels/card.json.jbuilder
@@ -183,8 +184,8 @@ files:
183
184
  - app/views/json_ui/garage/views/_chart_data.json.jbuilder
184
185
  - app/views/json_ui/garage/views/banners.json.jbuilder
185
186
  - app/views/json_ui/garage/views/calendar_data.json.jbuilder
186
- - app/views/json_ui/garage/views/carousels.json.jbuilder
187
187
  - app/views/json_ui/garage/views/charts.json.jbuilder
188
+ - app/views/json_ui/garage/views/icons.json.jbuilder
188
189
  - app/views/json_ui/garage/views/images.json.jbuilder
189
190
  - app/views/json_ui/garage/views/index.json.jbuilder
190
191
  - app/views/json_ui/garage/views/links.json.jbuilder
@@ -1,37 +0,0 @@
1
- json.title 'Views'
2
-
3
- image_url1 = 'http://ichef.bbci.co.uk/news/976/cpsprodpb/18106/production/_97266589_gettyimages-474547165.jpg'
4
- image_url2 = 'https://s.abcnews.com/images/International/Guam03-gty-jrl-170809_16x9_992.jpg'
5
-
6
- json_ui_page json do |page|
7
- render "#{@path_prefix}/nav_menu", json: json, page: page
8
-
9
- page.scroll childViews: ->(scroll) do
10
- scroll.label text: "\n"
11
- scroll.h1 text: 'Carousel with labels'
12
- scroll.panels_carousel width: 'matchParent', childViews: ->(carousel) do
13
- carousel.label text: 'Item 1'
14
- carousel.label text: 'Item 2'
15
- end
16
-
17
- scroll.label text: "\n"
18
- scroll.h1 text: 'Carousel with images'
19
- scroll.panels_carousel width: 'matchParent', childViews: ->(carousel) do
20
- carousel.image url: image_url1, width: 'matchParent'
21
- carousel.image url: image_url2, width: 'matchParent'
22
- end
23
-
24
- scroll.label text: "\n"
25
- scroll.h1 text: 'Carousel with complex layout'
26
- scroll.panels_carousel width: 'matchParent', childViews: ->(carousel) do
27
- carousel.panels_vertical childViews: ->(panel) do
28
- panel.h3 text: 'Item 1'
29
- panel.image url: image_url1, width: 'matchParent'
30
- end
31
- carousel.panels_vertical childViews: ->(panel) do
32
- panel.h3 text: 'Item 2'
33
- panel.image url: image_url2, width: 'matchParent'
34
- end
35
- end
36
- end
37
- end