bulma-phlex 0.2.0 → 0.3.0

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: 9c9baf01284c1c12d06e389eb2871a7c9ada348d3611c26e74ce7d7f24136c83
4
- data.tar.gz: baaee6a523f95e49507bb6a289b28301fb1d218284aee8cef960dc6b53baf559
3
+ metadata.gz: 5838ff317a395e9e57b33d45dad7f62c3a7820112a2453c35e9305e7a6ac19c1
4
+ data.tar.gz: 48988fd8c7210d47b0090d9d385fa6fce278d2ad6d47d10673aabf9e46034df8
5
5
  SHA512:
6
- metadata.gz: 24302ffbdc624f9b1041ff786d0a57aaf2d3fed7abc4d32096a9c50f861a48049bc9c6ffdf27dfcbfbd94e50d3569debc5898617b77fe9d00be34bc2b702f5bd
7
- data.tar.gz: aaaa147076dfd55030ea1fd94adc9d4d71e0e05bc6bf8841eabe776d6633426142e06119635e6db68f9972df12369595c933e6fcba03845d7e0d326920ff271b
6
+ metadata.gz: 49c89b3e7e9aa630d01ce8ae14b0c35694d811533c37512e42d2d21dbcae83546a96e5ef0262b4078d9235d6cea73f3dcad529ed91c4dd0ccfda1eee1af040d4
7
+ data.tar.gz: 9840cfdb56b3af42f2a32c3717b985a29ef93d939444ceaef47545915e450e8717c543eff3f867946aacdaac45ca51dcd2845f0d53b3b61a3eaa594586964847
data/README.md CHANGED
@@ -117,12 +117,12 @@ The [NavigationBar](https://bulma.io/documentation/components/navbar/) component
117
117
  ```ruby
118
118
  render Components::Bulma::NavigationBar.new do |navbar|
119
119
  navbar.brand_item "My App", "/"
120
-
120
+
121
121
  navbar.left do |menu|
122
122
  menu.item "Home", "/"
123
123
  menu.item "Products", "/products"
124
124
  end
125
-
125
+
126
126
  navbar.right do |menu|
127
127
  menu.item "About", "/about"
128
128
  menu.dropdown "Account" do |dropdown|
@@ -152,6 +152,8 @@ render Components::Bulma::Pagination.new(@products, ->(page) { products_path(pag
152
152
 
153
153
  The [Table](https://bulma.io/documentation/elements/table/) component provides a way to display data in rows and columns with customizable headers and formatting options.
154
154
 
155
+ It requires a Hotwired Stimulus controller to manage the tabs and the content. By default, the controller name is assumed to be `bulma--tabs`, but can be overridden with the constructor keyword argument `stimulus_controller`. Stimulus targets and actions are added to the component.
156
+
155
157
  ```ruby
156
158
  users = User.all
157
159
 
@@ -159,11 +161,11 @@ render Components::Bulma::Table.new(users) do |table|
159
161
  table.column "Name" do |user|
160
162
  user.full_name
161
163
  end
162
-
164
+
163
165
  table.column "Email" do |user|
164
166
  user.email
165
167
  end
166
-
168
+
167
169
  table.column "Actions" do |user|
168
170
  link_to "Edit", edit_user_path(user), class: "button is-small"
169
171
  end
@@ -179,11 +181,11 @@ render Components::Bulma::Tabs.new do |tabs|
179
181
  tabs.tab(id: "profile", title: "Profile", active: true) do
180
182
  "Profile content goes here"
181
183
  end
182
-
184
+
183
185
  tabs.tab(id: "settings", title: "Settings", icon: "fas fa-cog") do
184
186
  "Settings content goes here"
185
187
  end
186
-
188
+
187
189
  tabs.tab(id: "notifications", title: "Notifications", icon: "fas fa-bell") do
188
190
  "Notifications content goes here"
189
191
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BulmaPhlex
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
@@ -30,7 +30,8 @@ module Components
30
30
  Tab = Data.define(:id, :title, :icon, :active)
31
31
  Content = Data.define(:id, :block, :active)
32
32
 
33
- def initialize
33
+ def initialize(stimulus_controller: "bulma--tabs")
34
+ @stimulus_controller = stimulus_controller
34
35
  @tabs = []
35
36
  @contents = []
36
37
  end
@@ -43,15 +44,16 @@ module Components
43
44
  def view_template(&)
44
45
  vanish(&)
45
46
 
46
- div(data: { controller: "tabs" }) do
47
+ div(data: { controller: @stimulus_controller }) do
47
48
  div(class: "tabs is-boxed") do
48
49
  ul do
49
50
  @tabs.each do |tab|
50
51
  li(
52
+ id: "#{tab.id}-tab",
51
53
  data: {
52
- tabs_target: "tab",
54
+ target_key => "tab",
53
55
  tab_content: tab.id,
54
- action: "click->tabs#showTabContent"
56
+ action: "click->#{@stimulus_controller}#showTabContent"
55
57
  },
56
58
  class: tab.active ? "is-active" : ""
57
59
  ) do
@@ -66,13 +68,19 @@ module Components
66
68
 
67
69
  @contents.each do |content|
68
70
  div(id: content.id,
69
- class: content.active ? "" : "hidden",
70
- data: { tabs_target: "content" }) do
71
+ class: content.active ? "" : "is-hidden",
72
+ data: { target_key => "content" }) do
71
73
  content.block.call
72
74
  end
73
75
  end
74
76
  end
75
77
  end
78
+
79
+ private
80
+
81
+ def target_key
82
+ "#{@stimulus_controller}-target"
83
+ end
76
84
  end
77
85
  end
78
86
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bulma-phlex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Kummer