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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 973ebc91558a780fcdfc2e8dea4c6b1bc3d090678ee30535768e3b9d7ad1f9aa
4
- data.tar.gz: 63e48c4f2b207557d9b111609a3dad42a10f70ea3719ea96a1477ed8f4e952fe
3
+ metadata.gz: f8bb20b23ebd77936e9d016fc914bad406118d259fc7e21b814ab21bd162dd48
4
+ data.tar.gz: b34976b5f6b8ba0e48a51f26d7fee4f13c2870631c5fdab88860e16db49d9bb0
5
5
  SHA512:
6
- metadata.gz: f1118112757bfde64bbdd6417827ad56ea031ba950f2006a8151436f55101ca14543b991317d3825ecd143844417b2fafe84c2d6cccf7d408c9c14d213e18c1f
7
- data.tar.gz: 7c1269811dd43b3a80188f9cafefc571c198c0eb9bd5adf9683353b7a67ef4ef915832a29bdf3fc1db710eeeb10a8ebca4b1829d4b05dacb7e2d05468891c01d
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 npm:
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
 
@@ -14,9 +14,9 @@ class CountdownComponent < TurboLive::Component
14
14
 
15
15
  def update(input)
16
16
  case input
17
- in [:countdown]
17
+ in :countdown
18
18
  self.countdown -= 1
19
- in [:start]
19
+ in :start
20
20
  self.countdown = 1000
21
21
  end
22
22
  end
@@ -15,11 +15,11 @@ class CounterComponent < TurboLive::Component
15
15
 
16
16
  def update(input)
17
17
  case input
18
- in [:decrement]
18
+ in :decrement
19
19
  self.count -= 1
20
- in [:increment]
20
+ in :increment
21
21
  self.count += 1
22
- in [:reset]
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 [:jump]
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 [:tick]
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 [[:change_component, component]]
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
@@ -50,9 +50,9 @@ class TicTacToeComponent < TurboLive::Component
50
50
 
51
51
  def update(input)
52
52
  case input
53
- in [[:make_move, index]]
53
+ in [:make_move, index]
54
54
  make_move(index)
55
- in [:reset_game]
55
+ in :reset_game
56
56
  reset_game
57
57
  end
58
58
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TurboLive
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
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.0
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-10-17 00:00:00.000000000 Z
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