Class: IronAdmin::Resources::BreadcrumbComponent::ItemComponent Private

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/iron_admin/resources/breadcrumb_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 breadcrumb item component.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label:, href: nil, current: false) ⇒ 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:

  • label (String)

    Item label

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

    Item link URL

  • current (Boolean) (defaults to: false)

    Whether this is current page



30
31
32
33
34
# File 'app/components/iron_admin/resources/breadcrumb_component.rb', line 30

def initialize(label:, href: nil, current: false)
  @label = label
  @href = href
  @current = current
end

Instance Attribute Details

#currentBoolean (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 Whether this is the current page.

Returns:

  • (Boolean)

    Whether this is the current page



25
26
27
# File 'app/components/iron_admin/resources/breadcrumb_component.rb', line 25

def current
  @current
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 Item link URL.

Returns:

  • (String, nil)

    Item link URL



22
23
24
# File 'app/components/iron_admin/resources/breadcrumb_component.rb', line 22

def href
  @href
end

#labelString (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 label text.

Returns:

  • (String)

    Item label text



19
20
21
# File 'app/components/iron_admin/resources/breadcrumb_component.rb', line 19

def label
  @label
end

Instance Method Details

#callString

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.

Renders the breadcrumb item.

Returns:

  • (String)

    HTML content



54
55
56
57
58
59
60
# File 'app/components/iron_admin/resources/breadcrumb_component.rb', line 54

def call
  if href && !current
    link_to(label, href, class: item_classes)
  else
    tag.span(label, class: item_classes, aria: current ? { current: "page" } : {})
  end
end

#item_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 breadcrumb item.

Returns:

  • (String)

    CSS classes for breadcrumb item



44
45
46
47
48
49
50
# File 'app/components/iron_admin/resources/breadcrumb_component.rb', line 44

def item_classes
  if current
    "text-sm font-medium #{theme.body_text}"
  else
    "text-sm #{theme.link}"
  end
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/resources/breadcrumb_component.rb', line 38

def theme
  IronAdmin.configuration.theme
end