File tree Expand file tree Collapse file tree 3 files changed +16
-8
lines changed
Expand file tree Collapse file tree 3 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ def card_options
5151
5252 # Returns the HTML to use for the title element if any
5353 def default_title
54- component = Flowbite ::Card ::Title . new
54+ component = Flowbite ::Card ::Title . new ( ** default_title_options )
5555
5656 if default_title_content
5757 component . with_content ( default_title_content )
@@ -70,10 +70,7 @@ def default_title_content
7070
7171 def default_title_options
7272 title_options = @title . dup
73- title_options . delete ( :content )
74-
75- {
76- } . merge ( title_options )
73+ title_options [ :options ]
7774 end
7875
7976 def title?
Original file line number Diff line number Diff line change @@ -22,10 +22,15 @@ def styles
2222 end
2323
2424 def call
25- title_options = { }
26- title_options [ :class ] = self . class . classes
25+ title_options = {
26+ class : self . class . classes
27+ } . merge ( @options )
2728
28- content_tag ( :h5 , content , title_options )
29+ content_tag ( :h5 , content , **title_options )
30+ end
31+
32+ def initialize ( **options )
33+ @options = options || { }
2934 end
3035 end
3136 end
Original file line number Diff line number Diff line change @@ -34,6 +34,12 @@ def test_with_title_argument
3434 assert_selector ( "h5.mb-2.text-2xl.font-bold.tracking-tight.text-gray-900.dark\\ :text-white" , text : "Card Title" )
3535 end
3636
37+ def test_passes_title_options_to_the_title
38+ render_inline ( Flowbite ::Card . new ( title : { content : "Card Title" , options : { class : "custom-title-class" } } ) ) { "Card Content" }
39+
40+ assert_selector ( "h5.custom-title-class" , text : "Card Title" )
41+ end
42+
3743 def test_with_title_slot_when_using_with_title
3844 render_inline ( Flowbite ::Card . new ) do |component |
3945 component . with_title { "<h1>This is the full title</h1>" . html_safe }
You can’t perform that action at this time.
0 commit comments