diff --git a/CHANGELOG.md b/CHANGELOG.md
index a0a0602..1aabd18 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,9 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [1.0.2]
+### Added
+* generic turbo frame component
+
## [1.0.1]
### Fixed
-* added correct spec dependence
+* spec dependence
## [1.0.0]
First official stable version, all bulma components are present
diff --git a/Gemfile.lock b/Gemfile.lock
index 0f62c2a..310f547 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- bulmacomp (1.0.1)
+ bulmacomp (1.0.2)
rails (>= 7.0)
view_component (>= 2.76)
@@ -217,4 +217,4 @@ DEPENDENCIES
yard
BUNDLED WITH
- 2.4.6
+ 2.4.8
diff --git a/README.md b/README.md
index 7312f22..ab4ab47 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,11 @@ Bulmacomp provide a "view component" for each bulma component:
* [Navbar](https://bulma.io/documentation/components/navbar/) - [Bulmacomp::NavbarCompoent](https://www.rubydoc.info/github/isprambiente/bulmacomp/Bulmacomp/NavbarComponent)
* [Pagination](https://bulma.io/documentation/components/pagination/) - [Bulmacomp::PaginationComponent](https://www.rubydoc.info/github/isprambiente/bulmacomp/Bulmacomp/PaginationComponent)
* [Panel](https://bulma.io/documentation/components/panel/) - [Bulmacomp::PanelComponent](https://www.rubydoc.info/github/isprambiente/bulmacomp/Bulmacomp/PanelComponent)
-* [Tabs](https://bulma.io/documentation/components/tabs/) - [Bulmacomp::TabsComponent](https://www.rubydoc.info/github/isprambiente/bulmacomp/Bulmacomp/tabsComponent)
+* [Tabs](https://bulma.io/documentation/components/tabs/) - [Bulmacomp::TabsComponent](https://www.rubydoc.info/github/isprambiente/bulmacomp/Bulmacomp/TabsComponent)
+
+and generic rails components
+* [Turbo Frame](https://turbo.hotwired.dev/handbook/frames) - [Bulmacomp::TurboFrameComponent](https://www.rubydoc.info/github/isprambiente/bulmacomp/Bulmacomp/TurboFrameComponent)
+
## Installation
Add this line to your application's Gemfile:
diff --git a/app/components/bulmacomp/turbo_frame_component.rb b/app/components/bulmacomp/turbo_frame_component.rb
new file mode 100644
index 0000000..d8a9a31
--- /dev/null
+++ b/app/components/bulmacomp/turbo_frame_component.rb
@@ -0,0 +1,55 @@
+# frozen_string_literal: true
+
+module Bulmacomp
+ # Make an HTML [turbo Frame](https://turbo.hotwired.dev/handbook/frames) structure.
+ #
+ # @example empty turbo frame, on default when the compoent is have't yield content, is added a lod icon
+ # = render Layout::TurboFrameComponent.new
+ #
+ #
+ #
+ #
+ #
+ # @example with id and src (to load remote content)
+ # = render Layout::TurboFrameComponent.new(id: 'nav1', src: books_path )
+ #
+ #
+ #
+ #
+ #
+ # @example with no icon
+ # = render Layout::TurboFrameComponent.new(icon: nil, id: 'nav1', src: books_path )
+ #
+ #
+ #
+ # @example with yield content
+ # = render Layout::TurboFrameComponent.new do
+ # some text
+ #
+ # some text
+ class TurboFrameComponent < ViewComponent::Base
+ # @param [Hash] opts
+ # options to generate content
+ # @param [String] icon
+ # text to add whe yield content is empty
+ # default: [default_icon]
+ # @option opts [String] :*
+ # each other key going as tag option
+ # @yield [optional] turbo frame content
+ def initialize(icon: default_icon, **opts)
+ super
+ @icon = icon
+ @opts = opts
+ end
+
+ # @return [String] html turbo frame
+ def call
+ content_tag('turbo-frame', (content || @icon), **@opts)
+ end
+
+ # default value for icon
+ def default_icon
+ tag.span tag.i(class: 'fas fa-sync fa-spin fa-2x'), class: 'icon'
+ end
+ end
+end
diff --git a/lib/bulmacomp/version.rb b/lib/bulmacomp/version.rb
index f2f95fd..5292778 100644
--- a/lib/bulmacomp/version.rb
+++ b/lib/bulmacomp/version.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
module Bulmacomp
- VERSION = '1.0.1' # Costant of bulmacomp version
+ VERSION = '1.0.2' # Costant of bulmacomp version
end
diff --git a/test/components/bulmacomp/turbo_frame_component_test.rb b/test/components/bulmacomp/turbo_frame_component_test.rb
new file mode 100644
index 0000000..b4d44e4
--- /dev/null
+++ b/test/components/bulmacomp/turbo_frame_component_test.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+require 'test_helper'
+
+module Bulmacomp
+ class TurboFrameComponentTest < ViewComponent::TestCase
+ # empty turbo frame
+ test 'empty' do
+ render_inline Bulmacomp::TurboFrameComponent.new
+ assert_selector 'turbo-frame', text: nil
+ assert_selector 'turbo-frame span.icon i.fas.fa-sync.fa-spin.fa-2x', text: nil
+ end
+
+ # turbo frame with id and src
+ test 'with id and src' do
+ render_inline Bulmacomp::TurboFrameComponent.new(id: 'nav1', src: '/books')
+ assert_selector 'turbo-frame#nav1[src="/books"]', text: nil
+ assert_selector 'turbo-frame span.icon i.fas.fa-sync.fa-spin.fa-2x', text: nil
+ end
+
+ # turbo frame without icon
+ test 'no icon' do
+ render_inline Bulmacomp::TurboFrameComponent.new(icon: nil)
+ assert_selector 'turbo-frame:empty', text: nil
+ end
+
+ # turbo frame with yield content
+ test 'with content' do
+ render_inline Bulmacomp::TurboFrameComponent.new.with_content('some text')
+ assert_selector 'turbo-frame', text: 'some text'
+ assert_selector 'turbo-frame:not(:has(> *))'
+ end
+ end
+end