This happened when previewing banners in the "new banner form", which might cause accessibility issues when people access the list of links on the page. We were getting the following accessibility error: ``` link-name: Links must have discernible text (serious) https://dequeuniversity.com/rules/axe/4.9/link-name?application=axeAPI The following node violate this rule: Selector: a[href$="new"] HTML: <a href="/admin/banners/new"><h2></h2><h3></h3></a> Fix all of the following: - Element is in tab order and does not have accessible text Fix any of the following: - Element does not have text that is visible to screen readers - aria-label attribute does not exist or is empty - aria-labelledby attribute does not exist, references elements that do not exist or references elements that - Element has no title attribute ```
29 lines
717 B
Ruby
29 lines
717 B
Ruby
class Shared::BannerComponent < ApplicationComponent
|
|
attr_reader :banner_or_section
|
|
|
|
def initialize(banner_or_section)
|
|
@banner_or_section = banner_or_section
|
|
end
|
|
|
|
def banner
|
|
@banner ||= if banner_or_section.respond_to?(:sections)
|
|
banner_or_section
|
|
else
|
|
Banner.in_section(banner_or_section).with_active.sample
|
|
end
|
|
end
|
|
|
|
def render?
|
|
banner && (banner.title.present? || banner.description.present?)
|
|
end
|
|
|
|
private
|
|
|
|
def link
|
|
link_to banner.target_url do
|
|
tag.h2(banner.title, style: "color:#{banner.font_color}") +
|
|
tag.h3(banner.description, style: "color:#{banner.font_color}")
|
|
end
|
|
end
|
|
end
|