demarches-normaliennes/app/components/instructeurs/dossiers_navigation_component.rb
mfo af5af67750
ui(navigation_icons): use span icons which are bolder [asked by design].
ensure next/prev links are always on oneline, make back button bigger
[same as design], align back/next/prev to top when there is more than
oneline for h1 [either procedure name, either dossier name]
2024-12-10 10:22:08 +01:00

45 lines
1.4 KiB
Ruby

# frozen_string_literal: true
class Instructeurs::DossiersNavigationComponent < ApplicationComponent
attr_reader :dossier, :statut
def initialize(dossier:, procedure_presentation:, statut:)
@dossier = dossier
@cache = Cache::ProcedureDossierPagination.new(procedure_presentation: procedure_presentation, statut:)
@statut = statut
end
def back_url_options
options = { statut: }
options = options.merge(page: @cache.incoming_page) if @cache.incoming_page
options
end
def link_next
if has_next?
html_tag = :a
options = { class: "fr-link no-wrap fr-ml-3w", href: next_instructeur_dossier_path(dossier:, statut:) }
else
html_tag = :span
options = { class: "fr-link no-wrap fr-ml-3w fr-text-mention--grey" }
end
tag.send(html_tag, t('.next').html_safe + tag.span(class: 'fr-icon-arrow-right-line fr-ml-1w'), **options)
end
def link_previous
if has_previous?
html_tag = :a
options = { class: "fr-link no-wrap", href: previous_instructeur_dossier_path(dossier:, statut:) }
else
html_tag = :span
options = { class: "fr-link no-wrap fr-text-mention--grey" }
end
tag.send(html_tag, tag.span(class: 'fr-icon-arrow-left-line fr-mr-1w') + t('.previous'), **options)
end
def has_next? = @has_next ||= @cache.next_dossier_id(from_id: dossier.id).present?
def has_previous? = @has_previous ||= @cache.previous_dossier_id(from_id: dossier.id).present?
end