glimmer-dsl-web 0.9.0 → 0.9.1
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 +173 -234
- data/VERSION +1 -1
- data/glimmer-dsl-web.gemspec +3 -2
- data/lib/glimmer/web/component/page_component.rb +1 -0
- data/lib/glimmer/web/component/page_component_button.rb +5 -0
- data/lib/glimmer/web/component/page_component_link.rb +6 -0
- data/lib/glimmer-dsl-web/samples/hello/hello_modal.rb +141 -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: 80d1ce05da87fe291727aa2a4adf9055292ceea97ac7f78093dc85d363cc10ae
|
|
4
|
+
data.tar.gz: 2bc64773da995efb53b89676dfe6d4504c75e57ebbce3082f913233865746089
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 35efaaed778a61e00ac81ed1580e1f4556112926f0932fa64af1bd64e6eadb01a9add2c3760d56be3c9b78b8b2b47333e918445a7280b095ac6c112aec060088
|
|
7
|
+
data.tar.gz: 317c2cce49f3ebc01d4a95762a9b6c40d9cc6b661437dd742d3c4ca5bf8150e4ca25692a40b5541309919f3be5cb7a1ed0db9b3893dbea2bc315ad942a42e9f7
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 0.9.1
|
|
4
|
+
|
|
5
|
+
- Hello, Modal! Sample: `require 'glimmer-dsl-web/samples/hello/hello_modal.rb'`
|
|
6
|
+
|
|
3
7
|
## 0.9.0
|
|
4
8
|
|
|
5
9
|
- page_component_link(text:, component_class:, component_attributes:, page_url:, css_id:, css_class:, css_style:) Glimmer Web Component to instantly render a new page component in the Frontend while changing the browser URL to a shareable bookmarkable URL
|
data/README.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
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.9.
|
|
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.9.1 (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!!!
|
|
5
5
|
[](http://badge.fury.io/rb/glimmer-dsl-web)
|
|
6
6
|
[](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
7
7
|
|
|
8
|
-
**UPCOMING APRIL 17, 2026 WORKSHOP: "Building Rails SPAs in Frontend Ruby with Glimmer DSL for Web" at [wroclove.rb 2026 Ruby Conference](https://wrocloverb.com/), in Wroclaw, Poland**
|
|
9
|
-
|
|
10
8
|
**UPCOMING MAY 30, 2026 TALK: "Frontend Ruby on Rails with Glimmer DSL for Web" at [RubyConf Austria 2026](https://rubyconf.at/), in Vienna, Austria**
|
|
11
9
|
|
|
12
10
|
**(Based on Original [Glimmer](https://github.com/AndyObtiva/glimmer) Library Handling World’s Ruby GUI Needs Since 2007. Beware of Imitators!)**
|
|
13
11
|
|
|
14
12
|
**([Fukuoka Prefecture Future IT Initiative 2025 Money Forward Award Winner](https://andymaleh.blogspot.com/2025/01/glimmer-dsl-for-web-wins-in-fukuoka.html)) [(Award Announcement)](https://digitalfukuoka.jp/news/info/528/)**
|
|
15
13
|
|
|
14
|
+
(**Workshops: [wroclove.rb 2026 Ruby conference workshop exercises: "Building Rails SPAs in Frontend Ruby with Glimmer DSL for Web"](https://github.com/AndyObtiva/glimmer_commerce)**)
|
|
15
|
+
|
|
16
16
|
**(Talk Videos: [Intro to Ruby in the Browser](https://youtu.be/4AdcfbI6A4c?si=MmxOrkhIXTDHQoYi) / [Frontend Ruby with Glimmer DSL for Web \[Montreal.rb\]](https://youtu.be/rIZ-ILUv9ME?si=raygUXVPd_7ypWuE) / [Frontend Ruby with Glimmer DSL for Web \[/dev/mtl 2024\]](https://www.youtube.com/watch?v=J2VIY9DMJo4)) / [Frontend Ruby with Glimmer DSL for Web at Ruby on Rio 2025-06-06 Talk](https://www.youtube.com/watch?v=LY6ulYICuzE)**
|
|
17
17
|
|
|
18
18
|
**(Ruby Rogues Podcast: [Building Better Ruby Apps: Glimmer Component Slots and More](https://topenddevs.com/podcasts/ruby-rogues/episodes/building-better-ruby-apps-glimmer-s-component-slots-and-more-ruby-653))**
|
|
@@ -1360,6 +1360,7 @@ Learn more about the differences between various [Glimmer](https://github.com/An
|
|
|
1360
1360
|
- [Hello, Component Attribute Listeners!](#hello-component-attribute-listeners)
|
|
1361
1361
|
- [Hello, Component Attribute Data-Binding!](#hello-component-attribute-data-binding)
|
|
1362
1362
|
- [Hello, glimmer_component Rails Helper!](#hello-glimmer_component-rails-helper)
|
|
1363
|
+
- [Hello, Modal!](#hello-modal)
|
|
1363
1364
|
- [Hello, Paragraph!](#hello-paragraph)
|
|
1364
1365
|
- [Hello, Style!](#hello-style)
|
|
1365
1366
|
- [Hello, SVG!](#hello-svg)
|
|
@@ -1388,250 +1389,34 @@ Learn more about the differences between various [Glimmer](https://github.com/An
|
|
|
1388
1389
|
|
|
1389
1390
|
## Setup
|
|
1390
1391
|
|
|
1391
|
-
You can setup Glimmer DSL for Web in
|
|
1392
|
+
You can setup Glimmer DSL for Web in one of the following ways:
|
|
1393
|
+
|
|
1394
|
+
- [Rails 7/8 (Build pipeline)](#rails-78-build-pipeline)
|
|
1395
|
+
- [Rails 7 (Sprockets pipeline)](#rails-7-sprockets-pipeline)
|
|
1396
|
+
- [Standalone (No Rails)](#standalone-no-rails)
|
|
1392
1397
|
|
|
1393
1398
|
Once done, read [Usage](#usage) instructions. Note that for serious app usage, it is recommended to build [components](#hello-component) and use the [`glimmer_component` Rails Helper](#hello-glimmer_component-rails-helper) to embed the top-level Web Frontend component in a Rails View.
|
|
1394
1399
|
|
|
1395
1400
|
(NOTE: Keep in mind this is a Beta. If you run into issues, read the [FAQ](#faq) in case they are addressed there (e.g. [I sometimes get an Opal error that makes no sense in relation to my code. How do I fix it?](https://github.com/AndyObtiva/glimmer-dsl-web/blob/master/README.md#i-sometimes-get-an-opal-error-that-makes-no-sense-in-relation-to-my-code-how-do-i-fix-it)) and try to go back to a [previous revision](https://rubygems.org/gems/glimmer-dsl-web/versions). Also, there is a slight chance any issues you encounter are fixed in master or some other branch that you could check out instead)
|
|
1396
1401
|
|
|
1397
|
-
### Rails 8
|
|
1398
|
-
|
|
1399
|
-
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.
|
|
1400
|
-
|
|
1401
|
-
Instructions will be added in the future.
|
|
1402
|
-
|
|
1403
|
-
If you want to help contribute Rails 8 instructions, please look at the Rails 7 instructions and see what needs to be adjusted in light of the first statement above about using `opal --watch` in Development and `opal` in Production.
|
|
1404
|
-
|
|
1405
|
-
### Rails 7
|
|
1406
|
-
|
|
1407
|
-
(NOTE: In the future, we plan to automate the setup steps below. If you would like to help contribute that to the project, please do so and open a Pull Request.)
|
|
1408
|
-
|
|
1409
|
-
Please follow these steps to setup.
|
|
1410
|
-
|
|
1411
|
-
Install a Rails 7 gem:
|
|
1412
|
-
|
|
1413
|
-
```
|
|
1414
|
-
gem install rails -v7.0.9.0
|
|
1415
|
-
```
|
|
1416
|
-
|
|
1417
|
-
Start a new Rails 7 app:
|
|
1418
|
-
|
|
1419
|
-
```
|
|
1420
|
-
rails new glimmer_app_server
|
|
1421
|
-
```
|
|
1422
|
-
|
|
1423
|
-
Add the following to `Gemfile`:
|
|
1424
|
-
|
|
1425
|
-
```
|
|
1426
|
-
gem 'glimmer-dsl-web', '~> 0.9.0'
|
|
1427
|
-
gem 'opal-rails', '2.0.4' # for Rails 7 use of Sprockets
|
|
1428
|
-
```
|
|
1429
|
-
|
|
1430
|
-
Run:
|
|
1431
|
-
|
|
1432
|
-
```
|
|
1433
|
-
bundle
|
|
1434
|
-
```
|
|
1435
|
-
|
|
1436
|
-
(run `rm -rf tmp/cache` from inside your Rails app if you upgrade your `glimmer-dsl-web` gem version from an older one to clear Opal-Rails's cache)
|
|
1437
|
-
|
|
1438
|
-
Follow [opal-rails](https://github.com/opal/opal-rails) instructions, basically running:
|
|
1439
|
-
|
|
1440
|
-
```
|
|
1441
|
-
bin/rails g opal:install
|
|
1442
|
-
```
|
|
1443
|
-
|
|
1444
|
-
To enable the `glimmer-dsl-web` gem in the frontend, edit `config/initializers/assets.rb` and add the following at the bottom (requires that you also create `manifest.opal.js` as per instructions below):
|
|
1445
|
-
|
|
1446
|
-
```ruby
|
|
1447
|
-
Opal.use_gem 'glimmer-dsl-web'
|
|
1448
|
-
Opal.append_path Rails.root.join('app', 'assets', 'opal')
|
|
1449
|
-
Rails.application.config.assets.precompile += %w[manifest.opal.js]
|
|
1450
|
-
```
|
|
1451
|
-
|
|
1452
|
-
To enable Opal Browser Debugging in Ruby with the [Source Maps](https://opalrb.com/docs/guides/v1.4.1/source_maps.html) feature, edit `config/initializers/opal.rb` and add the following inside the `Rails.application.configure do; end` block at the bottom of it:
|
|
1453
|
-
|
|
1454
|
-
```ruby
|
|
1455
|
-
config.assets.debug = true if Rails.env.development?
|
|
1456
|
-
```
|
|
1457
|
-
|
|
1458
|
-
Assuming this is a brand new Rails application and you do not have any Rails resources, you can scaffold the welcome resource just for testing purposes.
|
|
1459
|
-
|
|
1460
|
-
Run:
|
|
1461
|
-
|
|
1462
|
-
```
|
|
1463
|
-
rails g scaffold welcome
|
|
1464
|
-
```
|
|
1465
|
-
|
|
1466
|
-
Run:
|
|
1467
|
-
|
|
1468
|
-
```
|
|
1469
|
-
rails db:migrate
|
|
1470
|
-
```
|
|
1471
|
-
|
|
1472
|
-
Add the following to `config/routes.rb` inside the `Rails.application.routes.draw` block:
|
|
1473
|
-
|
|
1474
|
-
```ruby
|
|
1475
|
-
root to: 'welcomes#index'
|
|
1476
|
-
```
|
|
1477
|
-
|
|
1478
|
-
Clear the file `app/views/welcomes/index.html.erb` completely from all content.
|
|
1479
|
-
|
|
1480
|
-
Rename `app/assets/javascript/application.js.rb` file to `app/assets/javascript/opal_application.rb`.
|
|
1481
|
-
|
|
1482
|
-
Rename `app/assets/javascript` directory to `app/assets/opal`.
|
|
1483
|
-
|
|
1484
|
-
Edit `app/assets/config/manifest.js` and update `//= link_directory ../javascript .js` to `//= link_directory ../opal .js`:
|
|
1485
|
-
|
|
1486
|
-
```js
|
|
1487
|
-
//= link_directory ../opal .js
|
|
1488
|
-
```
|
|
1489
|
-
|
|
1490
|
-
Also, create `app/assets/config/manifest.opal.js` and add the following content to it:
|
|
1491
|
-
```js
|
|
1492
|
-
//= link_tree ../opal .js
|
|
1493
|
-
//= link_directory ../opal .js
|
|
1494
|
-
```
|
|
1495
|
-
|
|
1496
|
-
Edit `app/views/layouts/application.html.erb` and update `<%= javascript_include_tag "application", "data-turbolinks-track": "reload" %>` to `<%= javascript_include_tag "opal_application", "data-turbolinks-track": "reload" %>`:
|
|
1497
|
-
|
|
1498
|
-
```erb
|
|
1499
|
-
<%= javascript_include_tag "opal_application", "data-turbolinks-track": "reload" %>
|
|
1500
|
-
```
|
|
1501
|
-
|
|
1502
|
-
Edit and replace `app/assets/opal/opal_application.rb` content with code below (optionally including a require statement for one of the [samples](#samples) below):
|
|
1503
|
-
|
|
1504
|
-
```ruby
|
|
1505
|
-
require 'glimmer-dsl-web' # brings opal and other dependencies automatically
|
|
1506
|
-
|
|
1507
|
-
# Add more require-statements or Glimmer HTML DSL code
|
|
1508
|
-
```
|
|
1509
|
-
|
|
1510
|
-
```ruby
|
|
1511
|
-
require 'glimmer-dsl-web'
|
|
1512
|
-
|
|
1513
|
-
require 'glimmer-dsl-web/samples/hello/hello_world.rb'
|
|
1514
|
-
```
|
|
1515
|
-
|
|
1516
|
-
If the `<body></body>` element (where the Glimmer HTML DSL adds elements by default) is not available when the JS file is loading, you need to put the code inside a `Document.ready? do; end` (but, it is recommended that you load the JS file after the parent element like `<body></body>` is in the page already for faster performance, which is guaranteed automatically by using `glimmer_component`, mentioned in details below):
|
|
1517
|
-
|
|
1518
|
-
```ruby
|
|
1519
|
-
require 'glimmer-dsl-web'
|
|
1520
|
-
|
|
1521
|
-
Document.ready? do
|
|
1522
|
-
require 'glimmer-dsl-web/samples/hello/hello_world.rb'
|
|
1523
|
-
end
|
|
1524
|
-
```
|
|
1525
|
-
|
|
1526
|
-
Example to confirm setup is working:
|
|
1527
|
-
|
|
1528
|
-
Glimmer HTML DSL Ruby code in the frontend:
|
|
1529
|
-
|
|
1530
|
-
```ruby
|
|
1531
|
-
require 'glimmer-dsl-web'
|
|
1532
|
-
|
|
1533
|
-
include Glimmer
|
|
1534
|
-
|
|
1535
|
-
Document.ready? do
|
|
1536
|
-
# This will hook into element #app-container and then build HTML inside it using Ruby DSL code
|
|
1537
|
-
div {
|
|
1538
|
-
label(class: 'greeting') {
|
|
1539
|
-
'Hello, World!'
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1542
|
-
end
|
|
1543
|
-
```
|
|
1544
|
-
|
|
1545
|
-
That produces:
|
|
1546
|
-
|
|
1547
|
-
```html
|
|
1548
|
-
<body>
|
|
1549
|
-
<div data-parent="body" class="element element-1">
|
|
1550
|
-
<label class="greeting element element-2">
|
|
1551
|
-
Hello, World!
|
|
1552
|
-
</label>
|
|
1553
|
-
</div>
|
|
1554
|
-
</body>
|
|
1555
|
-
```
|
|
1556
|
-
|
|
1557
|
-
Start the Rails server:
|
|
1558
|
-
```
|
|
1559
|
-
rails s
|
|
1560
|
-
```
|
|
1561
|
-
|
|
1562
|
-
Visit `http://localhost:3000`
|
|
1563
|
-
|
|
1564
|
-
You should see:
|
|
1565
|
-
|
|
1566
|
-

|
|
1567
|
-
|
|
1568
|
-
If you want to customize where the top-level element is mounted, just pass a `parent: 'css_selector'` option.
|
|
1569
|
-
|
|
1570
|
-
HTML:
|
|
1571
|
-
|
|
1572
|
-
```html
|
|
1573
|
-
...
|
|
1574
|
-
<div id="app-container">
|
|
1575
|
-
</div>
|
|
1576
|
-
...
|
|
1577
|
-
```
|
|
1578
|
-
|
|
1579
|
-
Glimmer HTML DSL Ruby code in the frontend:
|
|
1580
|
-
|
|
1581
|
-
```ruby
|
|
1582
|
-
require 'glimmer-dsl-web'
|
|
1583
|
-
|
|
1584
|
-
include Glimmer
|
|
1585
|
-
|
|
1586
|
-
Document.ready? do
|
|
1587
|
-
# This will hook into element #app-container and then build HTML inside it using Ruby DSL code
|
|
1588
|
-
div(parent: '#app-container') {
|
|
1589
|
-
label(class: 'greeting') {
|
|
1590
|
-
'Hello, World!'
|
|
1591
|
-
}
|
|
1592
|
-
}
|
|
1593
|
-
end
|
|
1594
|
-
```
|
|
1595
|
-
|
|
1596
|
-
That produces:
|
|
1597
|
-
|
|
1598
|
-
```html
|
|
1599
|
-
...
|
|
1600
|
-
<div id="app-container">
|
|
1601
|
-
<div data-parent="app-container" class="element element-1">
|
|
1602
|
-
<label class="greeting element element-2">
|
|
1603
|
-
Hello, World!
|
|
1604
|
-
</label>
|
|
1605
|
-
</div>
|
|
1606
|
-
</div>
|
|
1607
|
-
...
|
|
1608
|
-
```
|
|
1609
|
-
|
|
1610
|
-
You may delete `opal_application.rb` after confirming that the setup works because `glimmer_component` is the recommended way for serious use of Glimmer DSL for Web in Rails web apps.
|
|
1611
|
-
|
|
1612
|
-
You may insert a Glimmer component anywhere into a Rails View using `glimmer_component(component_path, *args)` Rails helper. Add `include GlimmerHelper` to `ApplicationHelper` or another Rails helper, and use `<%= glimmer_component("path/to/component", *args) %>` in Views.
|
|
1402
|
+
### Rails 7/8 (Build pipeline)
|
|
1613
1403
|
|
|
1614
|
-
|
|
1404
|
+
For the modern build-based `opal-rails` flow, follow [docs/setup/rails_7_8_build_pipeline.md](docs/setup/rails_7_8_build_pipeline.md).
|
|
1615
1405
|
|
|
1616
|
-
|
|
1406
|
+
This is the recommended setup for:
|
|
1617
1407
|
|
|
1618
|
-
|
|
1619
|
-
|
|
1408
|
+
- Rails 8 apps
|
|
1409
|
+
- Rails 7 apps that you want on the same explicit build/watch flow, whether the host app serves assets with Propshaft or Sprockets
|
|
1620
1410
|
|
|
1621
|
-
|
|
1622
|
-
# ...
|
|
1623
|
-
include GlimmerHelper
|
|
1624
|
-
# ...
|
|
1625
|
-
end
|
|
1626
|
-
```
|
|
1411
|
+
It is based on the current `opal-rails` build pipeline and the verified migration path used in the [Sample Glimmer DSL for Web Rails 7 App](https://github.com/AndyObtiva/sample-glimmer-dsl-web-rails7-app). In this flow, Rails just serves the compiled assets from `app/assets/builds`; it does not compile Opal source files at request time.
|
|
1627
1412
|
|
|
1628
|
-
|
|
1413
|
+
If you are migrating an existing app from the legacy request-time pipeline to this build pipeline, start with [docs/setup/rails_7_8_build_pipeline.md](docs/setup/rails_7_8_build_pipeline.md) and the `opal-rails` porting notes at https://github.com/opal/opal-rails/blob/master/PORTING.md.
|
|
1629
1414
|
|
|
1630
|
-
|
|
1415
|
+
### Rails 7 (Sprockets pipeline)
|
|
1631
1416
|
|
|
1632
|
-
|
|
1417
|
+
For the legacy Rails 7 + Sprockets/request-time compilation flow, follow [docs/setup/rails_7_sprockets_pipeline.md](docs/setup/rails_7_sprockets_pipeline.md).
|
|
1633
1418
|
|
|
1634
|
-
|
|
1419
|
+
That guide explicitly pins `opal-rails` to `~> 2.0.4`. If you are starting a new app or want the newer build/watch workflow, use the build-pipeline guide above instead.
|
|
1635
1420
|
|
|
1636
1421
|
Next, read [Usage](#usage) instructions, and check out [Samples](#samples).
|
|
1637
1422
|
|
|
@@ -4188,6 +3973,160 @@ Screenshot:
|
|
|
4188
3973
|
|
|
4189
3974
|

|
|
4190
3975
|
|
|
3976
|
+
#### Hello, Modal!
|
|
3977
|
+
|
|
3978
|
+
[lib/glimmer-dsl-web/samples/hello/hello_modal.rb](/lib/glimmer-dsl-web/samples/hello/hello_modal.rb)
|
|
3979
|
+
|
|
3980
|
+
Glimmer HTML DSL Ruby code in the frontend:
|
|
3981
|
+
|
|
3982
|
+
```ruby
|
|
3983
|
+
require 'glimmer-dsl-web'
|
|
3984
|
+
|
|
3985
|
+
# only in the sample we need the unless statement to avoid conflicting with other samples, but not in real usage
|
|
3986
|
+
unless Object.const_defined?(:GreetingPerson)
|
|
3987
|
+
GreetingPerson = Struct.new(:name, keyword_init: true)
|
|
3988
|
+
end
|
|
3989
|
+
|
|
3990
|
+
# only in the sample we need the unless statement to avoid conflicting with other samples, but not in real usage
|
|
3991
|
+
unless Object.const_defined?(:GreetingModal)
|
|
3992
|
+
class GreetingModal
|
|
3993
|
+
include Glimmer::Web::Component
|
|
3994
|
+
|
|
3995
|
+
attribute :greeting_target, default: 'World'
|
|
3996
|
+
|
|
3997
|
+
markup {
|
|
3998
|
+
div(class: 'modal-outer') {
|
|
3999
|
+
div(class: 'modal-inner') {
|
|
4000
|
+
h2 { 'Greeting' }
|
|
4001
|
+
|
|
4002
|
+
h3 { "Hello, #{greeting_target}!" }
|
|
4003
|
+
|
|
4004
|
+
div {
|
|
4005
|
+
button('Close') {
|
|
4006
|
+
onclick do
|
|
4007
|
+
markup_root.remove
|
|
4008
|
+
end
|
|
4009
|
+
}
|
|
4010
|
+
}
|
|
4011
|
+
}
|
|
4012
|
+
}
|
|
4013
|
+
}
|
|
4014
|
+
|
|
4015
|
+
style {
|
|
4016
|
+
r('.modal-outer') {
|
|
4017
|
+
display 'flex'
|
|
4018
|
+
position 'fixed'
|
|
4019
|
+
left 0
|
|
4020
|
+
top 0
|
|
4021
|
+
width 100.vw
|
|
4022
|
+
height 100.vh
|
|
4023
|
+
background 'rgba(200, 200, 200, 0.8)'
|
|
4024
|
+
margin 0
|
|
4025
|
+
padding 0
|
|
4026
|
+
justify_content 'center'
|
|
4027
|
+
align_items 'center'
|
|
4028
|
+
}
|
|
4029
|
+
|
|
4030
|
+
r('div.modal-inner') {
|
|
4031
|
+
display 'flex'
|
|
4032
|
+
flex_direction 'column'
|
|
4033
|
+
width 300
|
|
4034
|
+
height 160
|
|
4035
|
+
justify_content 'center'
|
|
4036
|
+
align_items 'center'
|
|
4037
|
+
box_shadow '0 10px 30px rgba(0, 0, 0, 0.5)'
|
|
4038
|
+
background :white
|
|
4039
|
+
border_radius 15
|
|
4040
|
+
padding 15
|
|
4041
|
+
}
|
|
4042
|
+
|
|
4043
|
+
r('div.modal-inner button') {
|
|
4044
|
+
width 135
|
|
4045
|
+
margin 5
|
|
4046
|
+
border_radius 5
|
|
4047
|
+
padding 5
|
|
4048
|
+
background :white
|
|
4049
|
+
}
|
|
4050
|
+
|
|
4051
|
+
r('div.modal-inner button:hover') {
|
|
4052
|
+
background :black
|
|
4053
|
+
color :white
|
|
4054
|
+
}
|
|
4055
|
+
|
|
4056
|
+
|
|
4057
|
+
r('div.modal-inner h2') {
|
|
4058
|
+
margin_top 10
|
|
4059
|
+
}
|
|
4060
|
+
}
|
|
4061
|
+
end
|
|
4062
|
+
end
|
|
4063
|
+
|
|
4064
|
+
# only in the sample we need the unless statement to avoid conflicting with other samples, but not in real usage
|
|
4065
|
+
unless Object.const_defined?(:HelloModal)
|
|
4066
|
+
class HelloModal
|
|
4067
|
+
include Glimmer::Web::Component
|
|
4068
|
+
|
|
4069
|
+
before_render do
|
|
4070
|
+
@greeting_person = GreetingPerson.new
|
|
4071
|
+
end
|
|
4072
|
+
|
|
4073
|
+
markup {
|
|
4074
|
+
div {
|
|
4075
|
+
div {
|
|
4076
|
+
button('Greet The World') {
|
|
4077
|
+
onclick do
|
|
4078
|
+
# renders Modal under body by default, which works for Modals because they rely on fixed positioning
|
|
4079
|
+
GreetingModal.render
|
|
4080
|
+
end
|
|
4081
|
+
}
|
|
4082
|
+
}
|
|
4083
|
+
div {
|
|
4084
|
+
button('Greet Laura') {
|
|
4085
|
+
onclick do
|
|
4086
|
+
# renders Modal under body explicitly (parent takes a CSS expression) while passing it an attribute value
|
|
4087
|
+
GreetingModal.render(parent: 'body', greeting_target: 'Laura')
|
|
4088
|
+
end
|
|
4089
|
+
}
|
|
4090
|
+
}
|
|
4091
|
+
div {
|
|
4092
|
+
label { 'Greeting Person Name:' }
|
|
4093
|
+
input(type: 'text') {
|
|
4094
|
+
value <=> [@greeting_person, :name]
|
|
4095
|
+
}
|
|
4096
|
+
button {
|
|
4097
|
+
inner_text <= [@greeting_person, :name, on_read: ->(name) { "Greet #{name}" }]
|
|
4098
|
+
|
|
4099
|
+
onclick do
|
|
4100
|
+
# renders Modal under body by default while passing it a Model attribute value
|
|
4101
|
+
GreetingModal.render(greeting_target: @greeting_person.name)
|
|
4102
|
+
end
|
|
4103
|
+
}
|
|
4104
|
+
}
|
|
4105
|
+
}
|
|
4106
|
+
}
|
|
4107
|
+
|
|
4108
|
+
style {
|
|
4109
|
+
r('.hello-modal div') {
|
|
4110
|
+
margin_bottom 10
|
|
4111
|
+
}
|
|
4112
|
+
r('.hello-modal label, .hello-modal input, .hello-modal button') {
|
|
4113
|
+
margin_right 5
|
|
4114
|
+
}
|
|
4115
|
+
}
|
|
4116
|
+
end
|
|
4117
|
+
end
|
|
4118
|
+
|
|
4119
|
+
# only in the sample we need the Document.ready? call; in real usage,
|
|
4120
|
+
# we rely on the glimmer_component helper to load this file inside a Rails View
|
|
4121
|
+
Document.ready? do
|
|
4122
|
+
HelloModal.render
|
|
4123
|
+
end
|
|
4124
|
+
```
|
|
4125
|
+
|
|
4126
|
+
Screenshot:
|
|
4127
|
+
|
|
4128
|
+

|
|
4129
|
+
|
|
4191
4130
|
#### Hello, Paragraph!
|
|
4192
4131
|
|
|
4193
4132
|
To facilitate building formatted textual paragraphs in Ruby, thanks to [Glimmer](https://github.com/AndyObtiva/glimmer#dsl-engine), the most advanced DSL engine in Ruby, the Glimmer HTML DSL is advanced enough to intelligently behave differently under different situations, like when using HTML formatting elements: `<br>`, `<strong>`, `<em>`, `<br>`, `<i>`, `<sub>`, `<sup>`, `<del>`, `<ins>`, `<small>`, `<mark>`
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.9.
|
|
1
|
+
0.9.1
|
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.9.
|
|
5
|
+
# stub: glimmer-dsl-web 0.9.1 ruby lib
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |s|
|
|
8
8
|
s.name = "glimmer-dsl-web".freeze
|
|
9
|
-
s.version = "0.9.
|
|
9
|
+
s.version = "0.9.1".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]
|
|
@@ -48,6 +48,7 @@ Gem::Specification.new do |s|
|
|
|
48
48
|
"lib/glimmer-dsl-web/samples/hello/hello_form_mvp/views/contact_table.rb",
|
|
49
49
|
"lib/glimmer-dsl-web/samples/hello/hello_glimmer_component_helper/address_form.rb",
|
|
50
50
|
"lib/glimmer-dsl-web/samples/hello/hello_input_date_time.rb",
|
|
51
|
+
"lib/glimmer-dsl-web/samples/hello/hello_modal.rb",
|
|
51
52
|
"lib/glimmer-dsl-web/samples/hello/hello_observer.rb",
|
|
52
53
|
"lib/glimmer-dsl-web/samples/hello/hello_observer_data_binding.rb",
|
|
53
54
|
"lib/glimmer-dsl-web/samples/hello/hello_page_component_link/conference_talk_page.rb",
|
|
@@ -23,6 +23,11 @@ class PageComponentButton
|
|
|
23
23
|
markup {
|
|
24
24
|
button(text, **@button_tag_attributes) {
|
|
25
25
|
onclick do |event|
|
|
26
|
+
# TODO provide the ability to programmatically push a component in
|
|
27
|
+
# and programmatically trigger a page load
|
|
28
|
+
# TODO support custom onclick behavior that comes from outside the component as well in case that's needed
|
|
29
|
+
# especially if needed to determine the component_attributes dynamically ahead of the code below
|
|
30
|
+
# Maybe there is a need for another listener to execute afterwards as well (like by supporting hooks)
|
|
26
31
|
event.prevent_default
|
|
27
32
|
page_component = nil
|
|
28
33
|
if component_attributes.nil?
|
|
@@ -23,6 +23,12 @@ class PageComponentLink
|
|
|
23
23
|
markup {
|
|
24
24
|
a(text, **@anchor_tag_attributes) {
|
|
25
25
|
onclick do |event|
|
|
26
|
+
# TODO provide the ability to programmatically push a component in
|
|
27
|
+
# and programmatically trigger a page load
|
|
28
|
+
# TODO support custom onclick behavior that comes from outside the component as well in case that's needed
|
|
29
|
+
# especially if needed to determine the component_attributes dynamically ahead of the code below
|
|
30
|
+
# Maybe there is a need for another listener to execute afterwards as well (like by supporting hooks)
|
|
31
|
+
|
|
26
32
|
event.prevent_default
|
|
27
33
|
page_component = nil
|
|
28
34
|
if component_attributes.nil?
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
require 'glimmer-dsl-web'
|
|
2
|
+
|
|
3
|
+
# only in the sample we need the unless statement to avoid conflicting with other samples, but not in real usage
|
|
4
|
+
unless Object.const_defined?(:GreetingPerson)
|
|
5
|
+
GreetingPerson = Struct.new(:name, keyword_init: true)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# only in the sample we need the unless statement to avoid conflicting with other samples, but not in real usage
|
|
9
|
+
unless Object.const_defined?(:GreetingModal)
|
|
10
|
+
class GreetingModal
|
|
11
|
+
include Glimmer::Web::Component
|
|
12
|
+
|
|
13
|
+
attribute :greeting_target, default: 'World'
|
|
14
|
+
|
|
15
|
+
markup {
|
|
16
|
+
div(class: 'modal-outer') {
|
|
17
|
+
div(class: 'modal-inner') {
|
|
18
|
+
h2 { 'Greeting' }
|
|
19
|
+
|
|
20
|
+
h3 { "Hello, #{greeting_target}!" }
|
|
21
|
+
|
|
22
|
+
div {
|
|
23
|
+
button('Close') {
|
|
24
|
+
onclick do
|
|
25
|
+
markup_root.remove
|
|
26
|
+
end
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
style {
|
|
34
|
+
r('.modal-outer') {
|
|
35
|
+
display 'flex'
|
|
36
|
+
position 'fixed'
|
|
37
|
+
left 0
|
|
38
|
+
top 0
|
|
39
|
+
width 100.vw
|
|
40
|
+
height 100.vh
|
|
41
|
+
background 'rgba(200, 200, 200, 0.8)'
|
|
42
|
+
margin 0
|
|
43
|
+
padding 0
|
|
44
|
+
justify_content 'center'
|
|
45
|
+
align_items 'center'
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
r('div.modal-inner') {
|
|
49
|
+
display 'flex'
|
|
50
|
+
flex_direction 'column'
|
|
51
|
+
width 300
|
|
52
|
+
height 160
|
|
53
|
+
justify_content 'center'
|
|
54
|
+
align_items 'center'
|
|
55
|
+
box_shadow '0 10px 30px rgba(0, 0, 0, 0.5)'
|
|
56
|
+
background :white
|
|
57
|
+
border_radius 15
|
|
58
|
+
padding 15
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
r('div.modal-inner button') {
|
|
62
|
+
width 135
|
|
63
|
+
margin 5
|
|
64
|
+
border_radius 5
|
|
65
|
+
padding 5
|
|
66
|
+
background :white
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
r('div.modal-inner button:hover') {
|
|
70
|
+
background :black
|
|
71
|
+
color :white
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
r('div.modal-inner h2') {
|
|
76
|
+
margin_top 10
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# only in the sample we need the unless statement to avoid conflicting with other samples, but not in real usage
|
|
83
|
+
unless Object.const_defined?(:HelloModal)
|
|
84
|
+
class HelloModal
|
|
85
|
+
include Glimmer::Web::Component
|
|
86
|
+
|
|
87
|
+
before_render do
|
|
88
|
+
@greeting_person = GreetingPerson.new
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
markup {
|
|
92
|
+
div {
|
|
93
|
+
div {
|
|
94
|
+
button('Greet The World') {
|
|
95
|
+
onclick do
|
|
96
|
+
# renders Modal under body by default, which works for Modals because they rely on fixed positioning
|
|
97
|
+
GreetingModal.render
|
|
98
|
+
end
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
div {
|
|
102
|
+
button('Greet Laura') {
|
|
103
|
+
onclick do
|
|
104
|
+
# renders Modal under body explicitly (parent takes a CSS expression) while passing it an attribute value
|
|
105
|
+
GreetingModal.render(parent: 'body', greeting_target: 'Laura')
|
|
106
|
+
end
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
div {
|
|
110
|
+
label { 'Greeting Person Name:' }
|
|
111
|
+
input(type: 'text') {
|
|
112
|
+
value <=> [@greeting_person, :name]
|
|
113
|
+
}
|
|
114
|
+
button {
|
|
115
|
+
inner_text <= [@greeting_person, :name, on_read: ->(name) { "Greet #{name}" }]
|
|
116
|
+
|
|
117
|
+
onclick do
|
|
118
|
+
# renders Modal under body by default while passing it a Model attribute value
|
|
119
|
+
GreetingModal.render(greeting_target: @greeting_person.name)
|
|
120
|
+
end
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
style {
|
|
127
|
+
r('.hello-modal div') {
|
|
128
|
+
margin_bottom 10
|
|
129
|
+
}
|
|
130
|
+
r('.hello-modal label, .hello-modal input, .hello-modal button') {
|
|
131
|
+
margin_right 5
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# only in the sample we need the Document.ready? call; in real usage,
|
|
138
|
+
# we rely on the glimmer_component helper to load this file inside a Rails View
|
|
139
|
+
Document.ready? do
|
|
140
|
+
HelloModal.render
|
|
141
|
+
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.9.
|
|
4
|
+
version: 0.9.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andy Maleh
|
|
@@ -315,6 +315,7 @@ files:
|
|
|
315
315
|
- lib/glimmer-dsl-web/samples/hello/hello_form_mvp/views/contact_table.rb
|
|
316
316
|
- lib/glimmer-dsl-web/samples/hello/hello_glimmer_component_helper/address_form.rb
|
|
317
317
|
- lib/glimmer-dsl-web/samples/hello/hello_input_date_time.rb
|
|
318
|
+
- lib/glimmer-dsl-web/samples/hello/hello_modal.rb
|
|
318
319
|
- lib/glimmer-dsl-web/samples/hello/hello_observer.rb
|
|
319
320
|
- lib/glimmer-dsl-web/samples/hello/hello_observer_data_binding.rb
|
|
320
321
|
- lib/glimmer-dsl-web/samples/hello/hello_page_component_link/conference_talk_page.rb
|