bulma-phlex 0.11.0 → 0.12.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: 1ee83e739b84c897bbb801d7be66a49ce909b940399e35b19d2ce0ce310febc6
4
- data.tar.gz: c3c1c066c77c916a51eb9d604f58a1e88291436e67e0014a821b40f3a2d32e66
3
+ metadata.gz: '08c8b05063a914b32d039a238e6e37ee2be9c5cc2a5dab9b0d60010a6fde1c51'
4
+ data.tar.gz: b31a0424a69cbaec9abba85feb9931dc677b86f22ec8565bedd3a1655bd3b9a0
5
5
  SHA512:
6
- metadata.gz: 5afc7194917ea792bf09f7a83ca58d8271b765a2d2a7eabbb6479b631c5935ebca1d3988a19a8d8e79d6ffe5d4a84fc2a4e507d4e455abaac98da0514d542e4d
7
- data.tar.gz: dc8cee0e55182192282e766c734de97e252f2c5c34019a82061ff26c23dab7b8cddbc7c5888c2b32b728d4801a9441aad953cfeedcc7d613597006150a9cfdd9
6
+ metadata.gz: 6934c59c858952b9cdb400411490ac3e752b0da5f759026375065c559eb5092287529a61f95de588c7bf670d2c9b9a9087898e0221757968d0abaec0f7719217
7
+ data.tar.gz: e1def51be46b4c2efc9baa295d50878b0b59df55a8c16003745055eb3814c3e69c03b2753b1e3cfc643c1f01902788a2e09b6122b6e6f3981ccb75e50e2e6e99
data/README.md CHANGED
@@ -6,20 +6,6 @@
6
6
 
