bulma-phlex 0.5.1 → 0.6.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: 63d0fb33d15debb198d1469b5f467f8ab155836600a7eece3167f1e6301007b7
4
+ data.tar.gz: c6fc149bcd52613d37c220802a213d4bc836884d5332ba4a2f6402e61b9c55fe
5
5
  SHA512:
6
- metadata.gz: b7dfa409bfa0380dfa15ca8a2d2e0a58b904fb3e75415a497c15e0276f7422a4e5425044421b99545a3decfedaa7dc8f76b342a2addcb56020165aca309671d6
7
- data.tar.gz: 7096d053b2c05c2da6ec7306bc4b4fe469d2e8ce4ab5fbf924b756c0b4962831e496e6d2c03ea3ea8ce6f5b46f5ce67cc950a8575fbda17a53537435eb208ceb
6
+ metadata.gz: 9f2df9cb18c084d02717dac31fc8eb275035ab474eb7184c61a4d6ff488dbceb27caa3ecf8bad4d00395900f5de20c8bbe014c9052a3ac16468e6be8e0f393e5
7
+ data.tar.gz: a3d55de4aefceb64805920b80ac851f9adba80140006d40286fe1a6cbc42efb43dc20b2a849c3053c9e910646a819423b5282af44540af8505b2ffb53706de72
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:
@@ -243,7 +252,7 @@ The icon column is intended to show a boolean flag: a yes / no or an on / off. W
243
252
 
244
253
  - name: content for the `th` element
245
254
  - `icon_class` (keyword): the icon to show (defaults to the Font Awesome check mark: "fas fa-check")
246
-
255
+
247
256
  ```ruby
248
257
  table.conditional_icon("Completed?", &:complete)
249
258
  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.6.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
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.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Kummer