bulma-phlex 0.5.1 → 0.7.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: 4b94a61e80c3da2fb0b776323e40e381322aab22eb9e6fa9493d495d21df8f30
4
- data.tar.gz: 8650e8b839631a6e642eb0e04ca33178f67006cdb848144d33f1e32359242653
3
+ metadata.gz: 5caa2176372f45d0002153e7a4272e79bd3ae01eb530e58c16a29864a3e90c09
4
+ data.tar.gz: 4ed606f6cb03296a7c0c52eccbe2e31bb2c7eb1c0e2fbbaef1510f8ad8f7d48f
5
5
  SHA512:
6
- metadata.gz: b7dfa409bfa0380dfa15ca8a2d2e0a58b904fb3e75415a497c15e0276f7422a4e5425044421b99545a3decfedaa7dc8f76b342a2addcb56020165aca309671d6
7
- data.tar.gz: 7096d053b2c05c2da6ec7306bc4b4fe469d2e8ce4ab5fbf924b756c0b4962831e496e6d2c03ea3ea8ce6f5b46f5ce67cc950a8575fbda17a53537435eb208ceb
6
+ metadata.gz: 2d3173c063bb8fc27fa653b34a2f4a57d6b653c313361d1bd1661d13feb760a31e5f8a102407a4024c5e48671031ae5d1b11b6d3414d38b17a3d43d38b2c3918
7
+ data.tar.gz: 9ec45c90c5060eb1d812d939ae03687c1027ed49c3959bf3f8855216c4e331c7ebb221f4a46903022a0a0d753cebab4a9ff0465528b5dfa424ce37e9b6b7340e
data/README.md CHANGED
@@ -75,9 +75,18 @@ Bulma::Card() do |card|
75
75
  card.content do
76
76
  "This is some card content"
77
77
  end
78
+ card.footer_link("View", "/view", target: "_blank")
79
+ card.footer_link("Edit", "/edit", class: "has-text-primary")
78
80
  end
79
81
  ```
80
82
 
83
+ **Arguments for `footer_link`:**
84
+
85
+ - text: the link text
86
+ - href: passed to the anchor's `href` attribute
87
+ - Any additional HTML attributes can be passed as keyword arguments.
88
+
89
+
81
90
  #### Rails Feature: Turbo Frame Content
82
91
 
83
92
  When the `turbo-rails` and `phlex-rails` gems are installed, the Card component also provides method `turbo_frame_content`, which allows the content to be deferred to a turbo frame. The method accepts the same parameters as [the Turbo Rails helper method `turbo_frame_tag`](https://github.com/hotwired/turbo-rails?tab=readme-ov-file#decompose-with-turbo-frames), with the addition of the following two attributes:
@@ -146,7 +155,7 @@ end
146
155
  The [NavigationBar](https://bulma.io/documentation/components/navbar/) component provides a responsive navigation header with support for branding, navigation links, and dropdown menus.
147
156
 
148
157
  ```ruby
149
- Bulma::NavigationBar() do |navbar|
158
+ Bulma::NavigationBar(classes: "is-primary") do |navbar|
150
159
  navbar.brand_item "My App", "/"
151
160
 
152
161
  navbar.left do |menu|
@@ -167,6 +176,14 @@ Bulma::NavigationBar() do |navbar|
167
176
  end
168
177
  ```
169
178
 
179
+ **Constructor Keyword Arguments:**
180
+
181
+ - `classes`: Additional classes to be added to the `nav` element, such as "is-primary" or "has-shadow".
182
+ - `container`: When true, wraps the content in a Bulma container. To set a constraint, such as "is-max-desktop", pass that string instead of true. (defaults to false)
183
+
184
+ > [!NOTE]
185
+ > Adding a container will limit the width of the Navigation Bar content according to Bulma's container rules. The background color of the navbar will still span the full width of the viewport.
186
+
170
187
  ### Pagination
171
188
 
172
189
  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.
@@ -243,7 +260,7 @@ The icon column is intended to show a boolean flag: a yes / no or an on / off. W
243
260
 
244
261
  - name: content for the `th` element
245
262
  - `icon_class` (keyword): the icon to show (defaults to the Font Awesome check mark: "fas fa-check")
246
-
263
+
247
264
  ```ruby
