- <% if application.icon.attached? && application.persisted? %>
- <% begin %>
- <%# Only show icon if we can successfully get its URL (blob is persisted) %>
- <% if application.icon.blob&.persisted? && application.icon.blob.key.present? %>
-
- <% end %>
- <% rescue ArgumentError => e %>
- <%# Handle case where icon attachment exists but can't generate signed_id %>
- <% if e.message.include?("Cannot get a signed_id for a new record") %>
-
-
Icon uploaded
-
File will be processed shortly
-
- <% else %>
- <%# Re-raise if it's a different error %>
- <% raise e %>
- <% end %>
- <% end %>
- <% end %>
-
-
-
-
-
-
-
or drag and drop
-
-
PNG, JPG, GIF, or SVG up to 2MB
-
💡 Tip: Click here and press Ctrl+V (or Cmd+V) to paste an image from your clipboard
+ <%= render "icon_uploader",
+ form: form,
+ field: :icon_dark,
+ label: "Dark mode icon (optional)",
+ help: "Used in place of the main icon when the user's theme is dark. If omitted, the main icon is used in both modes.",
+ current_attached: (application.persisted? ? application.icon_dark : nil),
+ current_label: "Current dark-mode icon",
+ preview_extra_class: "bg-gray-900" %>
diff --git a/app/views/admin/applications/_icon_uploader.html.erb b/app/views/admin/applications/_icon_uploader.html.erb
new file mode 100644
index 0000000..b7ae980
--- /dev/null
+++ b/app/views/admin/applications/_icon_uploader.html.erb
@@ -0,0 +1,66 @@
+<%# Compact icon uploader. Locals:
+ form - the form builder
+ field - symbol for the file field (:icon or :icon_dark)
+ label - heading text
+ help - small helper paragraph (optional)
+ current_attached - the attachment to show as "current" preview
+ current_label - text for the preview row (e.g. "Current icon")
+ preview_extra_class - extra css for the preview img (e.g. "bg-gray-900")
+%>
+