Skip to content

Commit

Permalink
add promo video content block (#15)
Browse files Browse the repository at this point in the history
* add promo video content block

* fix active processes cell
  • Loading branch information
microstudi committed Sep 7, 2023
1 parent 0afc191 commit 1dc3ff4
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 62 deletions.
13 changes: 5 additions & 8 deletions app/cells/decidim/content_blocks/active_processes/show.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
<div class="row column">
<h3 class="section-heading"><%= t(".title") %></h3>
<div class="text-center">
<div class="row small-up-1 medium-up-3">
<% (1..3).each do |i| %>
<div class="row small-up-1 medium-up-<%= items.size %>">
<% items.each do |item| %>
<div class="column">
<div class="card">
<%= link_to link_url(i) do %>
<% if (image_url = image_url_for(i)) %>
<%= image_tag image_url %>
<% end %>
<h3 class="heading3 card-header text-left ml-s" style="color: <%= text_color(i) %>;"><%= link_text(i)
%></h3>
<%= link_to item[:link_url] do %>
<%= image_tag item[:image_url] if item[:image_url] %>
<h3 class="heading3 card-header text-left ml-s" style="color: <%= item[:text_color] %>;"><%= item[:link_text] %></h3>
<% end %>
</div>
</div>
Expand Down
15 changes: 14 additions & 1 deletion app/cells/decidim/content_blocks/active_processes_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ def show
render
end

def items
(1..3).filter_map do |i|
next if link_url(i).blank?

{
link_url: link_url(i),
link_text: link_text(i),
image_url: image_url_for(i),
text_color: text_color(i)
}
end
end

def link_url(attribute)
model.settings["link_url_#{attribute}"]
end
Expand All @@ -30,7 +43,7 @@ def text_color(attribute)
end

def button
return unless button_text && button_url
return unless button_text.present? && button_url.present?

link_to button_text, button_url, class: "button hollow"
end
Expand Down
12 changes: 12 additions & 0 deletions app/cells/decidim/content_blocks/promo_video/show.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<section id="promo-video" class="extended home-section promo-video">
<div class="row">

<video controls width="100%" style="width: 100%;max-height: 100%;" autoplay muted>

<source src="<%= video_url %>" type="video/mp4" />

Download the <a href="<%= video_url %>">video</a>.
</video>

</div>
</section>
17 changes: 17 additions & 0 deletions app/cells/decidim/content_blocks/promo_video_cell.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

module Decidim
module ContentBlocks
class PromoVideoCell < Decidim::ViewModel
def video_url
case I18n.locale
when :en
# change to "en" when available
"/ecod_ca.mp4"
else
"/ecod_ca.mp4"
end
end
end
end
end
27 changes: 16 additions & 11 deletions app/packs/stylesheets/partials/_html_block.scss
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
.democracy-innovation {
background-color: $capitalitat-violet;
.promo-video {
background-color: $cpb-violet;
padding: 4rem 0;
}

.democracy-innovation .button {
color: #ffffff;
border-color: #fff;
@media print, screen and (max-width: 40em) {
padding: 0;
}
}

.democracy-innovation {
background-color: $capitalitat-violet;
padding: 4rem 0;
color: #ffffff;
}

.democracy-innovation .heading3 {
margin-bottom: 2rem;

.button {
color: #ffffff;
border-color: #fff;
}

.heading3 {
margin-bottom: 2rem;
}
}
84 changes: 42 additions & 42 deletions config/initializers/conferences_hacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,54 +11,54 @@
Decidim::Conferences::ConferencesController.include(ConferencesControllerOverride)
end

Rails.application.config do
initializer "capitalitat.homepage_content_blocks" do
config.to_prepare do
Decidim.content_blocks.register(:homepage, :active_processes) do |content_block|
content_block.cell = "decidim/content_blocks/active_processes"
content_block.settings_form_cell = "decidim/content_blocks/active_processes_settings_form"
content_block.public_name_key = "decidim.content_blocks.active_processes.name"
Decidim.content_blocks.register(:homepage, :active_processes) do |content_block|
content_block.cell = "decidim/content_blocks/active_processes"
content_block.settings_form_cell = "decidim/content_blocks/active_processes_settings_form"
content_block.public_name_key = "decidim.content_blocks.active_processes.name"

content_block.settings do |settings|
settings.attribute :button_text, type: :text, translated: true
settings.attribute :button_url, type: :text
content_block.settings do |settings|
settings.attribute :button_text, type: :text, translated: true
settings.attribute :button_url, type: :text

(1..3).each do |i|
settings.attribute "link_url_#{i}".to_sym, type: :text
settings.attribute "link_text_#{i}".to_sym, type: :text, translated: true
settings.attribute "text_color_#{i}".to_sym, type: :string
end
end
(1..3).each do |i|
settings.attribute "link_url_#{i}".to_sym, type: :text
settings.attribute "link_text_#{i}".to_sym, type: :text, translated: true
settings.attribute "text_color_#{i}".to_sym, type: :string
end
end

(1..3).each do |i|
content_block.images << {
name: "image_#{i}".to_sym,
uploader: "Decidim::ActiveProcessesImageUploader"
}
end
(1..3).each do |i|
content_block.images << {
name: "image_#{i}".to_sym,
uploader: "Decidim::ActiveProcessesImageUploader"
}
end

content_block.default!
end
content_block.default!
end

Decidim.content_blocks.register(:homepage, :extended_hero) do |content_block|
content_block.cell = "decidim/content_blocks/extended_hero"
content_block.settings_form_cell = "decidim/content_blocks/extended_hero_settings_form"
content_block.public_name_key = "decidim.content_blocks.extended_hero.name"
Decidim.content_blocks.register(:homepage, :extended_hero) do |content_block|
content_block.cell = "decidim/content_blocks/extended_hero"
content_block.settings_form_cell = "decidim/content_blocks/extended_hero_settings_form"
content_block.public_name_key = "decidim.content_blocks.extended_hero.name"

content_block.settings do |settings|
settings.attribute :welcome_title, type: :text, translated: true
settings.attribute :subtitle, type: :text, translated: true
end
content_block.settings do |settings|
settings.attribute :welcome_title, type: :text, translated: true
settings.attribute :subtitle, type: :text, translated: true
end

content_block.images = [
{
name: :background_image,
uploader: "Decidim::HomepageImageUploader"
}
]
content_block.images = [
{
name: :background_image,
uploader: "Decidim::HomepageImageUploader"
}
]

content_block.default!
end
end
end
content_block.default!
end

Decidim.content_blocks.register(:homepage, :promo_video) do |content_block|
content_block.cell = "decidim/content_blocks/promo_video"
content_block.public_name_key = "decidim.content_blocks.promo_video.name"
content_block.default!
end
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ en:
text_color: Text color
extended_hero:
name: Extended hero
promo_video:
name: Promo video
extended_hero_settings_form:
background_image: Background image
subtitle: Subtitle
Expand Down
Binary file added public/ecod_ca.mp4
Binary file not shown.

0 comments on commit 1dc3ff4

Please sign in to comment.