app/components/bs5/close_button_component.rb in bs5-0.0.24 vs app/components/bs5/close_button_component.rb in bs5-0.0.25

- old
+ new

@@ -1,17 +1,24 @@ # frozen_string_literal: true module Bs5 class CloseButtonComponent < ViewComponent::Base - attr_reader :data + def initialize(options = {}) + @options = options.symbolize_keys - def initialize(disabled: false, white: false, data: nil) - @disabled = disabled - @white = white - @data = data + @disabled = options.delete(:disabled) + @white = options.delete(:white) + @dismiss = options.delete(:dismiss) + @data = options.fetch(:data, {}) end + def data + @data['bs-dismiss'] = @dismiss if @dismiss + + @data + end + private def white? @white end @@ -19,10 +26,11 @@ def disabled? @disabled end def component_class - class_names = ['btn-close'] + class_names = Array(@options[:class]) + class_names << 'btn-close' class_names << %w[btn-close-white] if white? class_names.join(' ') end end end