Class: Avo::DiscreetInformationComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- Avo::DiscreetInformationComponent
show all
- Defined in:
- app/components/avo/discreet_information_component.rb
Constant Summary
Concerns::FindAssociationField::ASSOCIATIONS
Instance Method Summary
collapse
#component_name, #has_with_trial
#find_association_field
Instance Method Details
#data(item) ⇒ Object
42
|
# File 'app/components/avo/discreet_information_component.rb', line 42
def data(item) = item.data || {}
|
#element_attributes(item) ⇒ Object
18
19
20
21
22
23
24
|
# File 'app/components/avo/discreet_information_component.rb', line 18
def element_attributes(item)
if item.url.present?
{href: item.url, target: item.url_target}
else
{}
end
end
|
#element_classes(item) ⇒ Object
26
27
28
29
30
31
32
|
# File 'app/components/avo/discreet_information_component.rb', line 26
def element_classes(item)
if item.as == :badge
%w[flex gap-1 whitespace-nowrap rounded-md uppercase px-2 py-1 leading-none items-center text-xs block text-center truncate bg-gray-400 text-white hover:bg-gray-500]
else
%w[flex gap-1 text-xs font-normal text-gray-600 hover:text-gray-900]
end
end
|
#element_tag(item) ⇒ Object
10
11
12
13
14
15
16
|
# File 'app/components/avo/discreet_information_component.rb', line 10
def element_tag(item)
if item.url.present?
:a
else
:div
end
end
|
#icon_classes(item) ⇒ Object
34
35
36
37
38
39
40
|
# File 'app/components/avo/discreet_information_component.rb', line 34
def icon_classes(item)
if item.as == :badge
%w[text-2xl h-3]
else
%w[text-2xl h-4]
end
end
|
#items ⇒ Object
6
7
8
|
# File 'app/components/avo/discreet_information_component.rb', line 6
def items
@payload.items.compact
end
|