glimmer-dsl-web 0.7.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +84 -6
- data/VERSION +1 -1
- data/glimmer-dsl-web.gemspec +3 -2
- data/lib/glimmer-dsl-web/samples/hello/hello_component_attribute_listeners.rb +81 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fa66088970372c55644a8ffe63929208eb2ff33f70210fbb37c9df47c640553
|
4
|
+
data.tar.gz: 3322387162239687f62b4dd3ea7c1d1d34d52bda6e1242960dd9e6e7d8cf0f0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cd62b7128c8da53cb68a359ed633724439671877e485c17bda919fca70f7e5d80c10fda3720072b9f7e6fdcd5c1f6fb0ec1652539fa9e864234779ef5bea267
|
7
|
+
data.tar.gz: 0e2c789e2eb779f9fb5e0a70bc22da3ece42d0e9c1efcb77fd965a39c93e380142ca082b131fada732e25ce4b22ef131f5292af91d9cfe94cd7e19c2ce7229b9
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.7.2
|
4
|
+
|
5
|
+
- Hello, Component Attribute Listeners! Sample: `require 'glimmer-dsl-web/samples/hello/hello_component_attribute_listeners.rb'`
|
6
|
+
|
3
7
|
## 0.7.1
|
4
8
|
|
5
9
|
- Fix issue with not being able to pass arguments containing apostrophe (') to glimmer_component helper (provided by GlimmerHelper)
|
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.7.
|
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.7.2 (Beta)
|
2
2
|
## Ruby-in-the-Browser Web Frontend Framework
|
3
3
|
### The "Rails" of Frontend Frameworks!!! ([Fukuoka Award Winning](https://andymaleh.blogspot.com/2025/01/glimmer-dsl-for-web-wins-in-fukuoka.html))
|
4
4
|
#### Finally, Ruby Developer Productivity, Happiness, and Fun in the Frontend!!!
|
@@ -1348,10 +1348,11 @@ Learn more about the differences between various [Glimmer](https://github.com/An
|
|
1348
1348
|
- [Hello, Observer (Data-Binding)!](#hello-observer)
|
1349
1349
|
- [Hello, Data-Binding!](#hello-data-binding)
|
1350
1350
|
- [Hello, Content Data-Binding!](#hello-content-data-binding)
|
1351
|
-
- [Hello, Component!](#hello-
|
1351
|
+
- [Hello, Component!](#hello-component)
|
1352
1352
|
- [Hello, Component Slots!](#hello-component-slots)
|
1353
|
-
- [Hello, Component Listeners!](#hello-
|
1354
|
-
- [Hello, Component Listeners (Default Slot)!](#hello-
|
1353
|
+
- [Hello, Component Listeners!](#hello-component-listeners)
|
1354
|
+
- [Hello, Component Listeners (Default Slot)!](#hello-component-listeners-default-slot)
|
1355
|
+
- [Hello, Component Attribute Listeners!](#hello-component-attribute-listeners)
|
1355
1356
|
- [Hello, glimmer_component Rails Helper!](#hello-glimmer_component-rails-helper)
|
1356
1357
|
- [Hello, Paragraph!](#hello-paragraph)
|
1357
1358
|
- [Hello, Style!](#hello-style)
|
@@ -1389,7 +1390,7 @@ Once done, read [Usage](#usage) instructions. Note that for serious app usage, i
|
|
1389
1390
|
|
1390
1391
|
### Rails 8
|
1391
1392
|
|
1392
|
-
Rails 8 instructions are not ready yet though they would rely on the `opal --watch` command in the Development environment to generate JavaScript files in the directory that propshaft is setup with, and Rails 8 would rely on the `opal` command to generate JavaScript files for the Production environment.
|
1393
|
+
Rails 8 instructions are not ready yet though they would rely on the `opal --watch` command in the Development environment to generate JavaScript files in the directory that propshaft is setup with, and Rails 8 would rely on the `opal` command to generate JavaScript files for the Production environment.
|
1393
1394
|
|
1394
1395
|
Instructions will be added in the future.
|
1395
1396
|
|
@@ -1416,7 +1417,7 @@ rails new glimmer_app_server
|
|
1416
1417
|
Add the following to `Gemfile`:
|
1417
1418
|
|
1418
1419
|
```
|
1419
|
-
gem 'glimmer-dsl-web', '~> 0.7.
|
1420
|
+
gem 'glimmer-dsl-web', '~> 0.7.2'
|
1420
1421
|
```
|
1421
1422
|
|
1422
1423
|
Run:
|
@@ -3758,6 +3759,83 @@ Screenshot:
|
|
3758
3759
|
|
3759
3760
|

|
3760
3761
|
|
3762
|
+
#### Hello, Component Attribute Listeners!
|
3763
|
+
|
3764
|
+
[lib/glimmer-dsl-web/samples/hello/hello_component_attribute_listeners.rb](/lib/glimmer-dsl-web/samples/hello/hello_component_attribute_listeners.rb)
|
3765
|
+
|
3766
|
+
Glimmer HTML DSL Ruby code in the frontend:
|
3767
|
+
|
3768
|
+
```ruby
|
3769
|
+
require 'glimmer-dsl-web'
|
3770
|
+
|
3771
|
+
unless Object.const_defined?(:AddressTypeSelector)
|
3772
|
+
class AddressTypeSelector
|
3773
|
+
include Glimmer::Web::Component
|
3774
|
+
|
3775
|
+
attribute :address_types, default: []
|
3776
|
+
attribute :selected_address_type
|
3777
|
+
|
3778
|
+
before_render do
|
3779
|
+
self.selected_address_type ||= address_types.first
|
3780
|
+
end
|
3781
|
+
|
3782
|
+
markup {
|
3783
|
+
select(placeholder: 'Select an address type') { |select_element|
|
3784
|
+
address_types.each do |address_type|
|
3785
|
+
option(value: address_type) { address_type }
|
3786
|
+
end
|
3787
|
+
|
3788
|
+
# Bidirectionally data-bind select value to selected_address_type attribute on self (component)
|
3789
|
+
value <=> [self, :selected_address_type]
|
3790
|
+
}
|
3791
|
+
}
|
3792
|
+
|
3793
|
+
style {
|
3794
|
+
r(component_element_selector) {
|
3795
|
+
font_size 2.em
|
3796
|
+
margin_left 5.px
|
3797
|
+
}
|
3798
|
+
}
|
3799
|
+
end
|
3800
|
+
end
|
3801
|
+
|
3802
|
+
unless Object.const_defined?(:AddressTypeSelectorPage)
|
3803
|
+
class AddressTypeSelectorPage
|
3804
|
+
include Glimmer::Web::Component
|
3805
|
+
|
3806
|
+
markup {
|
3807
|
+
div {
|
3808
|
+
h1('Address type for delivery:', style: {display: :inline})
|
3809
|
+
|
3810
|
+
address_type_selector(address_types: ['Home', 'Work', 'Other']) {
|
3811
|
+
# We can listen to the updates of any attribute/option in a Glimmer Web Component
|
3812
|
+
# on_{attribute_name}_update do execute code when component attribute/option with attribute_name is updated
|
3813
|
+
# This is an alternative to using Component Listeners, which require that the component explicitly calls notify_listeners,
|
3814
|
+
# whereas Component Attribute Listeners get tracked automatically, but depend on a specific attribute
|
3815
|
+
# The trade-off is Component Listeners provide more flexibility when needed as they are not bound to specific attributes,
|
3816
|
+
# but often Component Attribute Listeners are good enough as a solution for certain problems.
|
3817
|
+
on_selected_address_type_update do |address_type|
|
3818
|
+
$$.alert("You selected the address type: #{address_type}")
|
3819
|
+
end
|
3820
|
+
}
|
3821
|
+
}
|
3822
|
+
}
|
3823
|
+
end
|
3824
|
+
end
|
3825
|
+
|
3826
|
+
Document.ready? do
|
3827
|
+
AddressTypeSelectorPage.render
|
3828
|
+
end
|
3829
|
+
```
|
3830
|
+
|
3831
|
+
Screenshot:
|
3832
|
+
|
3833
|
+

|
3834
|
+
|
3835
|
+

|
3836
|
+
|
3837
|
+

|
3838
|
+
|
3761
3839
|
#### Hello, glimmer_component Rails Helper!
|
3762
3840
|
|
3763
3841
|
You may insert a Glimmer component anywhere into a Rails View using
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.2
|
data/glimmer-dsl-web.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
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.7.
|
5
|
+
# stub: glimmer-dsl-web 0.7.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "glimmer-dsl-web".freeze
|
9
|
-
s.version = "0.7.
|
9
|
+
s.version = "0.7.2".freeze
|
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]
|
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
"lib/glimmer-dsl-web/ext/kernel.rb",
|
34
34
|
"lib/glimmer-dsl-web/samples/hello/hello_button.rb",
|
35
35
|
"lib/glimmer-dsl-web/samples/hello/hello_component.rb",
|
36
|
+
"lib/glimmer-dsl-web/samples/hello/hello_component_attribute_listeners.rb",
|
36
37
|
"lib/glimmer-dsl-web/samples/hello/hello_component_listeners.rb",
|
37
38
|
"lib/glimmer-dsl-web/samples/hello/hello_component_listeners_default_slot.rb",
|
38
39
|
"lib/glimmer-dsl-web/samples/hello/hello_component_slots.rb",
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# Copyright (c) 2023-2024 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer-dsl-web'
|
23
|
+
|
24
|
+
unless Object.const_defined?(:AddressTypeSelector)
|
25
|
+
class AddressTypeSelector
|
26
|
+
include Glimmer::Web::Component
|
27
|
+
|
28
|
+
attribute :address_types, default: []
|
29
|
+
attribute :selected_address_type
|
30
|
+
|
31
|
+
before_render do
|
32
|
+
self.selected_address_type ||= address_types.first
|
33
|
+
end
|
34
|
+
|
35
|
+
markup {
|
36
|
+
select(placeholder: 'Select an address type') { |select_element|
|
37
|
+
address_types.each do |address_type|
|
38
|
+
option(value: address_type) { address_type }
|
39
|
+
end
|
40
|
+
|
41
|
+
# Bidirectionally data-bind select value to selected_address_type attribute on self (component)
|
42
|
+
value <=> [self, :selected_address_type]
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
style {
|
47
|
+
r(component_element_selector) {
|
48
|
+
font_size 2.em
|
49
|
+
margin_left 5.px
|
50
|
+
}
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
unless Object.const_defined?(:AddressTypeSelectorPage)
|
56
|
+
class AddressTypeSelectorPage
|
57
|
+
include Glimmer::Web::Component
|
58
|
+
|
59
|
+
markup {
|
60
|
+
div {
|
61
|
+
h1('Address type for delivery:', style: {display: :inline})
|
62
|
+
|
63
|
+
address_type_selector(address_types: ['Home', 'Work', 'Other']) {
|
64
|
+
# We can listen to the updates of any attribute/option in a Glimmer Web Component
|
65
|
+
# on_{attribute_name}_update do execute code when component attribute/option with attribute_name is updated
|
66
|
+
# This is an alternative to using Component Listeners, which require that the component explicitly calls notify_listeners,
|
67
|
+
# whereas Component Attribute Listeners get tracked automatically, but depend on a specific attribute
|
68
|
+
# The trade-off is Component Listeners provide more flexibility when needed as they are not bound to specific attributes,
|
69
|
+
# but often Component Attribute Listeners are good enough as a solution for certain problems.
|
70
|
+
on_selected_address_type_update do |address_type|
|
71
|
+
$$.alert("You selected the address type: #{address_type}")
|
72
|
+
end
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
Document.ready? do
|
80
|
+
AddressTypeSelectorPage.render
|
81
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-web
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
@@ -266,6 +266,7 @@ files:
|
|
266
266
|
- lib/glimmer-dsl-web/ext/kernel.rb
|
267
267
|
- lib/glimmer-dsl-web/samples/hello/hello_button.rb
|
268
268
|
- lib/glimmer-dsl-web/samples/hello/hello_component.rb
|
269
|
+
- lib/glimmer-dsl-web/samples/hello/hello_component_attribute_listeners.rb
|
269
270
|
- lib/glimmer-dsl-web/samples/hello/hello_component_listeners.rb
|
270
271
|
- lib/glimmer-dsl-web/samples/hello/hello_component_listeners_default_slot.rb
|
271
272
|
- lib/glimmer-dsl-web/samples/hello/hello_component_slots.rb
|