glimmer-dsl-web 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +3 -3
- data/VERSION +1 -1
- data/glimmer-dsl-web.gemspec +4 -4
- data/lib/glimmer/web/element_proxy.rb +42 -4
- data/lib/glimmer-dsl-web/samples/regular/todo_mvc/views/todo_list_item.rb +8 -6
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 968cea935d70d244e06ab3edce32c14c9483ac897e09d9ab5e578cfc0c19ce71
|
4
|
+
data.tar.gz: 138548a00c394758b57a7848f9940748fc3df0dfd19a1638c79e26c5c7325424
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cbe3be5841ec5519f8fc23ae620e6b0545dd8c736a865bed49b161fdb2a4f07faecc3dcddec08a6066c64a30c39e1eb3b753ad74e50633a3b505193832151a5
|
7
|
+
data.tar.gz: e2f6709c7356a0d32c3170789bf7f958db98906d7c7dbbfca1dec7483f43865c961e3facb0d3889ffd28fd4818b1e4850b3a8cbdfe231b4352825aacaabfd2ce
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.4.4
|
4
|
+
|
5
|
+
- Support setting element `style` property as String or Hash (like `background-color: yello; font-size: 12px;` or `{background_color: :yellow, font_size: 12}`)
|
6
|
+
- Support setting element `classes` property as String or Array of Strings/Symbols (like `"pushed round"`, `['pushed', 'round']` or `[:pushed, :round]`)
|
7
|
+
- Upgrade opal-jquery to version 0.5.2
|
8
|
+
|
3
9
|
## 0.4.3
|
4
10
|
|
5
11
|
- Support element class name inclusion data-binding (e.g. `class_name('pushed') <= [@button_model, :pushed]`)
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Web 0.4.
|
1
|
+
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Web 0.4.4 (Beta)
|
2
2
|
## Ruby-in-the-Browser Web Frontend Framework
|
3
3
|
### Finally, Ruby Developer Productivity, Happiness, and Fun in the Frontend!!!
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-web.svg)](http://badge.fury.io/rb/glimmer-dsl-web)
|
@@ -1390,7 +1390,7 @@ rails new glimmer_app_server
|
|
1390
1390
|
Add the following to `Gemfile`:
|
1391
1391
|
|
1392
1392
|
```
|
1393
|
-
gem 'glimmer-dsl-web', '~> 0.4.
|
1393
|
+
gem 'glimmer-dsl-web', '~> 0.4.4'
|
1394
1394
|
```
|
1395
1395
|
|
1396
1396
|
Run:
|
@@ -1619,7 +1619,7 @@ Disable the `webpacker` gem line in `Gemfile`:
|
|
1619
1619
|
Add the following to `Gemfile`:
|
1620
1620
|
|
1621
1621
|
```ruby
|
1622
|
-
gem 'glimmer-dsl-web', '~> 0.4.
|
1622
|
+
gem 'glimmer-dsl-web', '~> 0.4.4'
|
1623
1623
|
```
|
1624
1624
|
|
1625
1625
|
Run:
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.4
|
data/glimmer-dsl-web.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: glimmer-dsl-web 0.4.
|
5
|
+
# stub: glimmer-dsl-web 0.4.4 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "glimmer-dsl-web".freeze
|
9
|
-
s.version = "0.4.
|
9
|
+
s.version = "0.4.4"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Andy Maleh".freeze]
|
14
|
-
s.date = "2024-
|
14
|
+
s.date = "2024-08-03"
|
15
15
|
s.description = "Glimmer DSL for Web (Ruby in the Browser Web Frontend Framework) enables building Web Frontends using Ruby in the Browser, as per Matz's recommendation in his RubyConf 2022 keynote speech to replace JavaScript with Ruby. It aims at providing the simplest, most intuitive, most straight-forward, and most productive frontend framework in existence. The framework follows the Ruby way (with DSLs and TIMTOWTDI) and the Rails way (Convention over Configuration) in building Isomorphic Ruby on Rails Applications. It provides a Ruby HTML DSL, which uniquely enables writing both structure code and logic code in one language. It supports both Unidirectional (One-Way) Data-Binding (using <=) and Bidirectional (Two-Way) Data-Binding (using <=>). Dynamic rendering (and re-rendering) of HTML content is also supported via Content Data-Binding. Modular design is supported with Glimmer Web Components. And, a Ruby CSS DSL is supported with the included Glimmer DSL for CSS. Many samples are demonstrated in the Rails sample app (there is a very minimal Standalone [No Rails] sample app too). You can finally live in pure Rubyland on the Web in both the frontend and backend with Glimmer DSL for Web! This gem relies on Opal Ruby.".freeze
|
16
16
|
s.email = "andy.am@gmail.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
@@ -104,7 +104,7 @@ Gem::Specification.new do |s|
|
|
104
104
|
s.add_runtime_dependency(%q<opal>.freeze, ["= 1.8.2"])
|
105
105
|
s.add_runtime_dependency(%q<opal-rails>.freeze, ["= 2.0.3"])
|
106
106
|
s.add_runtime_dependency(%q<opal-async>.freeze, ["~> 1.4.1"])
|
107
|
-
s.add_runtime_dependency(%q<opal-jquery>.freeze, ["~> 0.5.
|
107
|
+
s.add_runtime_dependency(%q<opal-jquery>.freeze, ["~> 0.5.2"])
|
108
108
|
s.add_runtime_dependency(%q<to_collection>.freeze, [">= 2.0.1", "< 3.0.0"])
|
109
109
|
s.add_development_dependency(%q<puts_debuggerer>.freeze, [">= 1.0.1"])
|
110
110
|
s.add_development_dependency(%q<rake>.freeze, [">= 10.1.0", "< 14.0.0"])
|
@@ -328,6 +328,22 @@ module Glimmer
|
|
328
328
|
end
|
329
329
|
end
|
330
330
|
|
331
|
+
def style(value = null)
|
332
|
+
if rendered?
|
333
|
+
if value.nil?
|
334
|
+
dom_element.attr('style')
|
335
|
+
else
|
336
|
+
value = normalize_style(value)
|
337
|
+
dom_element.attr('style', value)
|
338
|
+
end
|
339
|
+
else
|
340
|
+
enqueue_args = ['style']
|
341
|
+
enqueue_args << value unless value.nil?
|
342
|
+
enqueue_post_render_method_call(*enqueue_args)
|
343
|
+
end
|
344
|
+
end
|
345
|
+
alias style= style
|
346
|
+
|
331
347
|
def style_property(property, value = nil)
|
332
348
|
if rendered?
|
333
349
|
property = property.to_s.gsub('_', '-')
|
@@ -451,7 +467,8 @@ module Glimmer
|
|
451
467
|
html_options["data-#{data_normalized_attribute}"] = html_options.delete(attribute)
|
452
468
|
end
|
453
469
|
html_options[:class] ||= ''
|
454
|
-
html_options[:class] = "#{html_options
|
470
|
+
html_options[:class] = "#{normalize_class_name(html_options.delete('class') || html_options.delete(:class))} #{body_class}".strip
|
471
|
+
html_options[:style] = normalize_style(html_options.delete('style') || html_options.delete(:style))
|
455
472
|
html_options['data-turbo'] = 'false' if parent.nil?
|
456
473
|
html_options
|
457
474
|
end
|
@@ -480,15 +497,16 @@ module Glimmer
|
|
480
497
|
@element_id ||= "element-#{ElementProxy.next_id_number_for(name)}"
|
481
498
|
end
|
482
499
|
|
483
|
-
def class_name=(
|
500
|
+
def class_name=(*values)
|
484
501
|
if rendered?
|
485
|
-
values =
|
502
|
+
values = normalize_class_name(values).split(' ')
|
486
503
|
new_class_name = (base_css_classes + values).uniq.compact.join(' ')
|
487
504
|
dom_element.prop('className', new_class_name)
|
488
505
|
else
|
489
|
-
enqueue_post_render_method_call('class_name=',
|
506
|
+
enqueue_post_render_method_call('class_name=', *values)
|
490
507
|
end
|
491
508
|
end
|
509
|
+
alias classes= class_name=
|
492
510
|
|
493
511
|
def add_css_class(css_class)
|
494
512
|
if rendered?
|
@@ -932,6 +950,26 @@ module Glimmer
|
|
932
950
|
SWT_CURSOR_TO_CSS_CURSOR_MAP[@cursor]
|
933
951
|
end
|
934
952
|
|
953
|
+
def normalize_class_name(class_name_value)
|
954
|
+
if class_name_value.is_a?(Array)
|
955
|
+
class_name_value.map(&:to_s).join(' ')
|
956
|
+
else
|
957
|
+
class_name_value.to_s
|
958
|
+
end
|
959
|
+
end
|
960
|
+
|
961
|
+
def normalize_style(style_value)
|
962
|
+
if style_value.is_a?(Hash)
|
963
|
+
style_value.reduce('') do |output, (key, value)|
|
964
|
+
key = key.to_s.gsub('_', '-')
|
965
|
+
value = value.px if value.is_a?(Numeric)
|
966
|
+
output += "#{key}: #{value}; "
|
967
|
+
end
|
968
|
+
else
|
969
|
+
style_value.to_s
|
970
|
+
end
|
971
|
+
end
|
972
|
+
|
935
973
|
end
|
936
974
|
end
|
937
975
|
end
|
@@ -14,17 +14,19 @@ class TodoListItem
|
|
14
14
|
end
|
15
15
|
|
16
16
|
markup {
|
17
|
+
|
18
|
+
|
17
19
|
li {
|
18
|
-
# Data-bind inclusion of `
|
19
|
-
# meaning inclusion of completed class
|
20
|
+
# Data-bind inclusion of `completed` in `li` `class` attribute unidirectionally to `todo` `completed` attribute,
|
21
|
+
# meaning inclusion/exclusion of `completed` class happens automatically when `todo.completed` boolean value changes.
|
20
22
|
class_name(:completed) <= [todo, :completed]
|
21
23
|
|
22
|
-
# Data-bind inclusion of `
|
23
|
-
# meaning inclusion of active class
|
24
|
+
# Data-bind inclusion of `active` in `li` `class` attribute unidirectionally to `todo` `completed` attribute, negated,
|
25
|
+
# meaning inclusion/exclusion of `active` class happens automatically when `todo.completed` negated boolean value changes.
|
24
26
|
class_name(:active) <= [todo, :completed, on_read: :!]
|
25
27
|
|
26
|
-
# Data-bind inclusion of `
|
27
|
-
# meaning inclusion of editing class
|
28
|
+
# Data-bind inclusion of `editing` in `li` `class` attribute unidirectionally to `todo` `editing` attribute,
|
29
|
+
# meaning inclusion/exclusion of `editing` class happens automatically when `todo.editing` boolean value changes.
|
28
30
|
class_name(:editing) <= [todo, :editing]
|
29
31
|
|
30
32
|
div(class: 'view') {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-web
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.5.
|
103
|
+
version: 0.5.2
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.5.
|
110
|
+
version: 0.5.2
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: to_collection
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|