Class: UI::DrawerCloseComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
DrawerCloseBehavior
Defined in:
app/view_components/ui/drawer_close_component.rb

Overview

Drawer close component (ViewComponent) Close button for drawer

Examples:

<%= render UI::CloseComponent.new { "Cancel" } %>

With custom variant

<%= render UI::CloseComponent.new(variant: :ghost) { "Close" } %>

Instance Method Summary collapse

Methods included from DrawerCloseBehavior

#drawer_close_data_attributes

Constructor Details

#initialize(variant: :outline, size: :default, classes: "", attributes: {}) ⇒ DrawerCloseComponent

Returns a new instance of DrawerCloseComponent.

Parameters:

  • variant (Symbol) (defaults to: :outline)

    button variant (:default, :outline, :ghost, etc.)

  • size (Symbol) (defaults to: :default)

    button size (:default, :sm, :lg, etc.)

  • classes (String) (defaults to: "")

    additional CSS classes

  • attributes (Hash) (defaults to: {})

    additional HTML attributes



18
19
20
21
22
23
# File 'app/view_components/ui/drawer_close_component.rb', line 18

def initialize(variant: :outline, size: :default, classes: "", attributes: {})
  @variant = variant
  @size = size
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#callObject



25
26
27
28
29
30
31
32
33
34
# File 'app/view_components/ui/drawer_close_component.rb', line 25

def call
  render UI::ButtonComponent.new(
    variant: @variant,
    size: @size,
    classes: @classes,
    **drawer_close_data_attributes.merge(@attributes)
  ) do
    content
  end
end