diff --git a/app/helpers/custom_styles_helper.rb b/app/helpers/custom_styles_helper.rb index 98ab85517f66..46bb574bd009 100644 --- a/app/helpers/custom_styles_helper.rb +++ b/app/helpers/custom_styles_helper.rb @@ -291,13 +291,24 @@ def custom_logo_upload(custom_style, mode:, field:) { field:, + mode:, label: t("admin.custom_styles.branding.modes.#{mode}.name"), present:, source: present ? custom_logo_url(custom_style, attachment) : nil, img_class: field.to_s.start_with?("logo_mobile") ? "custom-logo-mobile-preview" : "custom-logo-preview", accept: "image/*", delete_path: custom_style_logo_delete_path(field:), - instructions: t("admin.custom_styles.branding.modes.#{mode}.description") + instructions: t("admin.custom_styles.branding.modes.#{mode}.description"), + preview_data: logo_mode_data_attributes(mode) } end + + # Mirrors ApplicationHelper#user_theme_data_attributes/ThemeUtils#applyThemeToBody: with these + # two attributes on an element, CSS custom properties mapped in _primer_color_mapping.erb + # (e.g. --header-bg-color) resolve exactly as they would under that color mode, so a logo + # preview can show its background the way the real header would render it. + def logo_mode_data_attributes(mode) + color_mode = mode == :dark ? :dark : :light + { "color-mode": color_mode, "#{color_mode}-theme": mode } + end end diff --git a/app/views/custom_styles/_branding.html.erb b/app/views/custom_styles/_branding.html.erb index 8c8ea454a4fb..5784f2772400 100644 --- a/app/views/custom_styles/_branding.html.erb +++ b/app/views/custom_styles/_branding.html.erb @@ -26,22 +26,35 @@ See COPYRIGHT and LICENSE files for more details. ++#%> -<%= render(Primer::Beta::Subhead.new(spacious: true)) do |subhead| %> - <% subhead.with_heading(tag: :h3, size: :medium) { t("admin.custom_styles.branding.desktop.title") } %> +<%= render(Primer::Beta::Subhead.new(spacious: false)) do |subhead| %> + <% subhead.with_heading(tag: :h3, size: :medium, mt: 4) { t("admin.custom_styles.branding.desktop.title") } %> <% subhead.with_description { t("admin.custom_styles.branding.desktop.description") } %> <% end %> -<% custom_logo_uploads(@custom_style).each do |image| %> - <%= render partial: "custom_styles/uploads/image", locals: { image: } %> +<%= flex_layout(flex_wrap: :wrap, classes: "gap-3") do |flex| %> + <% custom_logo_uploads(@custom_style).each do |image| %> + <% flex.with_column(flex: 1, classes: "custom-style--growing-logo-form") do %> + <%= render partial: "custom_styles/uploads/image", locals: { image: } %> + <% end %> + <% end %> <% end %> -<%= render(Primer::Beta::Subhead.new(spacious: true)) do |subhead| %> - <% subhead.with_heading(tag: :h3, size: :medium) { t("admin.custom_styles.branding.mobile.title") } %> +<%= render(Primer::Beta::Subhead.new(spacious: false)) do |subhead| %> + <% subhead.with_heading(tag: :h3, size: :medium, mt: 4) { t("admin.custom_styles.branding.mobile.title") } %> <% subhead.with_description { t("admin.custom_styles.branding.mobile.description") } %> <% end %> -<% custom_logo_uploads(@custom_style, mobile: true).each do |image| %> - <%= render partial: "custom_styles/uploads/image", locals: { image: } %> +<%= flex_layout(flex_wrap: :wrap, classes: "gap-3") do |flex| %> + <% custom_logo_uploads(@custom_style, mobile: true).each do |image| %> + <% flex.with_column(flex: 1, classes: "custom-style--growing-logo-form") do %> + <%= render partial: "custom_styles/uploads/image", locals: { image: } %> + <% end %> + <% end %> +<% end %> + +<%= render(Primer::Beta::Subhead.new(spacious: false)) do |subhead| %> + <% subhead.with_heading(tag: :h3, size: :medium, mt: 4) { t("admin.custom_styles.branding.favicon.title") } %> + <% subhead.with_description { t("admin.custom_styles.branding.favicon.title_description") } %> <% end %> <% @@ -55,15 +68,20 @@ See COPYRIGHT and LICENSE files for more details. %> <%= render partial: "custom_styles/uploads/image", locals: { image: { field: :favicon, - label: I18n.t(:label_custom_favicon), + label: t("admin.custom_styles.branding.favicon.field"), + instructions: t("admin.custom_styles.branding.favicon.field_description"), present: favicon_present, source: favicon_source, img_class: "custom-favicon-preview", accept: "image/*", - delete_path: custom_style_favicon_delete_path, - instructions: I18n.t("text_custom_favicon_instructions") + delete_path: custom_style_favicon_delete_path } } %> +<%= render(Primer::Beta::Subhead.new(spacious: false)) do |subhead| %> + <% subhead.with_heading(tag: :h3, size: :medium, mt: 4) { t("admin.custom_styles.branding.touch_icon.title") } %> + <% subhead.with_description { t("admin.custom_styles.branding.touch_icon.title_description") } %> +<% end %> + <% touch_icon_present = @custom_style.persisted? && @custom_style.touch_icon.present? touch_icon_source = if touch_icon_present @@ -75,11 +93,11 @@ See COPYRIGHT and LICENSE files for more details. %> <%= render partial: "custom_styles/uploads/image", locals: { image: { field: :touch_icon, - label: I18n.t(:label_custom_touch_icon), + label: t("admin.custom_styles.branding.touch_icon.field"), + instructions: t("admin.custom_styles.branding.touch_icon.field_description"), present: touch_icon_present, source: touch_icon_source, img_class: "custom-touch-icon-preview", accept: "image/*", - delete_path: custom_style_touch_icon_delete_path, - instructions: I18n.t("text_custom_touch_icon_instructions") + delete_path: custom_style_touch_icon_delete_path } } %> diff --git a/app/views/custom_styles/_pdf_export_styles.html.erb b/app/views/custom_styles/_pdf_export_styles.html.erb index 2e28ba8b7b7d..70278415c970 100644 --- a/app/views/custom_styles/_pdf_export_styles.html.erb +++ b/app/views/custom_styles/_pdf_export_styles.html.erb @@ -29,41 +29,43 @@ See COPYRIGHT and LICENSE files for more details.
<%= I18n.t("label_custom_export_images_instructions") %>
<%= - render(Primer::Beta::Button.new( - target: "_blank", - data: { turbo: false }, - tag: :a, - href: export_demo_pdf_download_custom_style_path - )) do |_c| + render( + Primer::Beta::Button.new( + target: "_blank", + data: { turbo: false }, + tag: :a, + href: export_demo_pdf_download_custom_style_path + ) + ) do |_c| t("export.demo.button_text") end %> -<%= render partial: "custom_styles/uploads/image", locals: { image:{ - field: :export_logo, - label: I18n.t(:label_custom_export_logo), - present: @custom_style.id && @custom_style.export_logo.present?, - source: @custom_style.id && @custom_style.export_logo.present? ? - custom_style_export_logo_path(digest: @custom_style.digest, filename: @custom_style.export_logo_identifier) : - nil, - img_class: "custom-export-logo-preview", - accept: "image/png, image/jpg", - delete_path: custom_style_export_logo_delete_path, - instructions: I18n.t("text_custom_export_logo_instructions") -} } %> +<%= render partial: "custom_styles/uploads/image", locals: { image: { + field: :export_logo, + label: I18n.t(:label_custom_export_logo), + present: @custom_style.id && @custom_style.export_logo.present?, + source: if @custom_style.id && @custom_style.export_logo.present? + custom_style_export_logo_path(digest: @custom_style.digest, filename: @custom_style.export_logo_identifier) + end, + img_class: "custom-export-logo-preview", + accept: "image/png, image/jpeg", + delete_path: custom_style_export_logo_delete_path, + instructions: I18n.t("text_custom_export_logo_instructions") + } } %> -<%= render partial: "custom_styles/uploads/image", locals: { image:{ - field: :export_cover, - label: I18n.t(:label_custom_export_cover), - present: @custom_style.id && @custom_style.export_cover.present?, - source: @custom_style.id && @custom_style.export_cover.present? ? - custom_style_export_cover_path(digest: @custom_style.digest, filename: @custom_style.export_cover_identifier) : - nil, - img_class: "custom-export-cover-preview", - accept: "image/png, image/jpg", - delete_path: custom_style_export_cover_delete_path, - instructions: I18n.t("text_custom_export_cover_instructions") -} } %> +<%= render partial: "custom_styles/uploads/image", locals: { image: { + field: :export_cover, + label: I18n.t(:label_custom_export_cover), + present: @custom_style.id && @custom_style.export_cover.present?, + source: if @custom_style.id && @custom_style.export_cover.present? + custom_style_export_cover_path(digest: @custom_style.digest, filename: @custom_style.export_cover_identifier) + end, + img_class: "custom-export-cover-preview", + accept: "image/png, image/jpeg", + delete_path: custom_style_export_cover_delete_path, + instructions: I18n.t("text_custom_export_cover_instructions") + } } %> <%= form_tag update_custom_style_export_cover_text_color_path, html: { multipart: true, class: "form -vertical" } do %>