Sha256: 36656a9721f32e4ac8e4bd72c649a253a9354b3278f72c1c4dd9e7451206e145
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 KB
Contents
# frozen_string_literal: true module Card def default_plus_passed_classes(defaults, classes) "#{defaults} #{classes}".strip end module_function :default_plus_passed_classes class CardComponent < ViewComponent::Base renders_one :header, 'HeaderComponent' renders_one :footer, 'FooterComponent' def initialize(**options) @classes = options[:classes] @styles = options[:styles] end class HeaderComponent < ViewComponent::Base def initialize(**options) @tag = options[:tag] || :h2 @classes = options[:classes] @styles = options[:styles] @default_classses = 'card-header' end def call content_tag(@tag, content, class: Card.default_plus_passed_classes( @default_classses, @classes ), style: @styles ) end end class FooterComponent < ViewComponent::Base def initialize(**options) @tag = options[:tag] || :div @classes = options[:classes] @styles = options[:styles] @default_classses = 'card-footer text-muted' end def call content_tag(@tag, content, class: Card.default_plus_passed_classes( @default_classses, @classes ), style: @styles ) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bsvc-0.1.0 | app/components/card/card_component.rb |