vident-view_component 0.2.0 → 0.4.0

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: 531cb753af8f2fe3ed02ae071bdd3f170cb79b37c5a970f5b23401c17ebd1ffb
4
- data.tar.gz: 6318503f767428d22fc646bd45039faefbe3ec395ad68d384ce6d9e3dd923f07
3
+ metadata.gz: ad652aba56d18b01a7991dbebe9c352f039c4bfb0279cfa1a9236a5db1af3d01
4
+ data.tar.gz: 790cedcfba8761ccbb75762ceaa6f698a844ceac7fa5460cefcd2f03a4df3264
5
5
  SHA512:
6
- metadata.gz: 4d97303c3d10624e0fb7436c0ef7e90fea4ae1f0870929a07c3029f461b5771b08472ffb5b10e4148080e4d15fcfce63a7c20ebe61f4e4c48b936b024fda0f03
7
- data.tar.gz: ac764eab2b7ca18370f087fefd4d6de96e2ac419359c50873c789ef6ee62d47eb4edfa609281931fbe8106183cfcc2d83aae42a697627b5bbd0a98d80cc2c65f
6
+ metadata.gz: 4084e8a506ff759189f8522ebf7dd9fd77510ede51da2555ff9ce7ecba864ef952633fa1392ebb0cfc2dcd6254484077a1c769f8d77d88e13a8ca425589b800f
7
+ data.tar.gz: df83bd0e4b7976b6545662d1e77f14767d8919afc2138e744cd1ee9b8ffd09dc71102e1a1e47aaeede590cc47d6b8d8a4d69ed42b7424e60b9dad41d733c36e6
data/README.md CHANGED
@@ -1,7 +1,13 @@
1
1
  # Vident::ViewComponent
2
- Short description and motivation.
3
2
 
3
+ [ViewComponent](https://viewcomponent.org/) powered [Vident](https://github.com/stevegeek/vident) components.
4
4
 
5
+ ```ruby
6
+ class ApplicationComponent < ::Vident::ViewComponent::Base
7
+ end
8
+ ```
9
+
10
+ For more details see [vident](https://github.com/stevegeek/vident).
5
11
 
6
12
  # Examples
7
13
 
@@ -28,7 +34,7 @@ It is an avatar component that can either be displayed as an image or as initial
28
34
  ```ruby
29
35
  class AvatarComponent < ::Vident::ViewComponent::Base
30
36
  include ::Vident::Tailwind
31
- include ::Vident::ViewComponent::Caching
37
+ include ::Vident::Caching
32
38
 
33
39
  no_stimulus_controller
34
40
  with_cache_key :attributes
@@ -1,39 +1,7 @@
1
1
  module Vident
2
2
  module ViewComponent
3
- class Base < ::ViewComponent::Base
3
+ class Base < Core
4
4
  include ::Vident::Component
5
-
6
- class << self
7
- def current_component_modified_time
8
- sidecar_view_modified_time + rb_component_modified_time
9
- end
10
-
11
- def sidecar_view_modified_time
12
- ::File.exist?(template_path) ? ::File.mtime(template_path).to_i.to_s : ""
13
- end
14
-
15
- def rb_component_modified_time
16
- ::File.exist?(component_path) ? ::File.mtime(component_path).to_i.to_s : ""
17
- end
18
-
19
- def template_path
20
- File.join components_base_path, "#{virtual_path}.html.erb"
21
- end
22
-
23
- def component_path
24
- File.join components_base_path, "#{virtual_path}.rb"
25
- end
26
-
27
- def components_base_path
28
- ::Rails.configuration.view_component.view_component_path || "app/components"
29
- end
30
- end
31
-
32
- # Helper to create the main element
33
- def parent_element(**options)
34
- @parent_element ||= RootComponent.new(**parent_element_attributes(options))
35
- end
36
- alias_method :root, :parent_element
37
5
  end
38
6
  end
39
7
  end
@@ -0,0 +1,37 @@
1
+ module Vident
2
+ module ViewComponent
3
+ class Core < ::ViewComponent::Base
4
+ class << self
5
+ def current_component_modified_time
6
+ sidecar_view_modified_time + rb_component_modified_time
7
+ end
8
+
9
+ def sidecar_view_modified_time
10
+ ::File.exist?(template_path) ? ::File.mtime(template_path).to_i.to_s : ""
11
+ end
12
+
13
+ def rb_component_modified_time
14
+ ::File.exist?(component_path) ? ::File.mtime(component_path).to_i.to_s : ""
15
+ end
16
+
17
+ def template_path
18
+ File.join components_base_path, "#{virtual_path}.html.erb"
19
+ end
20
+
21
+ def component_path
22
+ File.join components_base_path, "#{virtual_path}.rb"
23
+ end
24
+
25
+ def components_base_path
26
+ ::Rails.configuration.view_component.view_component_path || "app/components"
27
+ end
28
+ end
29
+
30
+ # Helper to create the main element
31
+ def parent_element(**options)
32
+ @parent_element ||= ::Vident::ViewComponent::RootComponent.new(**parent_element_attributes(options))
33
+ end
34
+ alias_method :root, :parent_element
35
+ end
36
+ end
37
+ end
@@ -26,11 +26,12 @@ module Vident
26
26
  def call
27
27
  # Generate outer tag options and render
28
28
  tag_type = content_tag_type
29
+ child_content = content # Evaluate before generating the outer tag options to ensure DSL methods are executed
29
30
  options = content_tag_options
30
31
  if SELF_CLOSING_TAGS.include?(tag_type)
31
32
  view_context.tag(tag_type, options)
32
33
  else
33
- view_context.content_tag(tag_type, content, options)
34
+ view_context.content_tag(tag_type, child_content, options)
34
35
  end
35
36
  end
36
37
 
@@ -1,5 +1,5 @@
1
1
  module Vident
2
2
  module ViewComponent
3
- VERSION = "0.2.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vident-view_component
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Ierodiaconou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-11 00:00:00.000000000 Z
11
+ date: 2024-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: railties
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '7'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '8'
22
+ version: '8.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,27 @@ dependencies:
29
29
  version: '7'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '8'
32
+ version: '8.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: activesupport
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '7'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '8.0'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '7'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '8.0'
33
53
  - !ruby/object:Gem::Dependency
34
54
  name: vident
35
55
  requirement: !ruby/object:Gem::Requirement
@@ -82,6 +102,7 @@ files:
82
102
  - lib/tasks/vident/view_component_tasks.rake
83
103
  - lib/vident/view_component.rb
84
104
  - lib/vident/view_component/base.rb
105
+ - lib/vident/view_component/core.rb
85
106
  - lib/vident/view_component/engine.rb
86
107
  - lib/vident/view_component/root_component.rb
87
108
  - lib/vident/view_component/version.rb
@@ -107,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
128
  - !ruby/object:Gem::Version
108
129
  version: '0'
109
130
  requirements: []
110
- rubygems_version: 3.4.10
131
+ rubygems_version: 3.5.3
111
132
  signing_key:
112
133
  specification_version: 4
113
134
  summary: Vident with ViewComponent