refactor(dsfr): CardComponent with footer_buttons slot

This commit is contained in:
Colin Darie 2022-09-07 13:14:56 +02:00
parent b769def337
commit 5f760585ad
2 changed files with 8 additions and 10 deletions

View file

@ -1,15 +1,12 @@
class Dsfr::CardComponent < ApplicationComponent
def footer_button(*args)
@footer_buttons.push args
end
renders_many :footer_buttons
private
def initialize(title: nil, desc: nil, footer_buttons: [])
def initialize(title: nil, desc: nil)
@title = title
@desc = desc
@footer_buttons = footer_buttons
end
attr_reader :title, :desc, :footer_buttons
attr_reader :title, :desc
end

View file

@ -2,15 +2,16 @@
.fr-card__body
.fr-card__content
- if title
%h1.fr-card__title
%h2.fr-card__title
= title
- if desc
%p.fr-card__desc
= desc
- if footer_buttons.any?
- if footer_buttons?
.fr-card__footer
.fr-btns-group.fr-btns-group--inline-reverse.fr-btns-group--inline-lg
%ul
%li
= render Dsfr::ButtonComponent.with_collection(footer_buttons)
- footer_buttons.each do |button|
%li
= button