bulmacomp 1.0.1 → 1.0.3

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: 647bf29f1a9fab7a95e21df2d882988ec017f863d3810d921a2cb48669ff919f
4
- data.tar.gz: 214f9696e9785dd75b54f503d91a050e3429b84b39ded5ce928635b8e22b7d13
3
+ metadata.gz: 4c579db82c3306bf4ab683b2a0fb23a78fa1255419c7365a70114ae8017088a4
4
+ data.tar.gz: a09f86598c6811550e1c2079fed013a67f7f969a2b122ee9e6b3e94f5d004006
5
5
  SHA512:
6
- metadata.gz: 85eff114f624eb7351346cc182ace4219e3b7914f72232aa955158119651aee2a9d03ac677eb33d007f06a4f73f0cb8792a750a033dff48b29dd8c0087f3a581
7
- data.tar.gz: 722d8526dbdb501bfd1deb8f30a4a80a0ee7c16e35f8c5f789b44be8f894ca038172a53851203dd6d5778d7cd95946c863576d58a45a560d4f7cb06d4a92fc63
6
+ metadata.gz: b1efdddbdf692b70bfa473db3eaab0c813ebb14991fa796e3b0ae325ec161f10bbce6e92ee4ce7ca2a7b65350b5f79a3892ed25a3bab6422567a70e07b4daefb
7
+ data.tar.gz: e04f0c81eca22bbdfd9b6e949417cb59b4e85178d4587280925c9d67598e11d87ddcfeba478b0071fc691f76cbd7c40cf82f3606f001c16501d863ac0fed30f6
data/README.md CHANGED
@@ -17,7 +17,11 @@ Bulmacomp provide a "view component" for each bulma component:
17
17
  * [Navbar](https://bulma.io/documentation/components/navbar/) - [Bulmacomp::NavbarCompoent](https://www.rubydoc.info/github/isprambiente/bulmacomp/Bulmacomp/NavbarComponent)
18
18
  * [Pagination](https://bulma.io/documentation/components/pagination/) - [Bulmacomp::PaginationComponent](https://www.rubydoc.info/github/isprambiente/bulmacomp/Bulmacomp/PaginationComponent)
19
19
  * [Panel](https://bulma.io/documentation/components/panel/) - [Bulmacomp::PanelComponent](https://www.rubydoc.info/github/isprambiente/bulmacomp/Bulmacomp/PanelComponent)
20
- * [Tabs](https://bulma.io/documentation/components/tabs/) - [Bulmacomp::TabsComponent](https://www.rubydoc.info/github/isprambiente/bulmacomp/Bulmacomp/tabsComponent)
20
+ * [Tabs](https://bulma.io/documentation/components/tabs/) - [Bulmacomp::TabsComponent](https://www.rubydoc.info/github/isprambiente/bulmacomp/Bulmacomp/TabsComponent)
21
+
22
+ and generic rails components
23
+ * [Turbo Frame](https://turbo.hotwired.dev/handbook/frames) - [Bulmacomp::TurboFrameComponent](https://www.rubydoc.info/github/isprambiente/bulmacomp/Bulmacomp/TurboFrameComponent)
24
+
21
25
 
22
26
  ## Installation
23
27
  Add this line to your application's Gemfile:
@@ -52,11 +52,13 @@ module Bulmacomp
52
52
 
53
53
  # @return [String] html_safe navbar
54
54
  def call
55
- tag.nav safe_join([navbar_brand, navbar_menu]), @opts
55
+ tag.nav safe_join([navbar_brand, navbar_menu]), **@opts
56
56
  end
57
57
 
58
58
  # @return [String] html_safe navbar-brand tag
59
59
  def navbar_brand
60
+ return if @brand.blank?
61
+
60
62
  tag.div safe_join([link_to(@brand, root_path, data_turbo_frame: 'yield', class: 'navbar-item'), navbar_burger]),
61
63
  class: 'navbar-brand'
62
64
  end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bulmacomp
4
+ # Make an HTML [turbo Frame](https://turbo.hotwired.dev/handbook/frames) structure.
5
+ #
6
+ # @example empty turbo frame, on default when the compoent is have't yield content, is added a lod icon
7
+ # = render Layout::TurboFrameComponent.new
8
+ #
9
+ # <turbo-frame>
10
+ # <span class="icon"><i class="fas fa-sync fa-spin fa-2x"></i></span>
11
+ # </turbo-frame>
12
+ #
13
+ # @example with id and src (to load remote content)
14
+ # = render Layout::TurboFrameComponent.new(id: 'nav1', src: books_path )
15
+ #
16
+ # <turbo-frame id='nav1' src='/books'>
17
+ # <span class="icon"><i class="fas fa-sync fa-spin fa-2x"></i></span>
18
+ # </turbo-frame>
19
+ #
20
+ # @example with no icon
21
+ # = render Layout::TurboFrameComponent.new(icon: nil, id: 'nav1', src: books_path )
22
+ #
23
+ # <turbo-frame id='nav1' src='/books'></turbo-frame>
24
+ #
25
+ # @example with yield content
26
+ # = render Layout::TurboFrameComponent.new do
27
+ # some text
28
+ #
29
+ # <turbo-frame>some text</turbo-frame>
30
+ class TurboFrameComponent < ViewComponent::Base
31
+ # @param [Hash] opts
32
+ # options to generate content
33
+ # @param [String] icon
34
+ # text to add whe yield content is empty
35
+ # default: [default_icon]
36
+ # @option opts [String] :*
37
+ # each other key going as tag option
38
+ # @yield [optional] turbo frame content
39
+ def initialize(icon: default_icon, **opts)
40
+ super
41
+ @icon = icon
42
+ @opts = opts
43
+ end
44
+
45
+ # @return [String] html turbo frame
46
+ def call
47
+ content_tag('turbo-frame', (content || @icon), **@opts)
48
+ end
49
+
50
+ # default value for icon
51
+ def default_icon
52
+ tag.span tag.i(class: 'fas fa-sync fa-spin fa-2x'), class: 'icon'
53
+ end
54
+ end
55
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bulmacomp
4
- VERSION = '1.0.1' # Costant of bulmacomp version
4
+ VERSION = '1.0.3' # Costant of bulmacomp version
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bulmacomp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - MDreW
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-26 00:00:00.000000000 Z
11
+ date: 2023-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -58,6 +58,7 @@ files:
58
58
  - app/components/bulmacomp/pagination_component.rb
59
59
  - app/components/bulmacomp/panel_component.rb
60
60
  - app/components/bulmacomp/tabs_component.rb
61
+ - app/components/bulmacomp/turbo_frame_component.rb
61
62
  - lib/bulmacomp.rb
62
63
  - lib/bulmacomp/engine.rb
63
64
  - lib/bulmacomp/version.rb
@@ -84,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
85
  - !ruby/object:Gem::Version
85
86
  version: '0'
86
87
  requirements: []
87
- rubygems_version: 3.4.8
88
+ rubygems_version: 3.4.10
88
89
  signing_key:
89
90
  specification_version: 4
90
91
  summary: Rails 'View Components' for Bulma