bulma-phlex 0.8.2 → 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: afb300daa04f06472595582cc1bdfba1728e33dfcecd5c12b8d9d96ac0a595cb
4
- data.tar.gz: 34d233c24acc831cb2d62544bd589e0635664be90703c65775aa0b0cc4e9fcdb
3
+ metadata.gz: 86dcdd7f2c7329c32ae420a8fc095975b4e4a1495802054c85789ee598230335
4
+ data.tar.gz: bb42b533fe7b41b347d2e83f89faba27ed519a9d88ca06faf3d73a321e397e27
5
5
  SHA512:
6
- metadata.gz: e4d8a16c89010c53770305c8851c43b02f6edc084713945977934a9376854a670a1950e8e710b5f4be38f7455817bcac44eb81cc4c15e228fb7b6d2dc64213b8
7
- data.tar.gz: 5e3368563f12815dfce93fa79ea568b60369dd186b00202d6891aecea9c5831ccc3388cffb77a88b4edb0bcb5ff79ad5f5f2aedbb054ca95288db582cd3d35fa
6
+ metadata.gz: d5ad488129b08c46c985c25852da8cbe20486a7059e0429acc64cb2e6eee00889e0a8bb921db8de0175a0d7645762209da9e7e260f1cc139089cbbe9b6b3dc51
7
+ data.tar.gz: ea95d770b73c2adfdc60a0eb4bb92541730c35008fafc44e638956bbb00413ba104c2cc8f1c0534671766a559e17d6d11c718e5a9ac8d2bce47215119d7f2702
data/README.md CHANGED
@@ -25,12 +25,18 @@ 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)
30
+ - [Form Field](#form-field)
31
+ - [Grid](#grid)
32
+ - [Icon](#icon)
29
33
  - [Level](#level)
30
34
  - [NavigationBar](#navigationbar)
35
+ - [Notification](#notification)
31
36
  - [Pagination](#pagination)
32
37
  - [Table](#table)
33
38
  - [Tabs](#tabs)
39
+ - [Tag](#tag)
34
40
  - [Title and Subtitle](#title-and-subtitle)
35
41
  - [Development](#development)
36
42
  - [Contributing](#contributing)
@@ -108,6 +114,29 @@ Icons can be added to the links by passing an `icon` keyword argument with the i
108
114
  ```
109
115
 
110
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
+
111
140
  ### Dropdown
112
141
 
113
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.
@@ -137,6 +166,82 @@ end
137
166
  - `item(content = nil, &block)`: Adds a custom item (string or block).
138
167
  - `divider`: Adds a divider line.
139
168
 
169
+
170
+ ### Form Field
171
+
172
+ The [Form Field](https://bulma.io/documentation/form/general/) component provides a way to create form fields with labels, inputs, and help text, following Bulma's form styling conventions. It also supports adding icons to the input, as well as tagging the field as a column or grid cell.
173
+
174
+ ```ruby
175
+ BulmaPhlex::FormField(help: "We'll never share your email.") do |field|
176
+ field.label("Email Address")
177
+ field.control { input(name: "user[email_address]", type: "email") }
178
+ end
179
+ ```
180
+
181
+ The label can be passed in as a string or created with a block:
182
+
183
+ ```ruby
184
+ field.label do
185
+ span { "Email Address" }
186
+ span(class: "has-text-danger") { "*" }
187
+ end
188
+ ```
189
+
190
+ **Constructor Keyword Arguments:**
191
+
192
+ - `icon_left`: Icon class to display on the left side of the input (such as `fas fa-user`).
193
+ - `icon_right`: Icon class to display on the right side of the input.
194
+ - `help`: Help text to display below the field.
195
+ - `column`: When true, adds the `column` class to the container. Can also be a string specifying the column size (such as `two-thirds`) or a hash with sizes by breakpoint (such as `{ mobile: "full", desktop: "half" }`).
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`).
197
+
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
+
140
245
  ### Level
141
246
 
142
247
  The [Level](https://bulma.io/documentation/layout/level/) component provides a flexible horizontal layout system with left and right alignment.
@@ -190,18 +295,58 @@ end
190
295
  > [!NOTE]
191
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.
192
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
+
193
332
  ### Pagination
194
333
 
195
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.
196
335
 
197
336
  ```ruby
198
- # In a controller action:
199
- @products = Product.page(params[:page]).per(20)
200
-
201
- # In the view:
202
337
  BulmaPhlex::Pagination(@products, ->(page) { products_path(page: page) })
203
338
  ```
204
339
 
340
+ In order to support pagination, the argument passed into the constructor must repond with integers to the following:
341
+
342
+ - current_page
343
+ - total_pages
344
+ - per_page
345
+ - total_count
346
+ - previous_page (can be nil)
347
+ - next_page (can be nil)
348
+
349
+
205
350
  ### Table
206
351
 
207
352
  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.
@@ -272,16 +417,7 @@ If the table should be paginated, invoke method `paginate` with a block that wil
272
417
  end
273
418
  ```
274
419
 
275
- In order to support pagination, the `rows` argument passed into the constructor must repond with integers to the following:
276
-
277
- - current_page
278
- - total_pages
279
- - per_page
280
- - total_count
281
- - previous_page (can be nil)
282
- - next_page (can be nil)
283
-
284
- This generates the [Bulma pagination](https://bulma.io/documentation/components/pagination/) component, providing navigation controls for paginated content.
420
+ This generates the [Bulma pagination](https://bulma.io/documentation/components/pagination/) component, providing navigation controls for paginated content. The rows argument is passed into the Pagination component to determine the current page, total pages, and other pagination details.
285
421
 
286
422
 
287
423
  ### Tabs
@@ -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
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BulmaPhlex
4
+ # # Form Control
5
+ #
6
+ # The Bulma Form Control is used to wrap form elements like inputs, selects, and textareas. Additional classes can
7
+ # be added via the `classes` argument.
8
+ #
9
+ # ## References
10
+ # - [Bulma Form Control](https://bulma.io/documentation/form/general/#form-control)
11
+ class FormControl < Phlex::HTML
12
+ def initialize(**attributes)
13
+ @attributes = attributes.compact
14
+ end
15
+
16
+ def view_template(&)
17
+ div(**mix({ class: "control" }, @attributes), &)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,157 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BulmaPhlex
4
+ # # Form Field Component
5
+ #
6
+ # The Bulma Form Field is a `field` container that groups a label with yielded content
7
+ # (usually an input). It can optionally include a help text.
8
+ #
9
+ # The label can be provided either as a string argument to the `label` method or as a
10
+ # block. If a string is provided, it will be rendered inside a `<label>` tag with the
11
+ # `label` class. The label can also be omitted entirely if not needed.
12
+ #
13
+ # ## Icons
14
+ #
15
+ # The component supports optional left and right icons within the input control. Specify
16
+ # icons with the `icon_left` and `icon_right` keyword arguments.
17
+ #
18
+ # ```ruby
19
+ # FormField(icon_left: "fas fa-user", icon_right: "fas fa-check")
20
+ # ```
21
+ #
22
+ # ## Column Layout
23
+ #
24
+ # If the form field is to be used within a Bulma column layout, you can specify the `column`
25
+ # keyword. There are three ways to use this:
26
+ # - `true`: makes the field a column without specific sizing.
27
+ # - a size string (e.g., `"half"`): makes the field a column with that size for all breakpoints.
28
+ # - a hash mapping breakpoints to sizes (e.g., `{ mobile: "full", desktop: "half" }`): makes the
29
+ # field a column with sizes specific to breakpoints
30
+ #
31
+ # ## Example Usage
32
+ #
33
+ # Here is the label provided as a block:
34
+ #
35
+ # ```ruby
36
+ # FormField(help: "Enter the project name.") do |field|
37
+ # field.label { label "Project Name" }
38
+ # field.input { input id: "project_name", name: "project[name]", type: "text" }
39
+ # end
40
+ # ```
41
+ #
42
+ # Here is the label provided as a string:
43
+ #
44
+ # ```ruby
45
+ # FormField(help: "Enter the project name.") do |field|
46
+ # field.label "Project Name"
47
+ # field.input { input id: "project_name", name: "project[name]", type: "text" }
48
+ # end
49
+ # ```
50
+ #
51
+ # Here is no label provided:
52
+ #
53
+ # ```ruby
54
+ # FormField(help: "Enter the project name.") do |field|
55
+ # field.input { input id: "project_name", name: "project[name]", type: "text" }
56
+ # end
57
+ # ```
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
+ #
70
+ # ## References
71
+ #
72
+ # - [Bulma Form Field](https://bulma.io/documentation/form/general/#form-field)
73
+ # - [With Icons](https://bulma.io/documentation/form/general/#with-icons)
74
+ # - [Columns](https://bulma.io/documentation/columns/basics/)
75
+ # - [Grid Cells](https://bulma.io/documentation/grid/grid-cells/)
76
+ class FormField < Phlex::HTML
77
+ def initialize(help: nil, icon_left: nil, icon_right: nil, column: nil, grid: nil)
78
+ @help = help
79
+ @icon_left = icon_left
80
+ @icon_right = icon_right
81
+ @column = column
82
+ @grid = grid
83
+ end
84
+
85
+ # in order to use the method name `label`, we need to grab a reference to the method on the base class
86
+ # so it is stil available to us
87
+ alias html_label label
88
+
89
+ def label(label_string = nil, &block)
90
+ @label_string = label_string
91
+ @label_builder = block
92
+ end
93
+
94
+ def control(&block)
95
+ @control_builder = block
96
+ end
97
+
98
+ def view_template(&implicit_control)
99
+ @control_builder = implicit_control if @control_builder.nil? && implicit_control
100
+ vanish(&implicit_control)
101
+
102
+ div(class: field_classes) do
103
+ render_label
104
+ render FormControl.new(class: control_classes) do
105
+ raw @control_builder.call
106
+ Icon(@icon_left, size: :small, left: true) if @icon_left
107
+ Icon(@icon_right, size: :small, right: true) if @icon_right
108
+ end
109
+ p(class: "help") { @help } if @help
110
+ end
111
+ end
112
+
113
+ private
114
+
115
+ def field_classes
116
+ [:field].tap do |classes|
117
+ classes.append(column_classes) if @column
118
+ classes.append(grid_classes) if @grid
119
+ end
120
+ end
121
+
122
+ def column_classes
123
+ [:column].tap do |classes|
124
+ if @column.is_a?(String) || @column.is_a?(Integer)
125
+ classes << "is-#{@column}"
126
+ elsif @column.is_a?(Hash)
127
+ @column.each do |breakpoint, size|
128
+ classes << "is-#{size}-#{breakpoint}"
129
+ end
130
+ end
131
+ end
132
+ end
133
+
134
+ def grid_classes
135
+ if @grid.is_a?(String)
136
+ [:cell, "is-#{@grid}"]
137
+ else
138
+ [:cell]
139
+ end
140
+ end
141
+
142
+ def render_label
143
+ if @label_string
144
+ html_label(class: "label") { @label_string }
145
+ elsif @label_builder
146
+ raw @label_builder&.call
147
+ end
148
+ end
149
+
150
+ def control_classes
151
+ [].tap do |classes|
152
+ classes << "has-icons-left" if @icon_left
153
+ classes << "has-icons-right" if @icon_right
154
+ end
155
+ end
156
+ end
157
+ end
@@ -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
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BulmaPhlex
4
+ # # Icon
5
+ #
6
+ # This component implements the
7
+ # [Bulma icon element](https://bulma.io/documentation/elements/icon/).
8
+ #
9
+ # ## Options
10
+ #
11
+ # - `color`: Sets the [color of the icon](https://bulma.io/documentation/elements/icon/#colors)
12
+ # - `size`: Sets the [size of the icon](https://bulma.io/documentation/elements/icon/#sizes)
13
+ # - `text_right`: Text to display to the right of the icon
14
+ # - `text_left`: Text to display to the left of the icon
15
+ # - `left`: If true, adds the `is-left` class for use in form controls
16
+ # - `right`: If true, adds the `is-right` class for use in form controls
17
+ #
18
+ # ## Example
19
+ #
20
+ # ```ruby
21
+ # BulmaPhlex::Icon.new("fas fa-home")
22
+ # BulmaPhlex::Icon.new("fas fa-home", color: :primary, size: :large, text_right: "Home")
23
+ # ```
24
+ class Icon < BulmaPhlex::Base
25
+ def initialize(icon, # rubocop:disable Metrics/ParameterLists
26
+ text_right: nil,
27
+ text_left: nil,
28
+ size: nil,
29
+ color: nil,
30
+ left: false,
31
+ right: false,
32
+ **html_attributes)
33
+ @icon = icon
34
+ @text_right = text_right
35
+ @text_left = text_left
36
+ @size = size
37
+ @color = color
38
+ @left = left
39
+ @right = right
40
+ @html_attributes = html_attributes
41
+ end
42
+
43
+ def view_template
44
+ optional_text_wrapper do
45
+ span { @text_left } if @text_left
46
+ span(**mix({ class: icon_classes }, @html_attributes)) do
47
+ i(class: @icon)
48
+ end
49
+ span { @text_right } if @text_right
50
+ end
51
+ end
52
+
53
+ private
54
+
55
+ def optional_text_wrapper(&)
56
+ if @text_right || @text_left
57
+ span(class: "icon-text", &)
58
+ else
59
+ yield
60
+ end
61
+ end
62
+
63
+ def icon_classes
64
+ classes = ["icon"]
65
+ classes << "is-#{@size}" if @size
66
+ classes << "has-text-#{@color}" if @color
67
+ classes << "is-left" if @left
68
+ classes << "is-right" if @right
69
+ classes.join(" ")
70
+ end
71
+ end
72
+ end
@@ -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.8.2"
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.8.2
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-16 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,10 +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
71
+ - lib/bulma_phlex/form_control.rb
72
+ - lib/bulma_phlex/form_field.rb
73
+ - lib/bulma_phlex/grid.rb
74
+ - lib/bulma_phlex/icon.rb
70
75
  - lib/bulma_phlex/level.rb
71
76
  - lib/bulma_phlex/navigation_bar.rb
72
77
  - lib/bulma_phlex/navigation_bar_dropdown.rb
78
+ - lib/bulma_phlex/notification.rb
73
79
  - lib/bulma_phlex/pagination.rb
74
80
  - lib/bulma_phlex/tab_components/content.rb
75
81
  - lib/bulma_phlex/tab_components/tab.rb