Class: IronAdmin::Dashboards::ActivityFeedComponent::ItemComponent Private

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/iron_admin/dashboards/activity_feed_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 activity feed item component.

Constant Summary collapse

COLORS =

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

Color classes for icon backgrounds.

{
  green: "bg-green-100 text-green-600",
  red: "bg-red-100 text-red-600",
  blue: "bg-blue-100 text-blue-600",
  yellow: "bg-yellow-100 text-yellow-600",
  gray: "bg-gray-100 text-gray-600",
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description:, timestamp:, icon: "circle-stack", icon_color: :blue, href: nil) ⇒ ItemComponent

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 ItemComponent.

Parameters:

  • description (String)

    Item description

  • timestamp (Time, String)

    Item timestamp

  • icon (String) (defaults to: "circle-stack")

    Heroicon name (default: "circle-stack")

  • icon_color (Symbol) (defaults to: :blue)

    Icon color (default: :blue)

  • href (String, nil) (defaults to: nil)

    Optional link URL



62
63
64
65
66
67
68
# File 'app/components/iron_admin/dashboards/activity_feed_component.rb', line 62

def initialize(description:, timestamp:, icon: "circle-stack", icon_color: :blue, href: nil)
  @description = description
  @timestamp = timestamp
  @icon = icon
  @icon_color = icon_color.to_sym
  @href = href
end

Instance Attribute Details

#descriptionString (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 Item description.

Returns:

  • (String)

    Item description



39
40
41
# File 'app/components/iron_admin/dashboards/activity_feed_component.rb', line 39

def description
  @description
end

#hrefString? (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 link URL.

Returns:

  • (String, nil)

    Optional link URL



45
46
47
# File 'app/components/iron_admin/dashboards/activity_feed_component.rb', line 45

def href
  @href
end

#iconString (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 Icon name.

Returns:

  • (String)

    Icon name



33
34
35
# File 'app/components/iron_admin/dashboards/activity_feed_component.rb', line 33

def icon
  @icon
end

#icon_colorSymbol (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 Icon color.

Returns:

  • (Symbol)

    Icon color



36
37
38
# File 'app/components/iron_admin/dashboards/activity_feed_component.rb', line 36

def icon_color
  @icon_color
end

#timestampTime, 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 Item timestamp.

Returns:

  • (Time, String)

    Item timestamp



42
43
44
# File 'app/components/iron_admin/dashboards/activity_feed_component.rb', line 42

def timestamp
  @timestamp
end

Instance Method Details

#formatted_timestampString

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 Formatted timestamp string.

Returns:

  • (String)

    Formatted timestamp string



84
85
86
87
88
89
90
# File 'app/components/iron_admin/dashboards/activity_feed_component.rb', line 84

def formatted_timestamp
  if timestamp.respond_to?(:strftime)
    timestamp.strftime("%b %d, %H:%M")
  else
    timestamp
  end
end

#icon_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 icon background color.

Returns:

  • (String)

    CSS classes for icon background color



78
79
80
# File 'app/components/iron_admin/dashboards/activity_feed_component.rb', line 78

def icon_classes
  COLORS[@icon_color] || COLORS[:gray]
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:



72
73
74
# File 'app/components/iron_admin/dashboards/activity_feed_component.rb', line 72

def theme
  IronAdmin.configuration.theme
end