7
7
  This gem provides a set of ready-to-use [Phlex](https://github.com/phlex-ruby/phlex) components for common [Bulma](https://bulma.io/) components and elements, making it easy to build beautiful, responsive interfaces with a clean, Ruby-focused API.
8
8
 
9
- ## Upgrading to 0.8
10
-
11
- > [!IMPORTANT]
12
- > The 0.8.0 release includes breaking changes. The namespace for the components has been changed from `Components::Bulma` to `Components::BulmaPhlex`.
13
-
14
- This can generally be handled with a *Find-and-Replace*:
15
-
16
- **Find:** `Bulma::`
17
- **Replace:** `BulmaPhlex::`
18
-
19
- Note that this change was also applied to the expected Stimulus controllers. References such as the Navigation bar have been updated from `bulma--navigation-bar` to `bulma-phlex--navigation-bar`.
20
-
21
- Finally, the optional Rails extensions for the Card and Table components have been moved to the `bulma-phlex-rails` gem. If you are using this with Rails, you should use [the `bulma-phlex-rails` gem](https://github.com/RockSolt/bulma-phlex-rails). It provides both the component extensions as well as JavaScript for the Dropdown, Navigation Bar, and Tabs components.
22
-
23
9
  ## Table of Contents
24
10
 
25
11
  - [Installation](#installation)
@@ -28,10 +14,13 @@ Finally, the optional Rails extensions for the Card and Table components have be
28
14
  - [Card](#card)
29
15
  - [Columns](#columns)
30
16
  - [Dropdown](#dropdown)
17
+ - [File Upload](#file-upload)
31
18
  - [Form Field](#form-field)
32
19
  - [Grid](#grid)
20
+ - [Hero](#hero)
33
21
  - [Icon](#icon)
34
22
  - [Level](#level)
23
+ - [Modal](#modal)
35
24
  - [NavigationBar](#navigationbar)
36
25
  - [Notification](#notification)
37
26
  - [Pagination](#pagination)
@@ -69,8 +58,8 @@ gem install bulma-phlex
69
58
 
70
59
  This gem requires:
71
60
 
72
- - Ruby 3.4 or higher
73
- - Phlex 2.0.2 or higher
61
+ - Ruby 3.2.10 or higher
62
+ - Phlex 2.4.1 or higher
74
63
  - Bulma CSS (which you'll need to include in your application)
75
64
 
76
65
  ### Required Setup
@@ -96,6 +85,11 @@ The [Button](https://bulma.io/documentation/elements/button/) component provides
96
85
  BulmaPhlex::Button(color: "primary", size: "large", icon: "fas fa-thumbs-up") { "Like" }
97
86
  ```
98
87
 
88
+ The component can generate a button, anchor, or input element. By default it generates a `<button>`
89
+ element. If the `href` attribute is provided, it generates an `<a>` element. To generate an `<input>`
90
+ element, use the keyword argument `input` with a value of the type of input (button, reset, or submit).
91
+
92
+
99
93
  **Constructor Keyword Arguments:**
100
94
 
101
95
  - `color`: Sets the button color (e.g., "primary", "link", "info", "success", "warning", "danger").
@@ -106,6 +100,7 @@ BulmaPhlex::Button(color: "primary", size: "large", icon: "fas fa-thumbs-up") {
106
100
  - `outlined`: If `true`, makes the button outlined.
107
101
  - `inverted`: If `true`, makes the button inverted.
108
102
  - `rounded`: If `true`, makes the button rounded.
103
+ - `input`: If provided, generates an `input` element instead of a `button`. The value should be the type of input: "button", "reset", or "submit".
109
104
  - `icon`: If provided, adds an icon to the button. Should be a string representing the
110
105
  icon class (e.g., "fa-solid fa-check").
111
106
  - `icon_left`: If provided, adds an icon to the left of the button text. Should be a string
@@ -202,6 +197,30 @@ end
202
197
  - `divider`: Adds a divider line.
203
198
 
204
199
 
200
+ ### File Upload
201
+
202
+ The [File Upload](https://bulma.io/documentation/form/file/) component provides the structure for a file input. The component generates the container and additional elements, then yields for the file input.
203
+
204
+ If the name keyword argument is set to true, the component will also generate the file name display element and add the necessary data attributes for it to work with the default Stimulus controller. The controller is not provided by this library, but you can create your own Stimulus controller to handle the logic. Here is [an implementation of a Stimulus controller for Bulma file upload](https://github.com/RockSolt/bulma-phlex-rails/blob/main/app/javascript/controllers/bulma_phlex/file_input_display_controller.js). If you want to use a custom builder for the data attributes, you can pass that in as well.
205
+
206
+ ```ruby
207
+ BulmaPhlex::FileUpload.new(color: "primary") do |data_attributes|
208
+ input(type: "file", class: "file-input", data: data_attributes)
209
+ end
210
+ ```
211
+
212
+ **Constructor Keyword Arguments:**
213
+
214
+ - `color`: Sets the color of the file input
215
+ - `size`: Sets the size of the file input
216
+ - `name`: If `true`, includes the file name display element
217
+ - `align`: Aligns the file input: right or centered
218
+ - `fullwidth`: If `true`, makes the file input full width
219
+ - `boxed`: If `true`, makes the file input boxed
220
+ - `data_attributes_builder`: A custom builder for the data attributes used for Stimulus integration. If not provided, a default builder is used with the controller name "bulma-phlex--file-input-display".
221
+
222
+ Any additional HTML attributes passed to the constructor will be applied to the outer container div.
223
+
205
224
  ### Form Field
206
225
 
207
226
  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.
@@ -256,6 +275,25 @@ end
256
275
  - `row_gap`: (optional) Sets the row gap size between grid items, from 1-8 with 0.5 increments.
257
276
 
258
277
 
278
+
279
+ ### Hero
280
+
281
+ The [Hero](https://bulma.io/documentation/layout/hero/) component provides a large, full-width section for showcasing important content or calls to action, with support for different sizes and colors.
282
+
283
+ There are three ways to invoke the component:
284
+
285
+ - with a title and subtitle argument
286
+ - with a block for the hero body content
287
+ - invoke methods head, body, and footer on the yielded component and pass blocks to define each section
288
+
289
+ Additionally, both the size and color of the Hero can be specified through keyword arguments in the
290
+ constructor. Any additional HTML attributes given to the constructor will be added to the containing `div`.
291
+
292
+ ```ruby
293
+ BulmaPhlex::Hero(title: "Welcome to My Site", subtitle: "We're glad you're here!", color: "primary")
294
+ ```
295
+
296
+
259
297
  ### Icon
260
298
 
261
299
  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.
@@ -298,6 +336,27 @@ end
298
336
 
299
337
  Pass in any HTML attributes to the constructor to have them applied to the level container div.
300
338
 
339
+
340
+ ### Modal
341
+
342
+ The [Modal](https://bulma.io/documentation/components/modal/) component provides a way to create modal dialogs with customizable content and styling options.
343
+
344
+ ```ruby
345
+ BulmaPhlex::Modal.new do
346
+ div(class: "box") do
347
+ h1(class: "title") { "Modal Title" }
348
+ p { "This is the modal content." }
349
+ end
350
+ end
351
+ ```
352
+
353
+ **Constructor Keyword Arguments:**
354
+
355
+ - `data_attributes_builder`: A builder object that responds to `for_container`, `for_background`, and `for_close_button`, which should return a hash of data attributes for the container, background, and close button, respectively. By default, this uses the nested `StimulusDataAttributes` class with the controller name `bulma-phlex--modal`. You can create your own builder to integrate with a different JavaScript framework or custom logic.
356
+
357
+ Any additional HTML attributes passed to the constructor will be applied to the modal container div. The modal can be toggled by adding or removing the `is-active` class on the container. (Nothing in the component adds the `is-active` class, so you will need to handle that with your own JavaScript or Stimulus controller.)
358
+
359
+
301
360
  ### NavigationBar
302
361
 
303
362
  The [NavigationBar](https://bulma.io/documentation/components/navbar/) component provides a responsive navigation header with support for branding, navigation links, and dropdown menus.
@@ -567,6 +626,22 @@ BulmaPhlex::Title("Dr. Strangelove", size: 2, subtitle: "Or: How I Learned to St
567
626
  - `subtitle_size`: (optional) An integer from 1 to 6 indicating the size of the subtitle. If not provided and a title size is given, it defaults to `size + 2`.
568
627
  - `spaced`: (optional) A boolean indicating whether to add the `is-spaced` class to the title.
569
628
 
629
+
630
+ ## Upgrading to 0.8
631
+
632
+ > [!IMPORTANT]
633
+ > The 0.8.0 release includes breaking changes. The namespace for the components has been changed from `Components::Bulma` to `Components::BulmaPhlex`.
634
+
635
+ This can generally be handled with a *Find-and-Replace*:
636
+
637
+ **Find:** `Bulma::`
638
+ **Replace:** `BulmaPhlex::`
639
+
640
+ Note that this change was also applied to the expected Stimulus controllers. References such as the Navigation bar have been updated from `bulma--navigation-bar` to `bulma-phlex--navigation-bar`.
641
+
642
+ Finally, the optional Rails extensions for the Card and Table components have been moved to the `bulma-phlex-rails` gem. If you are using this with Rails, you should use [the `bulma-phlex-rails` gem](https://github.com/RockSolt/bulma-phlex-rails). It provides both the component extensions as well as JavaScript for the Dropdown, Navigation Bar, and Tabs components.
643
+
644
+
570
645
  ## Development
571
646
 
572
647
  After checking out the repo, run `bundle install` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -583,4 +658,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
583
658
 
584
659
  ## Credits
585
660
 
586
- This leverages the [Bulma CSS library](https://bulma.io/documentation/) and [Phlex](https://www.phlex.fun/) but is not endorsed or certified by either. We are fans of the both and this makes using them together easier.
661
+ This leverages the [Bulma CSS library](https://bulma.io/documentation/) and [Phlex](https://www.phlex.fun/) but is not endorsed or certified by either. We are fans of both and this makes using them together easier.
@@ -6,6 +6,10 @@ module BulmaPhlex
6
6
  # This component implements the [Bulma button](https://bulma.io/documentation/elements/button/)
7
7
  # interface. It provides a simple way to create buttons with the appropriate Bulma classes.
8
8
  #
9
+ # The component can generate a button, anchor, or input element. By default it generates a `<button>`
10
+ # element. If the `href` attribute is provided, it generates an `<a>` element. To generate an `<input>`
11
+ # element, use the keyword argument `input` with a value of the type of input (button, reset, or submit).
12
+ #
9
13
  # ## Options
10
14
  #
11
15
  # - `color`: Sets the button color (e.g., "primary", "link", "info", "success", "warning", "danger").
@@ -23,7 +27,28 @@ module BulmaPhlex
23
27
  # - `icon_right`: If provided, adds an icon to the right of the button text. Should be a string
24
28
  # representing the icon class (e.g., "fa-solid fa-check").
25
29
  class Button < Base
26
- def initialize(color: nil, # rubocop:disable Metrics/ParameterLists
30
+ # Returns an array of CSS classes for the button based on the provided options.
31
+ def self.classes_for(color: nil, # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
32
+ mode: nil,
33
+ size: nil,
34
+ responsive: false,
35
+ fullwidth: false,
36
+ outlined: false,
37
+ inverted: false,
38
+ rounded: false)
39
+ classes = ["button"]
40
+ classes << "is-#{color}" if color
41
+ classes << "is-#{mode}" if mode
42
+ classes << "is-#{size}" if size
43
+ classes << "is-responsive" if responsive
44
+ classes << "is-fullwidth" if fullwidth
45
+ classes << "is-outlined" if outlined
46
+ classes << "is-inverted" if inverted
47
+ classes << "is-rounded" if rounded
48
+ classes
49
+ end
50
+
51
+ def initialize(color: nil,
27
52
  mode: nil,
28
53
  size: nil,
29
54
  responsive: false,
@@ -34,41 +59,28 @@ module BulmaPhlex
34
59
  icon: nil,
35
60
  icon_left: nil,
36
61
  icon_right: nil,
62
+ input: nil,
37
63
  **html_attributes)
38
- @color = color
39
- @mode = mode
40
- @size = size
41
- @responsive = responsive
42
- @fullwidth = fullwidth
43
- @outlined = outlined
44
- @inverted = inverted
45
- @rounded = rounded
64
+ @classes = self.class.classes_for(color:, mode:, size:, responsive:, fullwidth:, outlined:, inverted:, rounded:)
65
+ @input = input
46
66
  @icon_left = icon || icon_left
47
67
  @icon_right = icon_right
48
68
  @html_attributes = html_attributes
49
69
  end
50
70
 
51
71
  def view_template(&)
52
- button(**mix({ class: button_classes }, @html_attributes)) do
53
- Icon(@icon_left) if @icon_left
54
- yield if block_given?
55
- Icon(@icon_right) if @icon_right
56
- end
57
- end
58
-
59
- private
72
+ options = mix({ class: @classes }, @html_attributes)
60
73
 
61
- def button_classes # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
62
- classes = ["button"]
63
- classes << "is-#{@color}" if @color
64
- classes << "is-#{@mode}" if @mode
65
- classes << "is-#{@size}" if @size
66
- classes << "is-responsive" if @responsive
67
- classes << "is-fullwidth" if @fullwidth
68
- classes << "is-outlined" if @outlined
69
- classes << "is-inverted" if @inverted
70
- classes << "is-rounded" if @rounded
71
- classes
74
+ if @input
75
+ input(**options, type: @input)
76
+ else
77
+ element_type = @html_attributes.key?(:href) ? :a : :button
78
+ tag(element_type, **options) do
79
+ Icon(@icon_left) if @icon_left
80
+ yield if block_given?
81
+ Icon(@icon_right) if @icon_right
82
+ end
83
+ end
72
84
  end
73
85
  end
74
86
  end
@@ -14,7 +14,7 @@ module BulmaPhlex
14
14
  # - `centered`: (Boolean, optional) If true, centers the columns.
15
15
  # - `vcentered`: (Boolean, optional) If true, vertically centers the columns.
16
16
  class Columns < BulmaPhlex::Base
17
- def initialize(minimum_breakpoint: nil, # rubocop:disable Metrics/ParameterLists
17
+ def initialize(minimum_breakpoint: nil,
18
18
  multiline: false,
19
19
  gap: nil,
20
20
  centered: false,
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BulmaPhlex
4
+ # # File Upload
5
+ #
6
+ # The file upload component allows you to create a styled file input using Bulma's classes.
7
+ #
8
+ # ## Options
9
+ #
10
+ # - `color`: Sets the color of the file input
11
+ # - `size`: Sets the size of the file input
12
+ # - `name`: If `true`, includes the file name display element
13
+ # - `align`: Aligns the file input: right or centered
14
+ # - `fullwidth`: If `true`, makes the file input full width
15
+ # - `boxed`: If `true`, makes the file input boxed
16
+ # - `data_attributes_builder`: A custom builder for the data attributes used for Stimulus integration. If
17
+ # not provided, a default builder is used with the controller name "bulma-phlex--file-input-display".
18
+ class FileUpload < Base
19
+ DataAttributesBuilder = Data.define(:for_file, :for_file_input, :for_file_list)
20
+
21
+ def self.stimulus_data_attributes(controller)
22
+ DataAttributesBuilder.new(
23
+ for_file: { controller: controller },
24
+ for_file_input: { "#{controller}-target": "fileInput", action: "#{controller}#show" },
25
+ for_file_list: { "#{controller}-target": "fileList" }
26
+ )
27
+ end
28
+
29
+ def initialize(color: nil,
30
+ size: nil,
31
+ name: false,
32
+ align: nil,
33
+ fullwidth: false,
34
+ boxed: false,
35
+ data_attributes_builder: nil)
36
+ @color = color
37
+ @size = size
38
+ @name = name
39
+ @align = align
40
+ @fullwidth = fullwidth
41
+ @boxed = boxed
42
+
43
+ return unless @name
44
+
45
+ @data_attributes_builder = data_attributes_builder ||
46
+ self.class.stimulus_data_attributes("bulma-phlex--file-input-display")
47
+ end
48
+
49
+ def view_template
50
+ div(class: file_classes, data: @data_attributes_builder&.for_file) do
51
+ label(class: "file-label") do
52
+ yield(@data_attributes_builder&.for_file_input)
53
+ span(class: "file-cta") do
54
+ span(class: "file-icon") do
55
+ i(class: "fas fa-upload")
56
+ end
57
+ span(class: "file-label") { plain " Choose a file… " }
58
+ end
59
+ file_name_span if @name
60
+ end
61
+ end
62
+ end
63
+
64
+ private
65
+
66
+ def file_classes
67
+ classes = ["file"]
68
+ classes << "is-#{@color}" if @color
69
+ classes << "is-#{@size}" if @size
70
+ classes << "has-name" if @name
71
+ classes << "is-#{@align}" if @align
72
+ classes << "is-fullwidth" if @fullwidth
73
+ classes << "is-boxed" if @boxed
74
+ classes
75
+ end
76
+
77
+ def file_name_span
78
+ span(class: "file-name is-flex", data: @data_attributes_builder&.for_file_list) do
79
+ plain "No file uploaded"
80
+ end
81
+ end
82
+ end
83
+ end
@@ -3,18 +3,40 @@
3
3
  module BulmaPhlex
4
4
  # # Form Control
5
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.
6
+ # The Bulma Form Control is used to wrap form elements like inputs, selects, and buttons. It can optionally
7
+ # include icons on the left and/or right side of the control.
8
+ #
9
+ # ## Options
10
+ #
11
+ # - `icon_left`: If provided, adds an icon to the left of the control. Should be a string representing
12
+ # the icon class (e.g., "fas fa-check").
13
+ # - `icon_right`: If provided, adds an icon to the right of the control. Should be a string representing
14
+ # the icon class (e.g., "fas fa-check").
8
15
  #
9
16
  # ## References
10
17
  # - [Bulma Form Control](https://bulma.io/documentation/form/general/#form-control)
11
18
  class FormControl < Phlex::HTML
12
- def initialize(**attributes)
13
- @attributes = attributes.compact
19
+ def initialize(icon_left: nil, icon_right: nil, **html_attributes)
20
+ @icon_left = icon_left
21
+ @icon_right = icon_right
22
+ @html_attributes = html_attributes
14
23
  end
15
24
 
16
25
  def view_template(&)
17
- div(**mix({ class: "control" }, @attributes), &)
26
+ div(**mix({ class: classes }, @html_attributes)) do
27
+ raw yield
28
+ Icon(@icon_left, size: :small, left: true) if @icon_left
29
+ Icon(@icon_right, size: :small, right: true) if @icon_right
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def classes
36
+ ["control"].tap do |classes|
37
+ classes << "has-icons-left" if @icon_left
38
+ classes << "has-icons-right" if @icon_right
39
+ end
18
40
  end
19
41
  end
20
42
  end
@@ -101,10 +101,8 @@ module BulmaPhlex
101
101
 
102
102
  div(class: field_classes) do
103
103
  render_label
104
- render FormControl.new(class: control_classes) do
104
+ render FormControl.new(icon_left: @icon_left, icon_right: @icon_right) do
105
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
106
  end
109
107
  p(class: "help") { @help } if @help
110
108
  end
@@ -146,12 +144,5 @@ module BulmaPhlex
146
144
  raw @label_builder&.call
147
145
  end
148
146
  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
147
  end
157
148
  end
@@ -15,7 +15,7 @@ module BulmaPhlex
15
15
  # - `column_gap`: (optional) Sets the column gap size between grid items from 1-8 with 0.5 increments.
16
16
  # - `row_gap`: (optional) Sets the row gap size between grid items from 1-8 with 0.5 increments.
17
17
  class Grid < BulmaPhlex::Base
18
- def initialize(fixed_columns: nil, # rubocop:disable Metrics/ParameterLists
18
+ def initialize(fixed_columns: nil,
19
19
  auto_count: false,
20
20
  minimum_column_width: nil,
21
21
  gap: nil,
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BulmaPhlex
4
+ # ## Hero
5
+ #
6
+ # This component implements the [Bulma Hero](https://bulma.io/documentation/layout/hero/) layout. There are
7
+ # three ways to invoke the component:
8
+ #
9
+ # - with a title and subtitle argument
10
+ # - with a block for the hero body content
11
+ # - invoke methods head, body, and footer on the yielded component and pass blocks to define each section
12
+ #
13
+ # Additionally, both the size and color of the Hero can be specified through keyword arguments in the
14
+ # constructor. Any additional HTML attributes given to the constructor will be added to the containing `div`.
15
+ class Hero < BulmaPhlex::Base
16
+ def initialize(title: nil, subtitle: nil, color: nil, size: nil, **html_attributes)
17
+ @title = title
18
+ @subtitle = subtitle
19
+ @color = color
20
+ @size = size
21
+ @html_attributes = html_attributes
22
+ end
23
+
24
+ def head(&block)
25
+ @head = block
26
+ end
27
+
28
+ def body(&block)
29
+ @body = block
30
+ end
31
+
32
+ def foot(&block)
33
+ @foot = block
34
+ end
35
+
36
+ def view_template(&)
37
+ output = capture(&)
38
+
39
+ section(**mix({ class: hero_classes }, @html_attributes)) do
40
+ if @body.present?
41
+ building_blocks(&)
42
+ else
43
+ div(class: "hero-body") do
44
+ if output.present?
45
+ output
46
+ else
47
+ title_and_subtitle
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ private
55
+
56
+ def hero_classes
57
+ classes = ["hero"]
58
+ classes << "is-#{@color}" if @color
59
+ classes << "is-#{@size}" if @size
60
+ classes
61
+ end
62
+
63
+ def building_blocks(&)
64
+ div(class: "hero-head") { @head.call } if @head
65
+ div(class: "hero-body") { @body.call } if @body
66
+ div(class: "hero-foot") { @foot.call } if @foot
67
+ end
68
+
69
+ def title_and_subtitle
70
+ p(class: "title") { @title } if @title
71
+ p(class: "subtitle") { @subtitle } if @subtitle
72
+ end
73
+ end
74
+ end
@@ -22,7 +22,7 @@ module BulmaPhlex
22
22
  # BulmaPhlex::Icon.new("fas fa-home", color: :primary, size: :large, text_right: "Home")
23
23
  # ```
24
24
  class Icon < BulmaPhlex::Base
25
- def initialize(icon, # rubocop:disable Metrics/ParameterLists
25
+ def initialize(icon,
26
26
  text_right: nil,
27
27
  text_left: nil,
28
28
  size: nil,
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BulmaPhlex
4
+ # ## Modal
5
+ #
6
+ # The Bulma Modal component is used to create modal dialogs. It consists of a background,
7
+ # content area, and a close button. The content of the modal can be defined using the block
8
+ # passed to the `call` method.
9
+ #
10
+ # The constructor accepts an optional `data_attributes_builder` argument, which allows you to
11
+ # provide data attributes for the container, background, and close button. By default, it uses a
12
+ # `StimulusDataAttributes` instance with the controller name "bulma-phlex--modal". You can provide your
13
+ # own builder if you want to use a different controller or customize the data attributes further.
14
+ #
15
+ # Any additional HTML attributes passed to the constructor will be applied to the outer `<div>`
16
+ # element of the modal.
17
+ class Modal < BulmaPhlex::Base
18
+ StimulusDataAttributes = Data.define(:stimulus_controller) do
19
+ def for_container = { controller: stimulus_controller }
20
+ def for_background = { action: "click->bulma-phlex--modal#close" }
21
+ def for_close_button = { action: "bulma-phlex--modal#close" }
22
+ end
23
+
24
+ def initialize(data_attributes_builder: StimulusDataAttributes.new("bulma-phlex--modal"), **html_attributes)
25
+ @data_attributes_builder = data_attributes_builder
26
+ @html_attributes = html_attributes
27
+ end
28
+
29
+ def view_template(&)
30
+ container = { class: "modal", data: @data_attributes_builder.for_container }
31
+ div(**mix(container, @html_attributes)) do
32
+ div(class: "modal-background", data: @data_attributes_builder.for_background)
33
+ div(class: "modal-content", &)
34
+ button(class: "modal-close is-large", aria: { label: "close" }, data: @data_attributes_builder.for_close_button)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -49,7 +49,7 @@ module BulmaPhlex
49
49
  #
50
50
  # Any additional HTML attributes passed to the component will be applied to the `<nav>` element.
51
51
  class NavigationBar < BulmaPhlex::Base
52
- def initialize(container: false, # rubocop:disable Metrics/ParameterLists
52
+ def initialize(container: false,
53
53
  color: nil,
54
54
  transparent: false,
55
55
  spaced: false,
@@ -43,7 +43,7 @@ module BulmaPhlex
43
43
  # will be rendered in the table footer. The block should accept a page number and return the
44
44
  # corresponding URL for that page.
45
45
  class Table < BulmaPhlex::Base
46
- def initialize(rows, # rubocop:disable Metrics/ParameterLists
46
+ def initialize(rows,
47
47
  bordered: false,
48
48
  striped: false,
49
49
  narrow: false,
@@ -69,7 +69,7 @@ module BulmaPhlex
69
69
  end
70
70
  end
71
71
 
72
- def initialize(align: nil, # rubocop:disable Metrics/ParameterLists
72
+ def initialize(align: nil,
73
73
  size: nil,
74
74
  boxed: false,
75
75
  toggle: false,
@@ -127,7 +127,7 @@ module BulmaPhlex
127
127
 
128
128
  div(class: tabs_classes) do
129
129
  ul(**attributes) do
130
- @tabs.each { render it }
130
+ @tabs.each { |tab| render tab }
131
131
  end
132
132
  end
133
133
  end
@@ -148,7 +148,7 @@ module BulmaPhlex
148
148
  attributes[:id] = "#{@html_attributes[:id]}-content" if @html_attributes[:id]
149
149
 
150
150
  div(**attributes) do
151
- @contents.each { render it }
151
+ @contents.each { |content| render content }
152
152
  end
153
153
  end
154
154
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BulmaPhlex
4
- VERSION = "0.11.0"
4
+ VERSION = "0.12.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.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Kummer
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-02-13 00:00:00.000000000 Z
10
+ date: 2026-02-26 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: phlex
@@ -69,11 +69,14 @@ files:
69
69
  - lib/bulma_phlex/card.rb
70
70
  - lib/bulma_phlex/columns.rb
71
71
  - lib/bulma_phlex/dropdown.rb
72
+ - lib/bulma_phlex/file_upload.rb
72
73
  - lib/bulma_phlex/form_control.rb
73
74
  - lib/bulma_phlex/form_field.rb
74
75
  - lib/bulma_phlex/grid.rb
76
+ - lib/bulma_phlex/hero.rb
75
77
  - lib/bulma_phlex/icon.rb
76
78
  - lib/bulma_phlex/level.rb
79
+ - lib/bulma_phlex/modal.rb
77
80
  - lib/bulma_phlex/navigation_bar.rb
78
81
  - lib/bulma_phlex/navigation_bar_dropdown.rb
79
82
  - lib/bulma_phlex/notification.rb
@@ -99,7 +102,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
102
  requirements:
100
103
  - - ">="
101
104
  - !ruby/object:Gem::Version
102
- version: 3.4.0
105
+ version: 3.2.10
103
106
  required_rubygems_version: !ruby/object:Gem::Requirement
104
107
  requirements:
105
108
  - - ">="