File tree Expand file tree Collapse file tree 3 files changed +21
-6
lines changed
demo/test/components/previews Expand file tree Collapse file tree 3 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ def styles
3535 # it will be rendered at the top of the card in a h5 tag using the
3636 # Card::Title component. Alternatively, you can use the `title` slot to
3737 # provide the entire title element yourself.
38- def initialize ( class : [ ] , options : { } , title : nil )
38+ def initialize ( class : [ ] , options : { } , title : { } )
3939 @class = Array ( binding . local_variable_get ( :class ) ) || [ ]
4040 @options = options || { }
4141 @title = title
@@ -51,14 +51,29 @@ def card_options
5151
5252 # Returns the HTML to use for the title element if any
5353 def default_title
54- return nil unless title?
54+ component = Flowbite ::Card ::Title . new
55+
56+ if default_title_content
57+ component . with_content ( default_title_content )
58+ else
59+ component
60+ end
5561
56- component = Flowbite ::Card ::Title . new . with_content ( default_title_content )
5762 render ( component )
5863 end
5964
6065 def default_title_content
61- @title
66+ return nil unless @title
67+
68+ @title [ :content ]
69+ end
70+
71+ def default_title_options
72+ title_options = @title . dup
73+ title_options . delete ( :content )
74+
75+ {
76+ } . merge ( title_options )
6277 end
6378
6479 def title?
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ def default
99 end
1010
1111 def with_title_argument
12- render ( Flowbite ::Card . new ( title : "Card Title" ) ) do
12+ render ( Flowbite ::Card . new ( title : { content : "Card Title" } ) ) do
1313 "This card includes a title with the default styling."
1414 end
1515 end
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ def test_overrides_the_default_classes
2929 end
3030
3131 def test_with_title_argument
32- render_inline ( Flowbite ::Card . new ( title : "Card Title" ) ) { "Card Content" }
32+ render_inline ( Flowbite ::Card . new ( title : { content : "Card Title" } ) ) { "Card Content" }
3333
3434 assert_selector ( "h5.mb-2.text-2xl.font-bold.tracking-tight.text-gray-900.dark\\ :text-white" , text : "Card Title" )
3535 end
You can’t perform that action at this time.
0 commit comments