Class: IronAdmin::Ui::CardComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/iron_admin/ui/card_component.rb

Overview

Renders a card container with optional header and footer.

Examples:

Basic card

render IronAdmin::Ui::CardComponent.new do
  "Card content here"
end

Card with header and footer

render IronAdmin::Ui::CardComponent.new do |card|
  card.with_header { "Title" }
  card.with_footer { "Footer" }
  "Content"
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(padding: true, shadow: true) ⇒ CardComponent

Returns a new instance of CardComponent.

Parameters:

  • padding (Boolean) (defaults to: true)

    Add padding to content (default: true)

  • shadow (Boolean) (defaults to: true)

    Show card shadow (default: true)



31
32
33
34
# File 'app/components/iron_admin/ui/card_component.rb', line 31

def initialize(padding: true, shadow: true)
  @padding = padding
  @shadow = shadow
end

Instance Attribute Details

#paddingBoolean (readonly)

Returns Whether to add padding to content.

Returns:

  • (Boolean)

    Whether to add padding to content



24
25
26
# File 'app/components/iron_admin/ui/card_component.rb', line 24

def padding
  @padding
end

#shadowBoolean (readonly)

Returns Whether to show shadow.

Returns:

  • (Boolean)

    Whether to show shadow



27
28
29
# File 'app/components/iron_admin/ui/card_component.rb', line 27

def shadow
  @shadow
end

Instance Method Details

#card_classesString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns CSS classes for card container.

Returns:

  • (String)

    CSS classes for card container



44
45
46
47
48
# File 'app/components/iron_admin/ui/card_component.rb', line 44

def card_classes
  classes = ["overflow-hidden", theme.border_radius, theme.card_bg, "border", theme.card_border]
  classes << theme.card_shadow if shadow
  classes.join(" ")
end

#content_classesString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns CSS classes for card content area.

Returns:

  • (String)

    CSS classes for card content area



52
53
54
# File 'app/components/iron_admin/ui/card_component.rb', line 52

def content_classes
  padding ? "p-6" : ""
end

#themeIronAdmin::Configuration::Theme

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Theme configuration.

Returns:



38
39
40
# File 'app/components/iron_admin/ui/card_component.rb', line 38

def theme
  IronAdmin.configuration.theme
end