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 +4 -4
- data/README.md +10 -1
- data/lib/bulma_phlex/version.rb +1 -1
- data/lib/components/bulma/card.rb +43 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63d0fb33d15debb198d1469b5f467f8ab155836600a7eece3167f1e6301007b7
|
4
|
+
data.tar.gz: c6fc149bcd52613d37c220802a213d4bc836884d5332ba4a2f6402e61b9c55fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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" }
|
data/lib/bulma_phlex/version.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
34
|
-
|
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
|
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
|