bulma-phlex 0.9.0 → 0.10.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: 3136a7a0dd22a5d85922b80419ece937d391f6cbd385ba668079eb65d4387a61
4
- data.tar.gz: 7553361a230fff3ecd6f121f6ec985348e4fc767a5f3927b27178676dea4de98
3
+ metadata.gz: 86dcdd7f2c7329c32ae420a8fc095975b4e4a1495802054c85789ee598230335
4
+ data.tar.gz: bb42b533fe7b41b347d2e83f89faba27ed519a9d88ca06faf3d73a321e397e27
5
5
  SHA512:
6
- metadata.gz: d500797827a0ef15b9ad2f5ef334d63440cce5f8501ad90b8a9e93e0bb2a3ff0edf71eadf9a47aa47e7ef2ba570418a50250a3c586e106f631a45763c8bfe096
7
- data.tar.gz: f62d2ae5b7c9dbba1fc3d73a775859ede75491d78faf2b6134aa34ed0101aad3991c3e1ee3555a41fa9fd7def98e18dcd026cd8e8c6909b3e7d0a44cda94dbf0
6
+ metadata.gz: d5ad488129b08c46c985c25852da8cbe20486a7059e0429acc64cb2e6eee00889e0a8bb921db8de0175a0d7645762209da9e7e260f1cc139089cbbe9b6b3dc51
7
+ data.tar.gz: ea95d770b73c2adfdc60a0eb4bb92541730c35008fafc44e638956bbb00413ba104c2cc8f1c0534671766a559e17d6d11c718e5a9ac8d2bce47215119d7f2702
data/README.md CHANGED
@@ -25,10 +25,14 @@ Finally, the optional Rails extensions for the Card and Table components have be
25
25
  - [Installation](#installation)
26
26
  - [Usage](#usage)
27
27
  - [Card](#card)
28
+ - [Columns](#columns)
28
29
  - [Dropdown](#dropdown)
29
30
  - [Form Field](#form-field)
31
+ - [Grid](#grid)
32
+ - [Icon](#icon)
30
33
  - [Level](#level)
31
34
  - [NavigationBar](#navigationbar)
35
+ - [Notification](#notification)
32
36
  - [Pagination](#pagination)
33
37
  - [Table](#table)
34
38
  - [Tabs](#tabs)
@@ -110,6 +114,29 @@ Icons can be added to the links by passing an `icon` keyword argument with the i
110
114
  ```
111
115
 
112
116
 
117
+ ### Columns
118
+
119
+ The [Columns](https://bulma.io/documentation/columns/basics/) component provides a way to create responsive columns layouts using Bulma's column classes. It generates the wrapping `div` with the `columns` class and handles all the options.
120
+
121
+ ```ruby
122
+ BulmaPhlex::Columns(gap: 4, multiline: true) do
123
+ div(class: "column is-one-third") { "Column 1" }
124
+ div(class: "column is-one-third") { "Column 2" }
125
+ div(class: "column is-one-third") { "Column 3" }
126
+ end
127
+ ```
128
+
129
+ **Constructor Keyword Arguments:**
130
+
131
+ - `minimum_breakpoint`: (Symbol, optional) Sets the minimum breakpoint for the columns; default is `:tablet`.
132
+ - `multiline`: (Boolean, optional) If true, allows the columns to wrap onto multiple lines.
133
+ - `gap`: (optional) Use an integer (0-8) to set the gap size between columns; use a hash keyed by breakpoints
134
+ to set responsive gap sizes.
135
+ - `centered`: (Boolean, optional) If true, centers the columns.
136
+ - `vcentered`: (Boolean, optional) If true, vertically centers the columns.
137
+
138
+
139
+
113
140
  ### Dropdown
114
141
 
115
142
  The [Dropdown](https://bulma.io/documentation/components/dropdown/) component provides a flexible dropdown menu for navigation or actions. It supports both click-to-toggle (default, requires a Stimulus controller) and hoverable modes, as well as alignment and icon customization.
@@ -169,6 +196,52 @@ The label can be passed in as a string or created with a block:
169
196
  - `grid`: When true, adds the `cell` class to the container. Can also be a string specifying the heighth or width of the cell (such as `col-span-3`).
170
197
 
171
198
 
199
+ ### Grid
200
+
201
+ The [Grid](https://bulma.io/documentation/grid/smart-grid/) component provides a flexible grid layout system using Bulma's grid classes.
202
+
203
+ ```ruby
204
+ BulmaPhlex::Grid(minimum_column_width: 16) do
205
+ @tiles.each do |tile|
206
+ div(class: "cell") do
207
+ ... render tile ...
208
+ end
209
+ end
210
+ end
211
+ ```
212
+
213
+ **Constructor Keyword Arguments:**
214
+
215
+ - `fixed_columns`: (Integer, optional) Specifies a fixed number of columns for the grid.
216
+ - `auto_count`: (Boolean, optional) If true, the grid will automatically adjust the number
217
+ of columns based on the breakpoint.
218
+ - `minimum_column_width`: (Integer 1-32, optional) Sets a minimum width for the columns in the grid.
219
+ - `gap`: (optional) Sets the gap size between grid items, from 1-8 with 0.5 increments.
220
+ - `column_gap`: (optional) Sets the column gap size between grid items, from 1-8 with 0.5 increments.
221
+ - `row_gap`: (optional) Sets the row gap size between grid items, from 1-8 with 0.5 increments.
222
+
223
+
224
+ ### Icon
225
+
226
+ The [Icon](https://bulma.io/documentation/elements/icon/) component provides a way to display icons using Font Awesome or other icon libraries, with support for different sizes and colors.
227
+
228
+ ```ruby
229
+ BulmaPhlex::Icon("fas fa-user", size: "large", color: "primary")
230
+ ```
231
+
232
+ **Constructor Arguments:**
233
+
234
+ - `icon_class`: (positional, required) The icon class to display (such as `fas fa-user`).
235
+ - `size`: (optional) The [Bulma icon size](https://bulma.io/documentation/elements/icon/#sizes): small, medium, large.
236
+ - `color`: (optional) The [Bulma color class](https://bulma.io/documentation/elements/icon/#colors) to apply.
237
+ - `text_right`: (optional) Text to display to the right of the icon.
238
+ - `text_left`: (optional) Text to display to the left of the icon.
239
+ - `left`: (optional) If true, adds the `is-left` class for use in form controls.
240
+ - `right`: (optional) If true, adds the `is-right` class for use in form controls.
241
+
242
+ Any additional HTML attributes are passed to the icon container span.
243
+
244
+
172
245
  ### Level
173
246
 
174
247
  The [Level](https://bulma.io/documentation/layout/level/) component provides a flexible horizontal layout system with left and right alignment.
@@ -222,6 +295,40 @@ end
222
295
  > [!NOTE]
223
296
  > Adding a container will limit the width of the Navigation Bar content according to Bulma's container rules. However, the background color of the navbar will still span the full width of the viewport.
224
297
 
298
+
299
+ ### Notification
300
+
301
+ The [Notification](https://bulma.io/documentation/components/notification/) component provides a way to display messages or alerts with customizable styles and a close button.
302
+
303
+ ```ruby
304
+ BulmaPhlex::Notification(color: "info", delete: true) do
305
+ "This is an informational notification with a close button."
306
+ end
307
+ ```
308
+
309
+ The `delete` keyword argument adds a close button to the notification. In addition to setting it to `true`, it can also be a hash of HTML attributes for the button, such as a data attribute to hook into a Stimulus controller.
310
+
311
+ ```ruby
312
+ BulmaPhlex::Notification(color: "warning", delete: { data: { controller: "bulma-phlex--notification" } }) do
313
+ "This is a warning notification with a close button that works with a Stimulus controller."
314
+ end
315
+ ```
316
+
317
+ **Constructor Keyword Arguments:**
318
+
319
+ - `delete`: (optional) When true, adds a close button to the notification. Can also be a hash of HTML attributes for the button.
320
+ - `color`: (optional) The [Bulma color class](https://bulma.io/documentation/elements/tag/#colors) to apply.
321
+ - `mode`: Sets the mode of the notification: "light" or "dark".
322
+
323
+ Any additional attributes are passed to the notification container div.
324
+
325
+ ```ruby
326
+ BulmaPhlex::Notification(id: "my-notification", class: "ml-3") do
327
+ "This is a notification with custom id and class."
328
+ end
329
+ ```
330
+
331
+
225
332
  ### Pagination
226
333
 
227
334
  The [Pagination](https://bulma.io/documentation/components/pagination/) component provides navigation controls for paginated content, including previous/next links, page number links, and a summary of items being displayed.
@@ -7,12 +7,5 @@ module BulmaPhlex
7
7
  # It provides common utility methods and inherits from `Phlex::HTML`.
8
8
  #
9
9
  class Base < Phlex::HTML
10
- private
11
-
12
- def icon_span(icon, additional_classes = nil)
13
- span(class: "icon #{additional_classes}".strip) do
14
- i(class: icon)
15
- end
16
- end
17
10
  end
18
11
  end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BulmaPhlex
4
+ # # Columns Component
5
+ #
6
+ # The Columns component creates a responsive column layout using Bulma's column system.
7
+ #
8
+ # ## Keyword Arguments
9
+ #
10
+ # - `minimum_breakpoint`: (Symbol, optional) Sets the minimum breakpoint for the columns; default is `:tablet`.
11
+ # - `multiline`: (Boolean, optional) If true, allows the columns to wrap onto multiple lines.
12
+ # - `gap`: (optional) Use an integer (0-8) to set the gap size between columns; use a hash keyed by breakpoints
13
+ # to set responsive gap sizes.
14
+ # - `centered`: (Boolean, optional) If true, centers the columns.
15
+ # - `vcentered`: (Boolean, optional) If true, vertically centers the columns.
16
+ class Columns < BulmaPhlex::Base
17
+ def initialize(minimum_breakpoint: nil, # rubocop:disable Metrics/ParameterLists
18
+ multiline: false,
19
+ gap: nil,
20
+ centered: false,
21
+ vcentered: false,
22
+ **html_attributes)
23
+ @minimum_breakpoint = minimum_breakpoint
24
+ @multiline = multiline
25
+ @gap = gap
26
+ @centered = centered
27
+ @vcentered = vcentered
28
+ @html_attributes = html_attributes
29
+ end
30
+
31
+ def view_template(&)
32
+ div(**mix({ class: columns_classes }, @html_attributes), &)
33
+ end
34
+
35
+ private
36
+
37
+ def columns_classes
38
+ classes = ["columns"]
39
+ classes << "is-#{@minimum_breakpoint}" if @minimum_breakpoint
40
+ classes << "is-multiline" if @multiline
41
+ classes << "is-centered" if @centered
42
+ classes << "is-vcentered" if @vcentered
43
+ gap_classes(classes) if @gap
44
+ classes.join(" ")
45
+ end
46
+
47
+ def gap_classes(classes)
48
+ if @gap.is_a?(Integer)
49
+ classes << "is-#{@gap}"
50
+ elsif @gap.is_a?(Hash)
51
+ @gap.each do |breakpoint, size|
52
+ classes << "is-#{size}-#{breakpoint}"
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -56,6 +56,17 @@ module BulmaPhlex
56
56
  # end
57
57
  # ```
58
58
  #
59
+ # ### Shorthand with no Label
60
+ #
61
+ # If no label is needed, you can use the shorthand syntax which just puts the control
62
+ # in the block without needing to call `control` explicitly:
63
+ #
64
+ # ```ruby
65
+ # FormField(help: "Enter the project name.") do
66
+ # input id: "project_name", name: "project[name]", type: "text"
67
+ # end
68
+ # ```
69
+ #
59
70
  # ## References
60
71
  #
61
72
  # - [Bulma Form Field](https://bulma.io/documentation/form/general/#form-field)
@@ -84,13 +95,14 @@ module BulmaPhlex
84
95
  @control_builder = block
85
96
  end
86
97
 
87
- def view_template(&)
88
- vanish(&)
98
+ def view_template(&implicit_control)
99
+ @control_builder = implicit_control if @control_builder.nil? && implicit_control
100
+ vanish(&implicit_control)
89
101
 
90
102
  div(class: field_classes) do
91
103
  render_label
92
104
  render FormControl.new(class: control_classes) do
93
- render raw @control_builder.call
105
+ raw @control_builder.call
94
106
  Icon(@icon_left, size: :small, left: true) if @icon_left
95
107
  Icon(@icon_right, size: :small, right: true) if @icon_right
96
108
  end
@@ -131,7 +143,7 @@ module BulmaPhlex
131
143
  if @label_string
132
144
  html_label(class: "label") { @label_string }
133
145
  elsif @label_builder
134
- render raw @label_builder&.call
146
+ raw @label_builder&.call
135
147
  end
136
148
  end
137
149
 
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BulmaPhlex
4
+ # # Grid Component
5
+ #
6
+ # The Grid component create a responsive grid layout using Bulma's grid system.
7
+ #
8
+ # ## Keyword Arguments
9
+ #
10
+ # - `fixed_columns`: (Integer, optional) Specifies a fixed number of columns for the grid.
11
+ # - `auto_count`: (Boolean, optional) If true, the grid will automatically adjust the number
12
+ # of columns based on the content.
13
+ # - `minimum_column_width`: (Integer 1-32, optional) Sets a minimum width for the columns in the grid.
14
+ # - `gap`: (optional) Sets the gap size between grid items from 1-8 with 0.5 increments.
15
+ # - `column_gap`: (optional) Sets the column gap size between grid items from 1-8 with 0.5 increments.
16
+ # - `row_gap`: (optional) Sets the row gap size between grid items from 1-8 with 0.5 increments.
17
+ class Grid < BulmaPhlex::Base
18
+ def initialize(fixed_columns: nil, # rubocop:disable Metrics/ParameterLists
19
+ auto_count: false,
20
+ minimum_column_width: nil,
21
+ gap: nil,
22
+ column_gap: nil,
23
+ row_gap: nil,
24
+ **html_attributes)
25
+ @fixed_columns = fixed_columns
26
+ @auto_count = auto_count
27
+ @minimum_column_width = minimum_column_width
28
+ @gap = gap
29
+ @column_gap = column_gap
30
+ @row_gap = row_gap
31
+ @html_attributes = html_attributes
32
+ end
33
+
34
+ def view_template(&)
35
+ optional_fixed_grid_wrapper do
36
+ div(**mix({ class: grid_classes }, @html_attributes), &)
37
+ end
38
+ end
39
+
40
+ private
41
+
42
+ def optional_fixed_grid_wrapper(&)
43
+ if @fixed_columns || @auto_count
44
+ div(**mix({ class: fixed_grid_classes }, @html_attributes)) do
45
+ @html_attributes = {}
46
+ yield
47
+ end
48
+ else
49
+ yield
50
+ end
51
+ end
52
+
53
+ def grid_classes
54
+ classes = ["grid"]
55
+ classes << "is-col-min-#{@minimum_column_width}" if @minimum_column_width
56
+ classes << "is-gap-#{@gap}" if @gap
57
+ classes << "is-column-gap-#{@column_gap}" if @column_gap
58
+ classes << "is-row-gap-#{@row_gap}" if @row_gap
59
+ classes.join(" ")
60
+ end
61
+
62
+ def fixed_grid_classes
63
+ classes = ["fixed-grid"]
64
+ classes << "has-#{@fixed_columns}-cols" if @fixed_columns
65
+ classes << "has-auto-count" if @auto_count
66
+ classes.join(" ")
67
+ end
68
+ end
69
+ end
@@ -28,7 +28,8 @@ module BulmaPhlex
28
28
  size: nil,
29
29
  color: nil,
30
30
  left: false,
31
- right: false)
31
+ right: false,
32
+ **html_attributes)
32
33
  @icon = icon
33
34
  @text_right = text_right
34
35
  @text_left = text_left
@@ -36,12 +37,13 @@ module BulmaPhlex
36
37
  @color = color
37
38
  @left = left
38
39
  @right = right
40
+ @html_attributes = html_attributes
39
41
  end
40
42
 
41
43
  def view_template
42
44
  optional_text_wrapper do
43
45
  span { @text_left } if @text_left
44
- span(class: icon_classes) do
46
+ span(**mix({ class: icon_classes }, @html_attributes)) do
45
47
  i(class: @icon)
46
48
  end
47
49
  span { @text_right } if @text_right
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BulmaPhlex
4
+ # # Notification
5
+ #
6
+ # The Bulma Notification component can be styled with the following options:
7
+ #
8
+ # - `delete`: If true, includes a delete button to dismiss the notification. Can also be a hash of HTML
9
+ # attributes for the button.
10
+ # - `color`: Sets the color of the notification. Accepts any Bulma color class suffix (e.g., "primary",
11
+ # "info", "danger").
12
+ # - `mode`: Sets the mode of the notification: "light" or "dark".
13
+ #
14
+ # Any additional HTML attributes passed to the component will be applied to the notification div.
15
+ #
16
+ # The content of the notification is provided via a block.
17
+ class Notification < BulmaPhlex::Base
18
+ def initialize(delete: false, color: nil, mode: nil, **html_attributes)
19
+ @delete = delete
20
+ @color = color
21
+ @mode = mode
22
+ @html_attributes = html_attributes
23
+ end
24
+
25
+ def view_template(&)
26
+ vanish(&)
27
+
28
+ div(**mix({ class: notification_classes }, **@html_attributes)) do
29
+ delete_button if @delete
30
+ yield
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def notification_classes
37
+ classes = ["notification"]
38
+ classes << "is-#{@color}" if @color.present?
39
+ classes << "is-#{@mode}" if @mode.present?
40
+ classes.join(" ")
41
+ end
42
+
43
+ def delete_button
44
+ html_attributes = { class: "delete" }
45
+ html_attributes = mix(html_attributes, @delete) if @delete.is_a?(Hash)
46
+ button(**html_attributes)
47
+ end
48
+ end
49
+ end
@@ -32,7 +32,7 @@ module BulmaPhlex
32
32
  class: @active ? "is-active" : ""
33
33
  ) do
34
34
  a do
35
- icon_span(@icon, "mr-1") if @icon
35
+ Icon(@icon, class: "mr-1") if @icon
36
36
  span { @title }
37
37
  end
38
38
  end
@@ -72,7 +72,7 @@ module BulmaPhlex
72
72
  html_attributes[:class] = [html_attributes[:class], "has-text-centered"].compact.join(" ")
73
73
 
74
74
  column(header, **html_attributes) do |row|
75
- icon_span(icon_class) if content.call(row)
75
+ Icon(icon_class) if content.call(row)
76
76
  end
77
77
  end
78
78
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BulmaPhlex
4
- VERSION = "0.9.0"
4
+ VERSION = "0.10.0"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bulma-phlex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Kummer
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-01-24 00:00:00.000000000 Z
10
+ date: 2026-02-01 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: phlex
@@ -66,13 +66,16 @@ files:
66
66
  - lib/bulma_phlex.rb
67
67
  - lib/bulma_phlex/base.rb
68
68
  - lib/bulma_phlex/card.rb
69
+ - lib/bulma_phlex/columns.rb
69
70
  - lib/bulma_phlex/dropdown.rb
70
71
  - lib/bulma_phlex/form_control.rb
71
72
  - lib/bulma_phlex/form_field.rb
73
+ - lib/bulma_phlex/grid.rb
72
74
  - lib/bulma_phlex/icon.rb
73
75
  - lib/bulma_phlex/level.rb
74
76
  - lib/bulma_phlex/navigation_bar.rb
75
77
  - lib/bulma_phlex/navigation_bar_dropdown.rb
78
+ - lib/bulma_phlex/notification.rb
76
79
  - lib/bulma_phlex/pagination.rb
77
80
  - lib/bulma_phlex/tab_components/content.rb
78
81
  - lib/bulma_phlex/tab_components/tab.rb