proscenium 0.2.1-x86_64-linux → 0.3.0-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3865fbb2c2e0c606febd498305b5c547f4ed96ff271012f0a0a0069f7178bed0
4
- data.tar.gz: 4961bfa53fb5f2e495e7b5d60903fc9898cf61f9c6ac4b7fe1d33fd6e7c028d6
3
+ metadata.gz: 99abd883a1350e998b01ccd263607a8213c9efa13c13e8d691f58841f29fd355
4
+ data.tar.gz: 8958a092b13c4ff55ad664f8b37c48061f8ccf1cba5ce4f8a15d2b53c71dc74d
5
5
  SHA512:
6
- metadata.gz: c270f788bc4f61af038d19ce5250f70bbd3684061cfb2d865a5522c148ca78e713c47506c1813a73e72e11cd37f9c30d471bb04f617bbda14b7d26ded41b1b40
7
- data.tar.gz: 894ff8cc3f247356d8cf1983fda1dba591d33fb309aaedc765d30445a2d9eba97608f656c9e4c5fb72c12c81da088e7dd15d2f55685128bdd1cda9966156b80c
6
+ metadata.gz: ebcd43b63938a33ab45d24ac9bbf234a33bf886a6078dd8870d594749a780cb1dfa3dcde4879c83785f8c822bdb9fef9c36fd32ee2bde5b140c90efe2612954b
7
+ data.tar.gz: 5520e4305d344a4dd9e6ac09f3c529c4ed37262df1d7dae6ce1f7c6a717b9091985352ed628a5030e6fcf2ff7bcebf84de93205ee07677a67250a13521c8b0ec
data/bin/esbuild CHANGED
Binary file
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Proscenium::Phlex::Component < Proscenium::Phlex
4
+ private
5
+
6
+ def virtual_path
7
+ "/#{self.class.name.underscore}"
8
+ end
9
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Renders a div for use with component-manager.
5
+ #
6
+ class Proscenium::Phlex::ReactComponent < Proscenium::Phlex::Component
7
+ attr_accessor :props, :lazy
8
+
9
+ # @param props: [Hash]
10
+ # @param lazy: [Boolean] Lazy load the component using IntersectionObserver. Default: true.
11
+ def initialize(props: {}, lazy: true) # rubocop:disable Lint/MissingSuper
12
+ @props = props
13
+ @lazy = lazy
14
+ end
15
+
16
+ # @yield the given block to a `div` within the top level component div. If not given,
17
+ # `<div>loading...</div>` will be rendered. Use this to display a loading UI while the component
18
+ # is loading and rendered.
19
+ def template(&block)
20
+ div class: ['componentManagedByProscenium', '@component'],
21
+ data: { component: { path: virtual_path, props: props, lazy: lazy }.to_json } do
22
+ block ? div(&block) : div { 'loading...' }
23
+ end
24
+ end
25
+ end
@@ -1,7 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'phlex'
4
+
3
5
  module Proscenium
4
6
  class Phlex < ::Phlex::View
7
+ extend ActiveSupport::Autoload
8
+
9
+ autoload :Component
10
+ autoload :ReactComponent
11
+
12
+ module Helpers
13
+ def side_load_javascripts(...)
14
+ if (output = @_view_context.side_load_javascripts(...))
15
+ @_target << output
16
+ end
17
+ end
18
+
19
+ %i[side_load_stylesheets proscenium_dev].each do |name|
20
+ define_method name do
21
+ if (output = @_view_context.send(name))
22
+ @_target << output
23
+ end
24
+ end
25
+ end
26
+ end
27
+
5
28
  module Sideload
6
29
  def template(...)
7
30
  Proscenium::SideLoad.append self.class.path if Rails.application.config.proscenium.side_load
@@ -18,6 +41,7 @@ module Proscenium
18
41
  child.path = path.delete_prefix(::Rails.root.to_s).delete_suffix('.rb')[1..]
19
42
 
20
43
  child.prepend Sideload
44
+ child.include Helpers
21
45
 
22
46
  super
23
47
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Proscenium
4
- VERSION = '0.2.1'
4
+ VERSION = '0.3.0'
5
5
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class ReactComponent < ApplicationComponent
3
+ class Proscenium::ViewComponent::ReactComponent < Proscenium::ViewComponent
4
4
  attr_accessor :props, :lazy
5
5
 
6
6
  # @param props: [Hash]
@@ -15,7 +15,7 @@ class ReactComponent < ApplicationComponent
15
15
  def call
16
16
  tag.div class: ['componentManagedByProscenium', css_module(:component)],
17
17
  data: { component: { path: virtual_path, props: props, lazy: lazy } } do
18
- tag.div content
18
+ tag.div content || 'loading...'
19
19
  end
20
20
  end
21
21
  end
@@ -1,12 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Proscenium::ViewComponent
3
+ require 'view_component'
4
+
5
+ class Proscenium::ViewComponent < ViewComponent::Base
4
6
  extend ActiveSupport::Autoload
5
7
 
6
8
  autoload :TagBuilder
9
+ autoload :ReactComponent
7
10
 
8
11
  def render_in(...)
9
- cssm.compile_class_names(super)
12
+ cssm.compile_class_names(super(...))
10
13
  end
11
14
 
12
15
  def before_render
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proscenium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Joel Moss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-20 00:00:00.000000000 Z
11
+ date: 2022-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actioncable
@@ -92,6 +92,20 @@ dependencies:
92
92
  - - "~>"
93
93
  - !ruby/object:Gem::Version
94
94
  version: '3.13'
95
+ - !ruby/object:Gem::Dependency
96
+ name: phlex
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: 0.4.0
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: 0.4.0
95
109
  - !ruby/object:Gem::Dependency
96
110
  name: railties
97
111
  requirement: !ruby/object:Gem::Requirement
@@ -140,8 +154,6 @@ files:
140
154
  - README.md
141
155
  - app/channels/proscenium/connection.rb
142
156
  - app/channels/proscenium/reload_channel.rb
143
- - app/components/application_component.rb
144
- - app/components/react_component.rb
145
157
  - bin/esbuild
146
158
  - bin/lightningcss
147
159
  - config/routes.rb
@@ -171,6 +183,8 @@ files:
171
183
  - lib/proscenium/middleware/runtime.rb
172
184
  - lib/proscenium/middleware/static.rb
173
185
  - lib/proscenium/phlex.rb
186
+ - lib/proscenium/phlex/component.rb
187
+ - lib/proscenium/phlex/react_component.rb
174
188
  - lib/proscenium/precompile.rb
175
189
  - lib/proscenium/railtie.rb
176
190
  - lib/proscenium/runtime/auto_reload.js
@@ -180,6 +194,7 @@ files:
180
194
  - lib/proscenium/utils.js
181
195
  - lib/proscenium/version.rb
182
196
  - lib/proscenium/view_component.rb
197
+ - lib/proscenium/view_component/react_component.rb
183
198
  - lib/proscenium/view_component/tag_builder.rb
184
199
  - lib/tasks/assets.rake
185
200
  homepage: https://github.com/joelmoss/proscenium
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'view_component'
4
-
5
- class ApplicationComponent < ViewComponent::Base
6
- include Proscenium::ViewComponent
7
- end