248
265
  table.conditional_icon("Completed?", &:complete)
249
266
  table.conditional_icon("Approved?", icon_class: "fas fa-thumbs-up") { |row| row.status == "Approved" }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BulmaPhlex
4
- VERSION = "0.5.1"
4
+ VERSION = "0.7.0"
5
5
  end
@@ -16,6 +16,8 @@ module Components
16
16
  # card.content do
17
17
  # "This is some card content"
18
18
  # end
19
+ # card.footer_link("View", "/view", target: "_blank")
20
+ # card.footer_link("Edit", "/edit", class: "has-text-primary")
19
21
  # end
20
22
  # ```
21
23
  #
@@ -26,18 +28,54 @@ module Components
26
28
  # as its content. This allows for dynamic loading of card content.
27
29
  class Card < Components::Bulma::Base
28
30
  def view_template(&)
29
- div(class: "card", &)
31
+ vanish(&)
32
+
33
+ div(class: "card") do
34
+ card_header
35
+ card_content
36
+ card_footer
37
+ end
30
38
  end
31
39
 
32
40
  def head(title, classes: nil)
33
- header(class: "card-header #{classes}") do
34
- p(class: "card-header-title") { plain title }
41
+ @header_title = title
42
+ @header_classes = classes
43
+ end
44
+
45
+ def content(&block)
46
+ @card_content = block
47
+ end
48
+
49
+ def footer_link(text, href, **html_attributes)
50
+ (@footer_items ||= []) << [text, href, html_attributes]
51
+ end
52
+
53
+ private
54
+
55
+ def card_header
56
+ return if @header_title.nil?
57
+
58
+ header(class: "card-header #{@header_classes}") do
59
+ p(class: "card-header-title") { plain @header_title }
35
60
  end
36
61
  end
37
62
 
38
- def content(&)
63
+ def card_content
64
+ return if @card_content.nil?
65
+
39
66
  div(class: "card-content") do
40
- div(class: "content", &)
67
+ div(class: "content") { @card_content.call }
68
+ end
69
+ end
70
+
71
+ def card_footer
72
+ return if @footer_items.nil? || @footer_items.empty?
73
+
74
+ footer(class: "card-footer") do
75
+ @footer_items.each do |text, href, html_attributes|
76
+ html_attributes[:class] = [html_attributes[:class], "card-footer-item"].compact.join(" ")
77
+ a(href:, **html_attributes) { text }
78
+ end
41
79
  end
42
80
  end
43
81
  end
@@ -36,7 +36,9 @@ module Components
36
36
  # ```
37
37
  #
38
38
  class NavigationBar < Components::Bulma::Base
39
- def initialize
39
+ def initialize(container: false, classes: "")
40
+ @container = container
41
+ @classes = classes
40
42
  @brand = []
41
43
  @left = []
42
44
  @right = []
@@ -45,11 +47,11 @@ module Components
45
47
  def view_template(&)
46
48
  vanish(&)
47
49
 
48
- nav(class: "navbar is-light block",
50
+ nav(class: "navbar #{@classes}".rstrip,
49
51
  role: "navigation",
50
52
  aria_label: "main navigation",
51
53
  data: { controller: "bulma--navigation-bar" }) do
52
- div(class: "container") do
54
+ optional_container do
53
55
  div(class: "navbar-brand") do
54
56
  @brand.each(&:call)
55
57
 
@@ -90,6 +92,17 @@ module Components
90
92
  def right(&block)
91
93
  @right << block
92
94
  end
95
+
96
+ private
97
+
98
+ def optional_container(&)
99
+ if @container
100
+ constraint = @container if @container.is_a?(String) || @container.is_a?(Symbol)
101
+ div(class: "container #{constraint}".rstrip, &)
102
+ else
103
+ yield
104
+ end
105
+ end
93
106
  end
94
107
  end
95
108
  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.5.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Kummer