Prepare SDG tag list component to render list with or without links

Now the tag list can render tags with or without links, so we need
to adapt the styles slightly.

We want to use the same text color for tags without links.

The hover style is only needed when using tags with links.
This commit is contained in:
Senén Rodero Rodríguez
2021-01-27 18:34:43 +01:00
committed by taitus
parent cc2ce38d13
commit bb1315def1
4 changed files with 69 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
<div class="sdg-tag-list">
<%= render SDG::Goals::TagListComponent.new(record, limit: limit) %>
<%= render SDG::Targets::TagListComponent.new(record, limit: limit) %>
<%= goals_list %>
<%= targets_list %>
</div>

View File

@@ -1,8 +1,27 @@
class SDG::TagListComponent < ApplicationComponent
attr_reader :record, :limit
attr_reader :record, :limit, :linkable
def initialize(record, limit: nil)
def initialize(record, limit: nil, linkable: true)
@record = record
@limit = limit
@linkable = linkable
end
private
def goals_list
if linkable
render SDG::Goals::TagListComponent.new(record, limit: limit)
else
render SDG::Goals::PlainTagListComponent.new(record, limit: limit)
end
end
def targets_list
if linkable
render SDG::Targets::TagListComponent.new(record, limit: limit)
else
render SDG::Targets::PlainTagListComponent.new(record, limit: limit)
end
end
end