From 75c9b6637541d3fd833a644938db42e2cf23b318 Mon Sep 17 00:00:00 2001 From: taitus Date: Thu, 14 Sep 2023 09:51:51 +0200 Subject: [PATCH 1/2] Refactor footer legal links for cleaner code Removed inline ' |' used as a separator between footer legal links. --- app/assets/stylesheets/layout.scss | 22 +++++++++++++++++++ .../layout/footer_component.html.erb | 10 ++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 9c3780f56..a557f582f 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -734,6 +734,28 @@ footer { border-top: 1px solid $text-light; font-size: $small-font-size; padding-top: $line-height / 2; + + .legal { + display: inline-block; + margin-#{$global-left}: 0; + + &::before { + content: "|"; + } + + li { + display: inline-block; + + &::after { + content: "|"; + margin-left: 4px; + } + + &:last-child::after { + content: none; + } + } + } } // 04. Tags diff --git a/app/components/layout/footer_component.html.erb b/app/components/layout/footer_component.html.erb index 979ecc556..4391b0cd0 100644 --- a/app/components/layout/footer_component.html.erb +++ b/app/components/layout/footer_component.html.erb @@ -22,11 +22,11 @@
- <%= t("layouts.footer.copyright", year: Time.current.year) %> | -
    -
  • <%= link_to t("layouts.footer.privacy"), page_path("privacy") %> |
  • -
  • <%= link_to t("layouts.footer.conditions"), page_path("conditions") %> |
  • -
  • <%= link_to t("layouts.footer.accessibility"), page_path("accessibility") %>
  • + <%= t("layouts.footer.copyright", year: Time.current.year) %> +
From c2f03f869ad893b75eb6082ebddd6c80240a21c9 Mon Sep 17 00:00:00 2001 From: taitus Date: Thu, 14 Sep 2023 10:06:04 +0200 Subject: [PATCH 2/2] Add new footer content block Include a new content block called 'footer_legal' for additional legal footer items. --- .../layout/footer_component.html.erb | 1 + app/components/layout/footer_component.rb | 5 +++ .../site_customization/content_block.rb | 2 +- config/locales/en/admin.yml | 3 +- config/locales/es/admin.yml | 3 +- .../site_customization/content_blocks_spec.rb | 32 ++++++++++++++++--- 6 files changed, 39 insertions(+), 7 deletions(-) diff --git a/app/components/layout/footer_component.html.erb b/app/components/layout/footer_component.html.erb index 4391b0cd0..52f78b18d 100644 --- a/app/components/layout/footer_component.html.erb +++ b/app/components/layout/footer_component.html.erb @@ -27,6 +27,7 @@
  • <%= link_to t("layouts.footer.privacy"), page_path("privacy") %>
  • <%= link_to t("layouts.footer.conditions"), page_path("conditions") %>
  • <%= link_to t("layouts.footer.accessibility"), page_path("accessibility") %>
  • + <%= raw footer_legal_content_block %>
    diff --git a/app/components/layout/footer_component.rb b/app/components/layout/footer_component.rb index b9e0fe5de..0f092f247 100644 --- a/app/components/layout/footer_component.rb +++ b/app/components/layout/footer_component.rb @@ -1,2 +1,7 @@ class Layout::FooterComponent < ApplicationComponent + delegate :content_block, to: :helpers + + def footer_legal_content_block + content_block("footer_legal") + end end diff --git a/app/models/site_customization/content_block.rb b/app/models/site_customization/content_block.rb index 744819956..7d42817e6 100644 --- a/app/models/site_customization/content_block.rb +++ b/app/models/site_customization/content_block.rb @@ -1,5 +1,5 @@ class SiteCustomization::ContentBlock < ApplicationRecord - VALID_BLOCKS = %w[top_links footer subnavigation_left subnavigation_right].freeze + VALID_BLOCKS = %w[top_links footer footer_legal subnavigation_left subnavigation_right].freeze validates :locale, presence: true, inclusion: { in: I18n.available_locales.map(&:to_s) } validates :name, presence: true, uniqueness: { scope: :locale }, inclusion: { in: ->(*) { VALID_BLOCKS }} diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 27351ee03..031a9759c 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -1590,7 +1590,8 @@ en: name: Name names: top_links: Top Links - footer: Footer + footer: Footer (social media) + footer_legal: Footer (legal terms) subnavigation_left: Main Navigation Left subnavigation_right: Main Navigation Right images: diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index b5c17978d..1c317d3a3 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -1590,7 +1590,8 @@ es: name: Nombre names: top_links: Enlaces superiores - footer: Pie de página + footer: Pie de página (redes sociales) + footer_legal: Pie de página (términos legales) subnavigation_left: Navegación principal izquierda subnavigation_right: Navegación principal derecha images: diff --git a/spec/system/site_customization/content_blocks_spec.rb b/spec/system/site_customization/content_blocks_spec.rb index 1af8f571e..cb7c5feb7 100644 --- a/spec/system/site_customization/content_blocks_spec.rb +++ b/spec/system/site_customization/content_blocks_spec.rb @@ -26,13 +26,37 @@ describe "Custom content blocks" do visit "/?locale=en" - expect(page).to have_content("content for footer") - expect(page).not_to have_content("contenido para footer") + within ".social" do + expect(page).to have_content("content for footer") + expect(page).not_to have_content("contenido para footer") + end visit "/?locale=es" - expect(page).to have_content("contenido para footer") - expect(page).not_to have_content("content for footer") + within ".social" do + expect(page).to have_content("contenido para footer") + expect(page).not_to have_content("content for footer") + end + end + + scenario "footer_legal content block" do + create(:site_customization_content_block, name: "footer_legal", locale: "en", + body: "legal content for footer") + create(:site_customization_content_block, name: "footer_legal", locale: "es", + body: "contenido legal para el footer") + + visit "/?locale=en" + + within ".legal" do + expect(page).to have_content("legal content for footer") + expect(page).not_to have_content("contenido legal para el footer") + end + + visit "/?locale=es" + within ".legal" do + expect(page).to have_content("contenido legal para el footer") + expect(page).not_to have_content("legal content for footer") + end end scenario "main navigation left" do