bulma-phlex 0.15.0 → 0.16.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: 8a1d3209d836363da07529fa00c9374618623280e70f3167c409e320b77dd4c4
4
- data.tar.gz: e078ae57978d967610194b989078d484ad2297d4cdd71b0ae2d65b07d80dc105
3
+ metadata.gz: 358df6739ab960f7d8b3799001c40b0d80a6e1c1d599b31b115b67bdcae46645
4
+ data.tar.gz: 54a368dec6bf6dfa7c21f32779e63651bea141070367880f7b1b938da86c92f3
5
5
  SHA512:
6
- metadata.gz: c7c0d1e8bbfb69e58e78af757f14b4dde6ab532f085e7ea970cb1addd511f2c5c33ba964df7b80dcfdac878f4475108858ceace18f3e5b52356d3b9b3d7df521
7
- data.tar.gz: c41d7a84d0a5e5c2c03aafd7ff74764af2e94221c051aa67766815d46805cd153829deb87173b7d73285fcfaf9752433412070effb7755fced7d3e45df388912
6
+ metadata.gz: 81cea339f39b95a17bd43e18f294944327744c81601fb03d1d7e7975e397973ebfa488350540eeb008e587c74ae3805ce8ff3ec15aa193277bd68bae03cee201
7
+ data.tar.gz: 021f7fc3b32d02a16c1c08a695e915b8beca73219b86da9766c58077afa5b13e205d337fd2ccace80378905076ccb821d2c9c244313ace1c1c32c38752258045
data/README.md CHANGED
@@ -10,6 +10,7 @@ This gem provides a set of ready-to-use [Phlex](https://github.com/phlex-ruby/ph
10
10
 
11
11
  - [Installation](#installation)
12
12
  - [Usage](#usage)
13
+ - [Breadcrumb](#breadcrumb)
13
14
  - [Button](#button)
14
15
  - [Card](#card)
15
16
  - [Columns](#columns)
@@ -78,6 +79,21 @@ require "bulma-phlex"
78
79
 
79
80
  Use the Phlex components in your Rails views or any Ruby application that supports Phlex components.
80
81
 
82
+ ### Breadcrumb
83
+
84
+ Renders a [Bulma breadcrumb](https://bulma.io/documentation/components/breadcrumb/) navigation element. Each breadcrumb item is added via the `item` method on the yielded component.
85
+
86
+ ```ruby
87
+ render BulmaPhlex::Breadcrumb.new do |bc|
88
+ bc.item("Bulma", href: "/")
89
+ bc.item("Components", href: "/components")
90
+ bc.item("Breadcrumb")
91
+ end
92
+ ```
93
+
94
+ It supports options for **alignment** (centered, right-aligned), **separator** style (arrow, bullet, dot, or succeeds), and **size** (small, medium, large). Items also support an optional `icon` argument.
95
+
96
+
81
97
  ### Button
82
98
 
83
99
  Renders a [Bulma button](https://bulma.io/documentation/elements/button/) element with support for color, size, style modifiers, and left/right icons.
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BulmaPhlex
4
+ # Renders a [Bulma breadcrumb](https://bulma.io/documentation/components/breadcrumb/) component.
5
+ # It supports options for **alignment** (centered, right-aligned), **separator** style (arrow,
6
+ # bullet, dot, or succeeds (greater than)), and **size** (small, medium, large).
7
+ class Breadcrumb < Base
8
+ # **Parameters**
9
+ #
10
+ # - `align` — Breadcrumb alignment: `"centered"` or `"right"`
11
+ # - `separator` — Breadcrumb separator style: `"arrow"`, `"bullet"`, `"dot"`, or `"succeeds"`
12
+ # - `size` — Alternate size: `"small"`, `"medium"`, or `"large"`
13
+ # - `**html_attributes` — Additional HTML attributes for the `<nav>` element
14
+ def self.new(align: nil, separator: nil, size: nil, **html_attributes)
15
+ super
16
+ end
17
+
18
+ def initialize(align: nil, separator: nil, size: nil, **html_attributes)
19
+ @align = align
20
+ @separator = separator
21
+ @size = size
22
+ @html_attributes = html_attributes
23
+
24
+ @items = []
25
+ end
26
+
27
+ def view_template(&)
28
+ vanish(&)
29
+ return if @items.empty?
30
+
31
+ nav(**mix(@html_attributes, class: nav_classes, aria: { label: "breadcrumbs" })) do
32
+ ul do
33
+ @items[0...-1].each do |item|
34
+ render_item(item)
35
+ end
36
+
37
+ render_last_item
38
+ end
39
+ end
40
+ end
41
+
42
+ # Adds a breadcrumb item to the component. The last item added will be rendered as the active item.
43
+ #
44
+ # **Parameters**
45
+ # - `label` (positional) — The text label for the breadcrumb item
46
+ # - `href` — URL for the breadcrumb item; not required on last item / current page
47
+ # - `icon` — Optional icon class for the breadcrumb item (e.g. `"fa-solid fa-home"`)
48
+ def item(label, href: nil, icon: nil)
49
+ @items << { label:, icon:, html_attributes: { href: href } }
50
+ end
51
+
52
+ private
53
+
54
+ def nav_classes
55
+ classes = ["breadcrumb"]
56
+ classes << "is-#{@align}" if @align
57
+ classes << "has-#{@separator}-separator" if @separator
58
+ classes << "is-#{@size}" if @size
59
+ classes
60
+ end
61
+
62
+ def render_item(item, list_item_attributes: {})
63
+ li(**list_item_attributes) do
64
+ a(**item[:html_attributes]) do
65
+ if item[:icon]
66
+ render BulmaPhlex::Icon.new(item[:icon], size: "small", icon_attributes: { aria: { hidden: "true" } })
67
+ span { item[:label] }
68
+ else
69
+ plain item[:label]
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+ def render_last_item
76
+ item = @items.last
77
+
78
+ item[:html_attributes] = mix(item[:html_attributes], aria: { current: "page" })
79
+ render_item(item, list_item_attributes: { class: "is-active" })
80
+ end
81
+ end
82
+ end
@@ -5,7 +5,12 @@ module BulmaPhlex
5
5
  # form control positioning.
6
6
  #
7
7
  # Supports **color** and **size** options, optional **text** to the left or right of the icon,
8
- # and **positioning** helpers (`left`/`right`) for use inside form controls.
8
+ # and **positioning** helpers (`left`/`right`) for use inside form controls. When text is provide,
9
+ # the icon and text are wrapped in a container with the `icon-text` class for proper spacing, and
10
+ # the icon includes `aria-hidden="true"` for accessibility.
11
+ #
12
+ # Additional HTML attributes can be passed to the icon's `<span>` element via `**html_attributes`,
13
+ # and to the inner `<i>` by nested them under `icon_attributes`.
9
14
  #
10
15
  # ## Example
11
16
  #
@@ -21,7 +26,8 @@ module BulmaPhlex
21
26
  # - `text_left` — Text to display to the left of the icon
22
27
  # - `left` — If `true`, adds the `is-left` class for use in form controls
23
28
  # - `right` — If `true`, adds the `is-right` class for use in form controls
24
- # - `**html_attributes` — Additional HTML attributes for the icon span element
29
+ # - `**html_attributes` — Additional HTML attributes for the icon span element. Nest attributes under
30
+ # `icon_attributes` to apply them to the inner `<i>` element instead.
25
31
  def self.new(icon,
26
32
  text_right: nil,
27
33
  text_left: nil,
@@ -48,14 +54,15 @@ module BulmaPhlex
48
54
  @color = color
49
55
  @left = left
50
56
  @right = right
51
- @html_attributes = html_attributes
57
+ @html_attributes = html_attributes.clone
58
+ @icon_attributes = @html_attributes.delete(:icon_attributes) || {}
52
59
  end
53
60
 
54
61
  def view_template
55
62
  optional_text_wrapper do
56
63
  span { @text_left } if @text_left
57
64
  span(**mix({ class: icon_classes }, @html_attributes)) do
58
- i(class: @icon)
65
+ i(class: @icon, **@icon_attributes)
59
66
  end
60
67
  span { @text_right } if @text_right
61
68
  end
@@ -65,12 +72,17 @@ module BulmaPhlex
65
72
 
66
73
  def optional_text_wrapper(&)
67
74
  if @text_right || @text_left
75
+ add_aria_hidden_to_icon_attributes
68
76
  span(class: "icon-text", &)
69
77
  else
70
78
  yield
71
79
  end
72
80
  end
73
81
 
82
+ def add_aria_hidden_to_icon_attributes
83
+ @icon_attributes = mix({ aria: { hidden: "true" } }, @icon_attributes)
84
+ end
85
+
74
86
  def icon_classes
75
87
  classes = ["icon"]
76
88
  classes << "is-#{@size}" if @size
@@ -26,8 +26,11 @@ module BulmaPhlex
26
26
  div(class: "navbar-dropdown is-right", &)
27
27
  end
28
28
 
29
- def header(label)
30
- div(class: "navbar-item header has-text-weight-medium") { label }
29
+ # Adds a non-clickable header item to the dropdown menu. Optionally add a divider before the header with
30
+ # the `divder: true` parameter.
31
+ def header(label, divider: false)
32
+ self.divider if divider
33
+ div(class: "navbar-item has-text-weight-semibold") { label }
31
34
  end
32
35
 
33
36
  def item(label, path)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BulmaPhlex
4
- VERSION = "0.15.0"
4
+ VERSION = "0.16.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.15.0
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Kummer
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-04-16 00:00:00.000000000 Z
10
+ date: 2026-05-27 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: phlex
@@ -65,6 +65,7 @@ files:
65
65
  - lib/bulma-phlex.rb
66
66
  - lib/bulma_phlex.rb
67
67
  - lib/bulma_phlex/base.rb
68
+ - lib/bulma_phlex/breadcrumb.rb
68
69
  - lib/bulma_phlex/button.rb
69
70
  - lib/bulma_phlex/card.rb
70
71
  - lib/bulma_phlex/columns.rb