Class: IronAdmin::Dashboards::StatsGridComponent::StatComponent Private
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- IronAdmin::Dashboards::StatsGridComponent::StatComponent
- Defined in:
- app/components/iron_admin/dashboards/stats_grid_component.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Individual statistic card component.
Instance Attribute Summary collapse
-
#change ⇒ String?
readonly
private
Change amount text.
-
#change_type ⇒ Symbol
readonly
private
Change type (:positive, :negative, :neutral).
-
#icon ⇒ String?
readonly
private
Optional icon name.
-
#label ⇒ String
readonly
private
Stat label.
-
#value ⇒ Numeric, String
readonly
private
Stat value.
Instance Method Summary collapse
-
#change_classes ⇒ String
private
CSS classes for change indicator color.
-
#change_icon ⇒ String?
private
Heroicon name for change direction.
-
#initialize(label:, value:, change: nil, change_type: :neutral, icon: nil) ⇒ StatComponent
constructor
private
A new instance of StatComponent.
-
#theme ⇒ IronAdmin::Configuration::Theme
private
Theme configuration.
Constructor Details
#initialize(label:, value:, change: nil, change_type: :neutral, icon: nil) ⇒ StatComponent
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 a new instance of StatComponent.
51 52 53 54 55 56 57 |
# File 'app/components/iron_admin/dashboards/stats_grid_component.rb', line 51 def initialize(label:, value:, change: nil, change_type: :neutral, icon: nil) @label = label @value = value @change = change @change_type = change_type.to_sym @icon = icon end |
Instance Attribute Details
#change ⇒ String? (readonly)
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 Change amount text.
38 39 40 |
# File 'app/components/iron_admin/dashboards/stats_grid_component.rb', line 38 def change @change end |
#change_type ⇒ Symbol (readonly)
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 Change type (:positive, :negative, :neutral).
41 42 43 |
# File 'app/components/iron_admin/dashboards/stats_grid_component.rb', line 41 def change_type @change_type end |
#icon ⇒ String? (readonly)
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 Optional icon name.
44 45 46 |
# File 'app/components/iron_admin/dashboards/stats_grid_component.rb', line 44 def icon @icon end |
#label ⇒ String (readonly)
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 Stat label.
32 33 34 |
# File 'app/components/iron_admin/dashboards/stats_grid_component.rb', line 32 def label @label end |
#value ⇒ Numeric, String (readonly)
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 Stat value.
35 36 37 |
# File 'app/components/iron_admin/dashboards/stats_grid_component.rb', line 35 def value @value end |
Instance Method Details
#change_classes ⇒ String
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 change indicator color.
67 68 69 70 71 72 73 |
# File 'app/components/iron_admin/dashboards/stats_grid_component.rb', line 67 def change_classes case change_type when :positive then "text-green-600" when :negative then "text-red-600" else theme.muted_text end end |
#change_icon ⇒ String?
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 Heroicon name for change direction.
77 78 79 80 81 82 |
# File 'app/components/iron_admin/dashboards/stats_grid_component.rb', line 77 def change_icon case change_type when :positive then "arrow-trending-up" when :negative then "arrow-trending-down" end end |
#theme ⇒ IronAdmin::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.
61 62 63 |
# File 'app/components/iron_admin/dashboards/stats_grid_component.rb', line 61 def theme IronAdmin.configuration.theme end |