Skip to content

Commit

Permalink
Add basic layout of news and stories section on the home page
Browse files Browse the repository at this point in the history
  • Loading branch information
stacytalbot committed Dec 16, 2019
1 parent c88e9e2 commit 5b941f8
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 2 deletions.
16 changes: 16 additions & 0 deletions app/assets/stylesheets/components/_cards.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@
// classes
//--------------------------------------------------
.cards {
//--------------------------------------------------
// class - articles
//--------------------------------------------------
&--articles {
.cards {
&__cards {
@include flex;
@include responsive-styles(flex-wrap, wrap, nowrap, nowrap);
}
}

.card {
@include responsive-styles(width, 100%, 50%, 50%);
}
}

//--------------------------------------------------
// class - circles
//--------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ def index
@pas_levels = home_yml[:pas][:levels]
@pas_categories = home_yml[:pas][:categories]

comfy_news = Comfy::Cms::Page.find_by_slug("blog")
@news_articles_title = comfy_news.label
@news_articles_url = comfy_news.full_path
@news_articles = comfy_news.children.published.order(created_at: :desc).limit(2) #TODO replace with correct pages #TODO get ordering to work


@regions_page = Comfy::Cms::Page.find_by_slug("unep-regions")

@thematicAreas = [
Expand Down Expand Up @@ -76,5 +82,6 @@ def index
]

@carousel_slides = HomeCarouselSlide.all.select{|slide| slide.published }

end
end
10 changes: 8 additions & 2 deletions app/views/home/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,14 @@
resources carousel
</section>

<section>
news & stories carousel
<section class="container section-padding">
<%= render partial: "partials/cards/articles", locals:
{
title: @news_articles_title,
cards: @news_articles,
url: @news_articles_url
}
%>
</section>

<%= render "partials/ctas/live-report" %>
19 changes: 19 additions & 0 deletions app/views/partials/cards/_articles.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<div class="cards--articles">

<h3><%= title %></h3>

<%= link_to t('global.view_all'), url, target: '_blank', title: t('global.view_all') %>

<div class="cards__cards">
<% cards.each do |card| %>
<div class="card">
image
<div>
<p><%= card.created_at %></p>
<h3><%= card.label %></h3>
<p>intro field needs creating</p>
</div>
</div>
<% end %>
</div>
</div>
3 changes: 3 additions & 0 deletions config/locales/global/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
en:
global:
view_all: View all

0 comments on commit 5b941f8

Please sign in to comment.