# frozen_string_literal: true module Arclight # ViewComponent for rendering a single document download link class DocumentDownloadComponent < ViewComponent::Base def initialize(downloads:, **kwargs) super @downloads = downloads @link_options = kwargs end attr_reader :downloads delegate :files, to: :downloads def render? files.present? end # i18n-tasks-use t('arclight.views.show.download.multiple.pdf') # i18n-tasks-use t('arclight.views.show.download.multiple.ead') def dropdown_label(file) t(file.type, scope: 'arclight.views.show.download.multiple') end # i18n-tasks-use t('arclight.views.show.download.single.pdf') # i18n-tasks-use t('arclight.views.show.download.single.ead') def label(file) t(file.type, scope: 'arclight.views.show.download.single') end # From https://icons.getbootstrap.com/icons/download/ def download_icon icon = <<~HTML HTML icon.html_safe # rubocop:disable Rails/OutputSafety end # This is an extension point where one could configure a different icon per file type def icon_for(type) public_send("#{type}_icon") end # From https://icons.getbootstrap.com/icons/file-earmark-pdf/ def pdf_icon icon = <<~HTML HTML icon.html_safe # rubocop:disable Rails/OutputSafety end # From https://icons.getbootstrap.com/icons/file-earmark-code/ def ead_icon icon = <<~HTML HTML icon.html_safe # rubocop:disable Rails/OutputSafety end end end