Skip to content

Commit

Permalink
add link color
Browse files Browse the repository at this point in the history
  • Loading branch information
microstudi committed Nov 24, 2023
1 parent bf98c28 commit dca8e35
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 26 deletions.
12 changes: 12 additions & 0 deletions app/cells/concerns/decidim/newsletter_agenda/theme_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ def organization_handler_attributes
end
end

def link_color
@link_color ||= model.settings.link_color.presence ||
default_link_color
end

def background_color
@background_color ||= model.settings.background_color.presence ||
default_background_color
Expand All @@ -36,6 +41,13 @@ def font_color_over_bg
default_font_color_over_bg
end

def default_link_color
@default_link_color ||= NewsletterAgenda.default_link_color ||
NewsletterAgenda.themes&.dig(theme, :default_link_color) ||
current_organization.colors["primary"] ||
"#39747f"
end

def default_background_color
@default_background_color ||= NewsletterAgenda.default_background_color ||
NewsletterAgenda.themes&.dig(theme, :default_background_color) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@
<% end %>

<!-- Date -->
<p style="text-align:left; color: #3998D4; font-size: 16px; font-weight: bold; padding-top: 10px;margin: 0;">
<p style="text-align:left; color: <%= link_color %>; font-size: 16px; font-weight: bold; padding-top: 10px;margin: 0;">
<%= translated_text_for "body_box_date_time_#{num}" %>
</p>

<!-- Title -->
<h2 style="text-align:left; color: #3998D4; font-size: 18px; font-weight: bold; padding: 0;">
<h2 style="text-align:left; color: <%= link_color %>; font-size: 18px; font-weight: bold; padding: 0;">
<%= translated_text_for "body_box_title_#{num}" %>
</h2>

Expand All @@ -172,7 +172,7 @@
<% if link %>
<p style="text-align:left; padding-top: 10px;">
<%= link_to translated_text_for("body_box_link_text_#{num}"), link,
style: "color: #3998D4;font-weight: bold; text-decoration: underline;",
style: "color: #{link_color};font-weight: bold; text-decoration: underline;",
target: :blank %>
</p>
<% end %>
Expand Down Expand Up @@ -282,9 +282,9 @@
<td class="mobile-responsive logos-block" style="padding: 0 32px 0 0;vertical-align: bottom;">
<table border="0" cellspacing="0" cellpadding="0">
<tr class="footer-logos">
<td align="left" class="footer-logo" style="padding-left: 16px;padding-right: 20px;"><%= image_tag footer_image_capitalitat %></td>
<td align="center" class="footer-logo" style="padding-left: 16px;padding-right: 20px;"><%= image_tag footer_image_ajuntament %></td>
<td align="right" class="footer-logo" style="padding-left: 16px;"><%= image_tag footer_image_metropolita %></td>
<td align="left" class="footer-logo" style="padding-left: 16px;padding-right: 20px;"><%= image_tag asset_pack_url("media/images/capital_logo.png", **host_options) %></td>
<td align="center" class="footer-logo" style="padding-left: 16px;padding-right: 20px;"><%= image_tag asset_pack_url("media/images/ajuntament.png", **host_options) %></td>
<td align="right" class="footer-logo" style="padding-left: 16px;"><%= image_tag asset_pack_url("media/images/metropolita_logo.png", **host_options) %></td>
</tr>
</table>
</td>
Expand Down
20 changes: 0 additions & 20 deletions app/cells/decidim/newsletter_agenda/agenda_events_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,6 @@ def social_links
links
end

def background_image_top
asset_pack_url("media/images/background_top.gif", **host_options)
end

def background_image_bottom_url
asset_pack_url("media/images/background_bottom.gif", **host_options)
end

def footer_image_capitalitat
asset_pack_url("media/images/capital_logo.png", **host_options)
end

def footer_image_metropolita
asset_pack_url("media/images/metropolita_logo.png", **host_options)
end

def footer_image_ajuntament
asset_pack_url("media/images/ajuntament.png", **host_options)
end

private

def representation_url(image)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<% form.fields_for :settings, settings do |settings_fields| %>
<%= settings_fields.text_field :link_color, label: t(".link_color"), type: "color" %>
<%= settings_fields.text_field :background_color, label: t(".background_color"), type: "color" %>
<%= settings_fields.text_field :font_color_over_bg, label: t(".font_color_over_bg"), type: "color" %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class AgendaEventsSettingsFormCell < NewsletterTemplates::BaseSettingsFormCell
# rubocop:disable Metrics/PerceivedComplexity
def settings
@settings ||= form.object.settings.tap do |settings|
settings[:link_color] ||= default_link_color
settings[:background_color] ||= default_background_color
settings[:font_color_over_bg] ||= default_font_color_over_bg
settings[:body_title].tap do |hash|
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ en:
decidim:
newsletter_agenda:
agenda_events_settings_form:
link_color: Link color
background_color: Background color
body: Body
body_box_date_time: Body event date/time
Expand Down
6 changes: 6 additions & 0 deletions lib/decidim/newsletter_agenda.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ module NewsletterAgenda
nil
end

config_accessor :default_link_color do
nil
end

# The default address text for the newsletter agenda.
# leave it empty (nil) to use the one defined in the config accessor "themes" for the theme
config_accessor :default_address_text do
Expand All @@ -41,6 +45,7 @@ module NewsletterAgenda
canodrom: {
default_background_color: "#7636D2",
default_font_color_over_bg: "#FFFFFF",
default_link_color: "#7636D2",
default_address_text: "<b>Canòdrom</b><br>" \
"<b>Ateneu d'Innovació Digital i Democràtica</b><br>" \
"C/Concepció Arenal 165<br>09027 Barcelona <a href='https://canodrom.barcelona'>canodrom.barcelona</a><br>" \
Expand All @@ -51,6 +56,7 @@ module NewsletterAgenda
capitalitat: {
default_background_color: "#524F9F",
default_font_color_over_bg: "#FFFFFF",
default_link_color: "#524F9F",
default_address_text: "<b>European Capital of Democracy</b><br>" \
"C/Concepció Arenal 165<br>09027 Barcelona <a href='https://capitalofdemocracy.barcelona'>capitalofdemocracy.barcelona</a><br>" \
"<a href='mailto:[email protected]'>[email protected]</a>",
Expand Down
5 changes: 5 additions & 0 deletions lib/decidim/newsletter_agenda/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class Engine < ::Rails::Engine
end

content_block.settings do |settings|
settings.attribute(
:link_color,
type: :text,
preview: -> { Decidim::NewsletterAgenda.default_link_color || properties[:default_link_color] || "#39747f" }
)
settings.attribute(
:background_color,
type: :text,
Expand Down

0 comments on commit dca8e35

Please sign in to comment.