Files
vault171/app/views/layouts/_form_header.html.erb
David Böhm 2931314cd1
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / scan_js (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
CI / system-test (push) Has been cancelled
More layout adjustments and more dry refactor
2026-05-30 03:02:31 +02:00

26 lines
1.6 KiB
Plaintext

<%
# 1. Wir prüfen automatisch, ob es ein neuer oder bestehender Eintrag ist
is_new = model.new_record?
# 2. Farb- und Icon-Weiche (Blau für Neu, Amber für Bearbeiten)
bg_css = is_new ? "bg-blue-50 border-blue-100 text-blue-600" : "bg-amber-50 border-amber-100 text-amber-600"
title_text = is_new ? new_title : edit_title
desc_text = is_new ? new_description : edit_description
# 3. Die beiden SVGs (Plus vs. Stift) mit identischer Konturschärfe (stroke-width="2")
icon_plus = '<svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" /></svg>'
icon_edit = '<svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" /></svg>'
final_icon = is_new ? icon_plus.html_safe : icon_edit.html_safe
%>
<div class="flex items-center gap-3">
<!-- Das Icon-Quadrat wechselt dynamisch seine Farbe und Grafik -->
<div class="p-2 rounded-lg border shrink-0 <%= bg_css %>">
<%= final_icon %>
</div>
<div class="min-w-0">
<h2 class="text-xl font-bold text-gray-800 leading-tight"><%= title_text %></h2>
<p class="text-sm text-gray-500 mt-1 leading-normal"><%= desc_text %></p>
</div>
</div>