Class: IronAdmin::Dashboards::StatsGridComponent

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

Overview

Renders a grid of statistics cards.

Defined Under Namespace

Classes: StatComponent

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(columns: 4) ⇒ StatsGridComponent

Returns a new instance of StatsGridComponent.

Parameters:

  • columns (Integer) (defaults to: 4)

    Grid columns (default: 4)



13
14
15
# File 'app/components/iron_admin/dashboards/stats_grid_component.rb', line 13

def initialize(columns: 4)
  @columns = columns
end

Instance Attribute Details

#columnsInteger (readonly)

Returns Number of columns.

Returns:

  • (Integer)

    Number of columns



10
11
12
# File 'app/components/iron_admin/dashboards/stats_grid_component.rb', line 10

def columns
  @columns
end

Instance Method Details

#grid_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 Tailwind grid column classes based on columns count.

Returns:

  • (String)

    Tailwind grid column classes based on columns count



19
20
21
22
23
24
25
26
# File 'app/components/iron_admin/dashboards/stats_grid_component.rb', line 19

def grid_classes
  case columns
  when 2 then "grid-cols-1 sm:grid-cols-2"
  when 3 then "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3"
  when 4 then "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4"
  else "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4"
  end
end