glimmer-dsl-opal 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +69 -17
- data/VERSION +1 -1
- data/lib/glimmer/dsl/opal/dsl.rb +2 -0
- data/lib/glimmer/dsl/opal/tab_folder_expression.rb +17 -0
- data/lib/glimmer/dsl/opal/tab_item_expression.rb +17 -0
- data/lib/glimmer/opal/div_proxy.rb +4 -2
- data/lib/glimmer/opal/document_proxy.rb +38 -0
- data/lib/glimmer/opal/element_proxy.rb +12 -8
- data/lib/glimmer/opal/grid_layout_proxy.rb +2 -1
- data/lib/glimmer/opal/input_proxy.rb +1 -1
- data/lib/glimmer/opal/label_proxy.rb +1 -1
- data/lib/glimmer/opal/layout_data_proxy.rb +1 -1
- data/lib/glimmer/opal/list_proxy.rb +1 -1
- data/lib/glimmer/opal/select_proxy.rb +1 -1
- data/lib/glimmer/opal/tab_folder.rb +46 -0
- data/lib/glimmer/opal/tab_item.rb +98 -0
- data/lib/samples/hello/hello_tab.rb +2 -2
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbf51689c9728f9af6a7670f703584c79def82be3f74085556f91cbc9f02cd51
|
4
|
+
data.tar.gz: e73b3c81aa113ca61e080a5c0fce7299c0812c04883aaf8864bdec5dc80fad00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98c27b51a8de0e218ed4e888660fb6dbf110deda9b1444b7fd75dc72d5477a5eaa277d2a64d92f223bcf0d3b8c398bf2da369a26e000c2544c34952c9fd7f8ad
|
7
|
+
data.tar.gz: 05725471322ba4a5e55115360fa2a970e69c6f076c36480b3354c86968ac796e63c0e0c1250ca2639f100a329363c51fc7a0254b66a918aa7ed4130f538c2ce4
|
data/README.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
# <img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=65 /> Glimmer DSL for Opal 0.0.5 (Web GUI for Desktop Apps)
|
1
|
+
# <img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=65 /> Glimmer DSL for Opal 0.0.6 (Web GUI for Desktop Apps)
|
3
2
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-opal.svg)](http://badge.fury.io/rb/glimmer-dsl-opal)
|
4
3
|
[![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
5
4
|
|
@@ -7,13 +6,14 @@
|
|
7
6
|
|
8
7
|
It enables running [Glimmer](https://github.com/AndyObtiva/glimmer) desktop apps on the web via [Rails](https://rubyonrails.org/) 5 and [Opal](https://opalrb.com/) 1.
|
9
8
|
|
10
|
-
NOTE: Alpha Version 0.0.
|
9
|
+
NOTE: Alpha Version 0.0.6 only supports Hello sample capabilities (detailed under [Examples](#examples)):
|
11
10
|
- [Hello, World!](#hello-world)
|
12
11
|
- [Hello, Combo!](#hello-combo)
|
13
12
|
- [Hello, Computed!](#hello-computed)
|
14
13
|
- [Hello, List Single Selection!](#hello-list-single-selection)
|
15
14
|
- [Hello, List Multi Selection!](#hello-list-multi-selection)
|
16
15
|
- [Hello, Browser!](#hello-browser)
|
16
|
+
- [Hello, Tab!](#hello-tab)
|
17
17
|
|
18
18
|
Other Glimmer DSL gems:
|
19
19
|
- [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (Desktop GUI)
|
@@ -31,7 +31,10 @@ The following keywords from [glimmer-dsl-swt](https://github.com/AndyObtiva/glim
|
|
31
31
|
- `text`
|
32
32
|
- `composite`
|
33
33
|
- `list` & `list(:multi)`
|
34
|
-
- `
|
34
|
+
- `tab_folder`
|
35
|
+
- `tab_item`
|
36
|
+
- `on_widget_selected`
|
37
|
+
- `on_modify_text`
|
35
38
|
- `grid_layout`
|
36
39
|
- `layout_data`
|
37
40
|
|
@@ -56,7 +59,7 @@ Add the following to `Gemfile` (NOTE: if you run into issues, they are probably
|
|
56
59
|
```
|
57
60
|
gem 'opal-rails'
|
58
61
|
gem 'opal-browser'
|
59
|
-
gem 'glimmer-dsl-opal', '~> 0.0.
|
62
|
+
gem 'glimmer-dsl-opal', '~> 0.0.6', require: false
|
60
63
|
```
|
61
64
|
|
62
65
|
Edit `config/initializers/assets.rb` and add:
|
@@ -64,6 +67,12 @@ Edit `config/initializers/assets.rb` and add:
|
|
64
67
|
Opal.use_gem 'glimmer-dsl-opal'
|
65
68
|
```
|
66
69
|
|
70
|
+
Add the following line to the top of an empty `app/assets/javascripts/application.js.rb`
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
require 'glimmer-dsl-opal' # brings opal and opal browser too
|
74
|
+
```
|
75
|
+
|
67
76
|
## Examples
|
68
77
|
|
69
78
|
### Hello, World!
|
@@ -71,8 +80,6 @@ Opal.use_gem 'glimmer-dsl-opal'
|
|
71
80
|
Add the following Glimmer code to `app/assets/javascripts/application.js.rb`
|
72
81
|
|
73
82
|
```ruby
|
74
|
-
require 'glimmer-dsl-opal' # brings opal and opal browser too
|
75
|
-
|
76
83
|
include Glimmer
|
77
84
|
|
78
85
|
shell {
|
@@ -85,7 +92,7 @@ shell {
|
|
85
92
|
|
86
93
|
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
87
94
|
|
88
|
-
![Glimmer DSL for
|
95
|
+
![Glimmer DSL for SWT Hello World](https://github.com/AndyObtiva/glimmer/blob/master/images/glimmer-hello-world.png)
|
89
96
|
|
90
97
|
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
91
98
|
|
@@ -105,8 +112,6 @@ You should see "Hello, World!"
|
|
105
112
|
Add the following Glimmer code to `app/assets/javascripts/application.js.rb`
|
106
113
|
|
107
114
|
```ruby
|
108
|
-
require 'glimmer-dsl-opal' # brings opal and opal browser too
|
109
|
-
|
110
115
|
class Person
|
111
116
|
attr_accessor :country, :country_options
|
112
117
|
|
@@ -144,7 +149,7 @@ HelloCombo.new.launch
|
|
144
149
|
```
|
145
150
|
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
146
151
|
|
147
|
-
![Glimmer DSL for
|
152
|
+
![Glimmer DSL for SWT Hello Combo](https://github.com/AndyObtiva/glimmer/blob/master/images/glimmer-hello-combo.png)
|
148
153
|
|
149
154
|
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
150
155
|
|
@@ -164,8 +169,6 @@ You should see "Hello, Combo!"
|
|
164
169
|
Add the following Glimmer code to `app/assets/javascripts/application.js.rb`
|
165
170
|
|
166
171
|
```ruby
|
167
|
-
require 'glimmer-dsl-opal' # brings opal and opal browser too
|
168
|
-
|
169
172
|
class HelloComputed
|
170
173
|
class Contact
|
171
174
|
attr_accessor :first_name, :last_name, :year_of_birth
|
@@ -258,7 +261,7 @@ HelloComputed.new.launch
|
|
258
261
|
```
|
259
262
|
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
260
263
|
|
261
|
-
![Glimmer DSL for
|
264
|
+
![Glimmer DSL for SWT Hello Computed](https://github.com/AndyObtiva/glimmer/blob/master/images/glimmer-hello-computed.png)
|
262
265
|
|
263
266
|
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
264
267
|
|
@@ -315,7 +318,7 @@ HelloListSingleSelection.new.launch
|
|
315
318
|
```
|
316
319
|
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
317
320
|
|
318
|
-
![Glimmer DSL for
|
321
|
+
![Glimmer DSL for SWT Hello List Single Selection](https://github.com/AndyObtiva/glimmer/raw/master/images/glimmer-hello-list-single-selection.png)
|
319
322
|
|
320
323
|
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
321
324
|
|
@@ -382,7 +385,7 @@ HelloListMultiSelection.new.launch
|
|
382
385
|
```
|
383
386
|
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
384
387
|
|
385
|
-
![Glimmer DSL for
|
388
|
+
![Glimmer DSL for SWT Hello List Multi Selection](https://github.com/AndyObtiva/glimmer/raw/master/images/glimmer-hello-list-multi-selection.png)
|
386
389
|
|
387
390
|
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
388
391
|
|
@@ -413,7 +416,7 @@ shell {
|
|
413
416
|
```
|
414
417
|
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
415
418
|
|
416
|
-
![Glimmer DSL for
|
419
|
+
![Glimmer DSL for SWT Hello Browser](https://github.com/AndyObtiva/glimmer/raw/master/images/glimmer-hello-browser.png)
|
417
420
|
|
418
421
|
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
419
422
|
|
@@ -428,6 +431,55 @@ You should see "Hello, Browser!"
|
|
428
431
|
|
429
432
|
![Glimmer DSL for Opal Hello Browser](images/glimmer-dsl-opal-hello-browser.png)
|
430
433
|
|
434
|
+
### Hello, Tab!
|
435
|
+
|
436
|
+
Add the following Glimmer code to `app/assets/javascripts/application.js.rb`
|
437
|
+
|
438
|
+
```ruby
|
439
|
+
class HelloTab
|
440
|
+
include Glimmer
|
441
|
+
def launch
|
442
|
+
shell {
|
443
|
+
text "Hello, Tab!"
|
444
|
+
tab_folder {
|
445
|
+
tab_item {
|
446
|
+
text "English"
|
447
|
+
label {
|
448
|
+
text "Hello, World!"
|
449
|
+
}
|
450
|
+
}
|
451
|
+
tab_item {
|
452
|
+
text "French"
|
453
|
+
label {
|
454
|
+
text "Bonjour, Univers!"
|
455
|
+
}
|
456
|
+
}
|
457
|
+
}
|
458
|
+
}.open
|
459
|
+
end
|
460
|
+
end
|
461
|
+
|
462
|
+
HelloTab.new.launch
|
463
|
+
```
|
464
|
+
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
465
|
+
|
466
|
+
![Glimmer DSL for SWT Hello Tab English](https://github.com/AndyObtiva/glimmer/raw/master/images/glimmer-hello-tab-english.png)
|
467
|
+
![Glimmer DSL for SWT Hello Tab French](https://github.com/AndyObtiva/glimmer/raw/master/images/glimmer-hello-tab-french.png)
|
468
|
+
|
469
|
+
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
470
|
+
|
471
|
+
Start the Rails server:
|
472
|
+
```
|
473
|
+
rails s
|
474
|
+
```
|
475
|
+
|
476
|
+
Visit `http://localhost:3000`
|
477
|
+
|
478
|
+
You should see "Hello, Tab!"
|
479
|
+
|
480
|
+
![Glimmer DSL for Opal Hello Tab English](images/glimmer-dsl-opal-hello-tab-english.png)
|
481
|
+
![Glimmer DSL for Opal Hello Tab French](images/glimmer-dsl-opal-hello-tab-french.png)
|
482
|
+
|
431
483
|
## Help
|
432
484
|
|
433
485
|
### Issues
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/lib/glimmer/dsl/opal/dsl.rb
CHANGED
@@ -17,6 +17,8 @@ require 'glimmer/dsl/opal/grid_layout_expression'
|
|
17
17
|
require 'glimmer/dsl/opal/text_expression'
|
18
18
|
require 'glimmer/dsl/opal/list_expression'
|
19
19
|
require 'glimmer/dsl/opal/browser_expression'
|
20
|
+
require 'glimmer/dsl/opal/tab_folder_expression'
|
21
|
+
require 'glimmer/dsl/opal/tab_item_expression'
|
20
22
|
require 'glimmer/dsl/opal/layout_data_expression'
|
21
23
|
require 'glimmer/dsl/opal/list_selection_data_binding_expression'
|
22
24
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'glimmer/dsl/static_expression'
|
2
|
+
require 'glimmer/dsl/parent_expression'
|
3
|
+
require 'glimmer/opal/tab_folder'
|
4
|
+
|
5
|
+
module Glimmer
|
6
|
+
module DSL
|
7
|
+
module Opal
|
8
|
+
class TabFolderExpression < StaticExpression
|
9
|
+
include ParentExpression
|
10
|
+
|
11
|
+
def interpret(parent, keyword, *args, &block)
|
12
|
+
Glimmer::Opal::TabFolder.new(parent, args)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'glimmer/dsl/static_expression'
|
2
|
+
require 'glimmer/dsl/parent_expression'
|
3
|
+
require 'glimmer/opal/tab_item'
|
4
|
+
|
5
|
+
module Glimmer
|
6
|
+
module DSL
|
7
|
+
module Opal
|
8
|
+
class TabItemExpression < StaticExpression
|
9
|
+
include ParentExpression
|
10
|
+
|
11
|
+
def interpret(parent, keyword, *args, &block)
|
12
|
+
Glimmer::Opal::TabItem.new(parent, args)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -3,14 +3,16 @@ require 'glimmer/opal/element_proxy'
|
|
3
3
|
module Glimmer
|
4
4
|
module Opal
|
5
5
|
class DivProxy < ElementProxy
|
6
|
+
attr_reader :layout
|
7
|
+
|
6
8
|
def initialize(parent, args)
|
7
9
|
super(parent, args)
|
8
|
-
GridLayoutProxy.new(self, [])
|
10
|
+
@layout = GridLayoutProxy.new(self, [])
|
9
11
|
end
|
10
12
|
|
11
13
|
def dom
|
12
14
|
div_id = id
|
13
|
-
div_style =
|
15
|
+
div_style = css
|
14
16
|
@dom ||= DOM {
|
15
17
|
div(id: div_id, class: 'grid-layout', style: div_style)
|
16
18
|
}
|
@@ -66,6 +66,44 @@ module Glimmer
|
|
66
66
|
li.empty-list-item {
|
67
67
|
color: transparent;
|
68
68
|
}
|
69
|
+
.tabs {
|
70
|
+
overflow: hidden;
|
71
|
+
border: 1px solid #ccc;
|
72
|
+
background-color: #f1f1f1;
|
73
|
+
}
|
74
|
+
|
75
|
+
/* Style the buttons inside the tab */
|
76
|
+
.tabs .tab {
|
77
|
+
background-color: inherit;
|
78
|
+
float: left;
|
79
|
+
border: none;
|
80
|
+
outline: none;
|
81
|
+
cursor: pointer;
|
82
|
+
padding: 14px 16px;
|
83
|
+
transition: 0.3s;
|
84
|
+
font-size: 17px;
|
85
|
+
}
|
86
|
+
|
87
|
+
/* Change background color of buttons on hover */
|
88
|
+
.tabs .tab:hover {
|
89
|
+
background-color: #ddd;
|
90
|
+
}
|
91
|
+
|
92
|
+
/* Create an active/current tablink class */
|
93
|
+
.tabs .tab.active {
|
94
|
+
background-color: #ccc;
|
95
|
+
}
|
96
|
+
|
97
|
+
/* Style the tab content */
|
98
|
+
.tab-item {
|
99
|
+
padding: 6px 12px;
|
100
|
+
border: 1px solid #ccc;
|
101
|
+
border-top: none;
|
102
|
+
}
|
103
|
+
|
104
|
+
.hide {
|
105
|
+
display: none !important;
|
106
|
+
}
|
69
107
|
</style>
|
70
108
|
CSS
|
71
109
|
}
|
@@ -5,18 +5,19 @@ module Glimmer
|
|
5
5
|
class ElementProxy
|
6
6
|
include Glimmer
|
7
7
|
include PropertyOwner
|
8
|
-
attr_reader :parent, :args, :css_classes, :
|
8
|
+
attr_reader :parent, :args, :css_classes, :css, :children
|
9
9
|
|
10
10
|
def initialize(parent, args)
|
11
11
|
@parent = parent
|
12
12
|
@args = args
|
13
|
-
@children =
|
14
|
-
@parent.add_child(self)
|
13
|
+
@children = Set.new
|
15
14
|
@css_classes = Set.new
|
15
|
+
@css = ''
|
16
|
+
@parent.add_child(self)
|
16
17
|
end
|
17
18
|
|
18
19
|
def add_child(child)
|
19
|
-
|
20
|
+
# return if @children.include?(child)
|
20
21
|
@children << child
|
21
22
|
dom << child.dom
|
22
23
|
end
|
@@ -29,6 +30,10 @@ module Glimmer
|
|
29
30
|
else
|
30
31
|
dom
|
31
32
|
end
|
33
|
+
@children.each do |child|
|
34
|
+
child.redraw
|
35
|
+
add_child(child)
|
36
|
+
end
|
32
37
|
end
|
33
38
|
|
34
39
|
# Subclasses must override with their own mappings
|
@@ -41,6 +46,7 @@ module Glimmer
|
|
41
46
|
end
|
42
47
|
|
43
48
|
def id
|
49
|
+
# TODO replace hash with autoincrement per name
|
44
50
|
"#{name}-#{hash}"
|
45
51
|
end
|
46
52
|
|
@@ -74,10 +80,8 @@ module Glimmer
|
|
74
80
|
redraw
|
75
81
|
end
|
76
82
|
|
77
|
-
|
78
|
-
|
79
|
-
def style=(css)
|
80
|
-
@style = css
|
83
|
+
def css=(css)
|
84
|
+
@css = css
|
81
85
|
redraw
|
82
86
|
end
|
83
87
|
|
@@ -11,6 +11,7 @@ module Glimmer
|
|
11
11
|
@args = args
|
12
12
|
@parent.add_css_class('grid-layout')
|
13
13
|
@vertical_spacing = 10
|
14
|
+
@num_columns = 1
|
14
15
|
reapply
|
15
16
|
end
|
16
17
|
|
@@ -39,7 +40,7 @@ module Glimmer
|
|
39
40
|
end
|
40
41
|
|
41
42
|
def reapply
|
42
|
-
@parent.
|
43
|
+
@parent.css = <<~CSS
|
43
44
|
display: grid;
|
44
45
|
grid-template-columns: #{'auto ' * @num_columns.to_i};
|
45
46
|
grid-row-gap: #{@vertical_spacing}px;
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'glimmer/opal/div_proxy'
|
2
|
+
|
3
|
+
module Glimmer
|
4
|
+
module Opal
|
5
|
+
class TabFolder < ElementProxy
|
6
|
+
attr_reader :tabs
|
7
|
+
|
8
|
+
def initialize(parent, args)
|
9
|
+
super(parent, args)
|
10
|
+
@tabs = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_child(child)
|
14
|
+
super(child)
|
15
|
+
if @children.size == 1
|
16
|
+
child.show
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def hide_all_tab_content
|
21
|
+
@children.each(&:hide)
|
22
|
+
end
|
23
|
+
|
24
|
+
def name
|
25
|
+
'div'
|
26
|
+
end
|
27
|
+
|
28
|
+
def tabs_dom
|
29
|
+
tabs_id = id + '-tabs'
|
30
|
+
@tabs_dom ||= DOM {
|
31
|
+
div(id: tabs_id, class: 'tabs')
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def dom
|
36
|
+
tab_folder_id = id
|
37
|
+
tab_folder_id_style = css
|
38
|
+
@dom ||= DOM {
|
39
|
+
div(id: tab_folder_id, style: tab_folder_id_style, class: 'tab-folder') {
|
40
|
+
|
41
|
+
}
|
42
|
+
}.tap {|the_dom| the_dom << tabs_dom }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'glimmer/opal/input_proxy'
|
2
|
+
|
3
|
+
module Glimmer
|
4
|
+
module Opal
|
5
|
+
class TabItem < DivProxy
|
6
|
+
include Glimmer
|
7
|
+
attr_reader :text, :content_visible
|
8
|
+
|
9
|
+
def initialize(parent, args)
|
10
|
+
super(parent, args)
|
11
|
+
css_classes << 'tab-item'
|
12
|
+
content do
|
13
|
+
on_widget_selected {
|
14
|
+
@parent.hide_all_tab_content
|
15
|
+
show
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def content(&block)
|
21
|
+
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Opal::TabItemExpression.new, &block)
|
22
|
+
end
|
23
|
+
|
24
|
+
def show
|
25
|
+
@content_visible = true
|
26
|
+
redraw
|
27
|
+
end
|
28
|
+
|
29
|
+
def hide
|
30
|
+
@content_visible = false
|
31
|
+
redraw
|
32
|
+
end
|
33
|
+
|
34
|
+
def text=(value)
|
35
|
+
@text = value
|
36
|
+
redraw
|
37
|
+
end
|
38
|
+
|
39
|
+
def name
|
40
|
+
'button'
|
41
|
+
end
|
42
|
+
|
43
|
+
def selector
|
44
|
+
super + '-tab'
|
45
|
+
end
|
46
|
+
|
47
|
+
def observation_request_to_event_mapping
|
48
|
+
{
|
49
|
+
'on_widget_selected' => {
|
50
|
+
event: 'click'
|
51
|
+
},
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
def redraw
|
56
|
+
if @tab_dom
|
57
|
+
old_tab_dom = @tab_dom
|
58
|
+
@tab_dom = nil
|
59
|
+
old_tab_dom.replace tab_dom
|
60
|
+
else
|
61
|
+
tab_dom
|
62
|
+
end
|
63
|
+
super
|
64
|
+
end
|
65
|
+
|
66
|
+
def tab_dom
|
67
|
+
tab_id = id + '-tab'
|
68
|
+
tab_text = text
|
69
|
+
tab_active = content_visible ? 'active' : ''
|
70
|
+
@tab_dom ||= DOM {
|
71
|
+
button(id: tab_id, class: "tab #{tab_active}") {
|
72
|
+
tab_text
|
73
|
+
}
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
def dom
|
78
|
+
tab_item_id = id
|
79
|
+
tab_item_id_style = css
|
80
|
+
tab_item_css_classes = css_classes
|
81
|
+
if content_visible
|
82
|
+
tab_item_css_classes.delete('hide')
|
83
|
+
else
|
84
|
+
tab_item_css_classes << 'hide'
|
85
|
+
end
|
86
|
+
if !@parent.tabs.include?(self)
|
87
|
+
@parent.tabs_dom << tab_dom
|
88
|
+
@parent.tabs << self
|
89
|
+
end
|
90
|
+
@dom ||= DOM {
|
91
|
+
div(id: tab_item_id, style: tab_item_id_style, class: tab_item_css_classes.to_a.join(' ')) {
|
92
|
+
}
|
93
|
+
}
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
require 'glimmer/dsl/opal/tab_item_expression'
|
@@ -2,7 +2,7 @@ class HelloTab
|
|
2
2
|
include Glimmer
|
3
3
|
def launch
|
4
4
|
shell {
|
5
|
-
text "Hello Tab"
|
5
|
+
text "Hello, Tab!"
|
6
6
|
tab_folder {
|
7
7
|
tab_item {
|
8
8
|
text "English"
|
@@ -13,7 +13,7 @@ class HelloTab
|
|
13
13
|
tab_item {
|
14
14
|
text "French"
|
15
15
|
label {
|
16
|
-
text "Bonjour Univers!"
|
16
|
+
text "Bonjour, Univers!"
|
17
17
|
}
|
18
18
|
}
|
19
19
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-opal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -190,6 +190,8 @@ files:
|
|
190
190
|
- lib/glimmer/dsl/opal/list_selection_data_binding_expression.rb
|
191
191
|
- lib/glimmer/dsl/opal/property_expression.rb
|
192
192
|
- lib/glimmer/dsl/opal/shell_expression.rb
|
193
|
+
- lib/glimmer/dsl/opal/tab_folder_expression.rb
|
194
|
+
- lib/glimmer/dsl/opal/tab_item_expression.rb
|
193
195
|
- lib/glimmer/dsl/opal/text_expression.rb
|
194
196
|
- lib/glimmer/dsl/opal/widget_listener_expression.rb
|
195
197
|
- lib/glimmer/dsl/parent_expression.rb
|
@@ -210,6 +212,8 @@ files:
|
|
210
212
|
- lib/glimmer/opal/point.rb
|
211
213
|
- lib/glimmer/opal/property_owner.rb
|
212
214
|
- lib/glimmer/opal/select_proxy.rb
|
215
|
+
- lib/glimmer/opal/tab_folder.rb
|
216
|
+
- lib/glimmer/opal/tab_item.rb
|
213
217
|
- lib/samples/elaborate/contact_manager.rb
|
214
218
|
- lib/samples/elaborate/contact_manager/contact.rb
|
215
219
|
- lib/samples/elaborate/contact_manager/contact_manager_presenter.rb
|