turbo_live 0.2.0 → 0.2.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/README.md +24 -2
- data/examples/countdown_component.rb +2 -2
- data/examples/counter_component.rb +3 -3
- data/examples/flappy_bird_component.rb +2 -2
- data/examples/showcase_component.rb +4 -1
- data/examples/tic_tac_toe_component.rb +2 -2
- data/lib/turbo_live/version.rb +1 -1
- data/lib/turbo_live.rb +1 -1
- metadata +3 -3
- /data/app/channels/{components_channel.rb → turbo_live/components_channel.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8bb20b23ebd77936e9d016fc914bad406118d259fc7e21b814ab21bd162dd48
|
4
|
+
data.tar.gz: b34976b5f6b8ba0e48a51f26d7fee4f13c2870631c5fdab88860e16db49d9bb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f23e8d630a733dad9c92b6ad79458213aa97b0f7f1c527a1e30b4b65914e62675ffeda07e3a272cdd8e8d924500c8fe36ae16c712922788b50b4939bcedad464
|
7
|
+
data.tar.gz: 266d2bcc3e8b82977ee5474dee219b88ce3e0d82b6de7258f231ec302807e87b8479422b4c124a8b3c05d1792d4293e01d81460b66809b1dfa7d4ea969b7923b
|
data/README.md
CHANGED
@@ -46,7 +46,13 @@ For importmaps:
|
|
46
46
|
bin/importmap pin @radioactive-labs/turbo-live
|
47
47
|
```
|
48
48
|
|
49
|
-
For
|
49
|
+
For yarn:
|
50
|
+
|
51
|
+
```console
|
52
|
+
yarn add @radioactive-labs/turbo-live
|
53
|
+
```
|
54
|
+
|
55
|
+
Or YAR:
|
50
56
|
|
51
57
|
```console
|
52
58
|
npm install @radioactive-labs/turbo-live
|
@@ -54,6 +60,21 @@ npm install @radioactive-labs/turbo-live
|
|
54
60
|
|
55
61
|
## Setup
|
56
62
|
|
63
|
+
### Rails Routes
|
64
|
+
|
65
|
+
In your rails routes, mount the engine:
|
66
|
+
|
67
|
+
```diff
|
68
|
+
Rails.application.routes.draw do
|
69
|
+
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
|
70
|
+
|
71
|
+
+ mount TurboLive::Engine => "/turbo_live"
|
72
|
+
|
73
|
+
# Defines the root path route ("/")
|
74
|
+
root "index#index"
|
75
|
+
end
|
76
|
+
```
|
77
|
+
|
57
78
|
### Stimulus Controller
|
58
79
|
|
59
80
|
TurboLive uses a Stimulus controller to manage interactions. In your `app/javascript/controllers/index.js`:
|
@@ -61,9 +82,10 @@ TurboLive uses a Stimulus controller to manage interactions. In your `app/javasc
|
|
61
82
|
```diff
|
62
83
|
import { application } from "controllers/application"
|
63
84
|
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
|
64
|
-
+import * as turboLive from "@radioactive-labs/turbo-live"
|
65
85
|
|
66
86
|
eagerLoadControllersFrom("controllers", application)
|
87
|
+
|
88
|
+
+import * as turboLive from "@radioactive-labs/turbo-live"
|
67
89
|
+turboLive.registerControllers(application)
|
68
90
|
```
|
69
91
|
|
@@ -15,11 +15,11 @@ class CounterComponent < TurboLive::Component
|
|
15
15
|
|
16
16
|
def update(input)
|
17
17
|
case input
|
18
|
-
in
|
18
|
+
in :decrement
|
19
19
|
self.count -= 1
|
20
|
-
in
|
20
|
+
in :increment
|
21
21
|
self.count += 1
|
22
|
-
in
|
22
|
+
in :reset
|
23
23
|
self.count = 0
|
24
24
|
end
|
25
25
|
end
|
@@ -75,14 +75,14 @@ class FlappyBirdComponent < TurboLive::Component
|
|
75
75
|
|
76
76
|
def update(input)
|
77
77
|
case input
|
78
|
-
in
|
78
|
+
in :jump
|
79
79
|
if game_over
|
80
80
|
reset_game
|
81
81
|
else
|
82
82
|
self.nonce = NONCES[live_id] = NONCES[live_id] + 1
|
83
83
|
self.bird_velocity = JUMP_STRENGTH
|
84
84
|
end
|
85
|
-
in
|
85
|
+
in :tick
|
86
86
|
norender! if nonce < NONCES[live_id]
|
87
87
|
update_game_state
|
88
88
|
end
|
@@ -12,6 +12,7 @@ class ShowcaseComponent < TurboLive::Component
|
|
12
12
|
li { button(**on(click: [:change_component, :countdown])) { "Countdown" } }
|
13
13
|
li { button(**on(click: [:change_component, :tic_tac_toe])) { "TicTacToe" } }
|
14
14
|
li { button(**on(click: [:change_component, :flappy_bird])) { "Flappy Bird" } }
|
15
|
+
li { button(**on(click: [:change_component, :form])) { "Form" } }
|
15
16
|
end
|
16
17
|
end
|
17
18
|
div class: "right-column" do
|
@@ -24,7 +25,7 @@ class ShowcaseComponent < TurboLive::Component
|
|
24
25
|
|
25
26
|
def update(input)
|
26
27
|
case input
|
27
|
-
in [
|
28
|
+
in [:change_component, component]
|
28
29
|
self.component = component
|
29
30
|
end
|
30
31
|
end
|
@@ -41,6 +42,8 @@ class ShowcaseComponent < TurboLive::Component
|
|
41
42
|
TicTacToeComponent
|
42
43
|
when :flappy_bird
|
43
44
|
FlappyBirdComponent
|
45
|
+
when :form
|
46
|
+
FormComponent
|
44
47
|
end
|
45
48
|
end
|
46
49
|
end
|
data/lib/turbo_live/version.rb
CHANGED
data/lib/turbo_live.rb
CHANGED
@@ -5,7 +5,7 @@ require_relative "turbo_live/component"
|
|
5
5
|
require_relative "turbo_live/renderer"
|
6
6
|
|
7
7
|
require_relative "turbo_live/engine" if defined?(Rails)
|
8
|
-
require_relative "../app/channels/components_channel" if defined?(ActionCable)
|
8
|
+
require_relative "../app/channels/turbo_live/components_channel" if defined?(ActionCable::Channel::Base)
|
9
9
|
|
10
10
|
module TurboLive
|
11
11
|
class Error < StandardError; end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turbo_live
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TheDumbTechGuy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: phlex-rails
|
@@ -52,7 +52,7 @@ files:
|
|
52
52
|
- LICENSE.txt
|
53
53
|
- README.md
|
54
54
|
- Rakefile
|
55
|
-
- app/channels/components_channel.rb
|
55
|
+
- app/channels/turbo_live/components_channel.rb
|
56
56
|
- app/controllers/turbo_live/components_controller.rb
|
57
57
|
- config/routes.rb
|
58
58
|
- examples/countdown_component.rb
|
File without changes
|