# frozen_string_literal: true module Bulmacomp # Make an html structure for a bulma card # # @example empty card # render Bulmacomp::BreadcrumbComponent.new() # #
# @example cart with title and yeld content # render Bulmacomp::BreadcrumbComponent.new(title: 'test') do #

test content

# end # #
#
#
test
#
#
#

test content

#
#
class CardComponent < ViewComponent::Base def initialize(title: nil, image: nil, footer: nil, **opts) super @title = title @image = image @footer = footer @opts = { class: 'card' }.merge(opts) end # @return [String] html_safe card def call tag.div safe_join([card_title, card_image, card_content, card_footer]), **@opts end # @return [String] title section if :title is set # @example # Bulmacomp::BreadcrumbComponent.new(title: 'test').title # #
test
def card_title tag.div(tag.div(@title, class: 'card-header-title'), class: 'card-header') if @title end # return [String] image section if :image is set # @example # Bulmacomp::BreadcrumbComponent.new(title: 'test', image: 'test.jpg').image # #
test
def card_image tag.div(tag.figure(image_tag(@image, alt: @title), class: 'image'), class: 'card-image') if @image end # return [String] content section if yield is present # @example # Bulmacomp::BreadcrumbComponent.new().title do # test content # end # #

test content

def card_content tag.div(tag.div(content, class: 'content'), class: 'card-content') if content end # return [String] footer section if a footer is present # @example # Bulmacomp::BreadcrumbComponent.new(footer: 'test').footer # # def card_footer tag.div @footer, class: 'card-footer' if @footer end end end