Skip to content

Commit

Permalink
Feature/issue 347 challenges side menu (#442)
Browse files Browse the repository at this point in the history
* Adds side menu with mock data

* Adds side menu styling

* Updates side menu details, links and styling

* Adds left arrow icon

* Adds challenge region page side menu partial

* Adds logic to display side menu challenge themes and eligible locations

* Style GovHack challenge region page side menu

* Removes theme filter from challenges side menu

* Fixes Back to Challenges Catalogue link position

* Makes challenges side menu region links functional

* Replaces elligible location arrays with hashes

* Fixed during sunday judging test

* Updated test reference so tests can run on GitHub

* Ran rubocop

---------

Co-authored-by: Pamela Glickman <pamela@Pamelas-MacBook-Pro.local>
  • Loading branch information
PegliOne and Pamela Glickman authored Aug 27, 2024
1 parent 6a17def commit 5c73bcf
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 70 deletions.
51 changes: 43 additions & 8 deletions app/assets/stylesheets/components/side_menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
width: 300px;
margin-right: 40px;

> h1 {
margin: 0;
line-height: 1.3;
}

> h3 {
margin-bottom: 12px;
font-size: 20px;
}

> div {
display: flex;
flex-direction: column;
Expand All @@ -14,16 +24,17 @@
flex-direction: row;
flex-wrap: wrap;
justify-content: flex-start;
margin-top: 12px;
width: 240px;

a {
width: max-content;
margin-right: 16px;
margin-bottom: 4px;
padding: 0 4px;
border: 1px solid #5c5e60;
margin-right: 8px;
margin-bottom: 8px;
padding: 0 8px;
border: 1px solid #6f7275;
border-radius: 4px;
color: #5c5e60;
color: #6f7275;
text-decoration: none;
}
}
Expand Down Expand Up @@ -94,12 +105,36 @@
}
}

hr {
> ul {
margin-bottom: 16px;

li {
margin: 16px 0;
padding-left: 8px;

a {
color: black;
text-decoration: none;

&.selected {
color: var(--primary);
text-decoration: underline;
}
}
}
}

> hr {
height: 2px;
margin-right: 40px;
margin-bottom: 20px;
margin: 0 20px 20px 0;
color: #f4f4f4;
background-color: #f4f4f4;
border: none;
}

> p {
width: 70%;
margin: 16px 0;
font-size: 18px;
}
}
17 changes: 8 additions & 9 deletions app/assets/stylesheets/layouts/challenge_index.scss
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
/*========== Mobile First Method ==========*/

/* Custom, iPhone Retina */
@media only screen and (min-device-width: 320px) and (min-width : 320px) {
@media only screen and (min-device-width: 320px) and (min-width: 320px) {
.challenges_list > h2 {
margin-top: 1.5em;
margin-bottom: 0.5em;
}
}

/* Extra Small Devices, Phones */
@media only screen and (min-device-width: 480px) and (min-width : 480px) {

@media only screen and (min-device-width: 480px) and (min-width: 480px) {
}

/* Small Devices, Tablets */
@media only screen and (min-width : 768px) {

@media only screen and (min-width: 768px) {
}

/* Medium Devices, Desktops */
@media only screen and (min-width : 992px) {

@media only screen and (min-width: 992px) {
.challenges_list_container {
display: flex;
}
}

/* Large Devices, Wide Screens */
@media only screen and (min-width : 1200px) {

@media only screen and (min-width: 1200px) {
}
15 changes: 15 additions & 0 deletions app/controllers/regions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def show
international_challenges
regions
national_regions
eligible_locations
end

private
Expand Down Expand Up @@ -78,4 +79,18 @@ def check_show

redirect_to challenges_path, alert: 'Region not visible at this time'
end

def eligible_locations
@eligible_locations = [
{label: 'NSW', path: 'new_south_wales_2024'},
{label: 'QLD', path: 'queensland_2024'},
{label: 'VIC', path: 'victoria_2024'},
{label: 'SA', path: 'south_australia_2024'},
{label: 'WA', path: 'western_australia_2024'},
{label: 'TAS', path: 'tasmania_2024'},
{label: 'Australia', path: 'australia2024'},
{label: 'New Zealand', path: 'new_zealand2024'},
{label: 'International', path: 'international_2024'},
]
end
end
15 changes: 15 additions & 0 deletions app/views/regions/_side_menu.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<section class="side_menu">
<h1><%= yield :title %></h1>

<p>Browse challenges to solve for GovHack</p>

<hr/>

<h3>Filter By State Elegibility</h3>

<div class="tags">
<% @eligible_locations.map do |location| %>
<%= link_to location[:label], region_path(location[:path]) %>
<% end %>
</div>
</section>
102 changes: 52 additions & 50 deletions app/views/regions/show.erb
Original file line number Diff line number Diff line change
@@ -1,60 +1,62 @@
<% content_for :title,"#{@region.name} Challenges" %>
<main class="challenge_index">
<h1>
<%= yield :title %>
</h1>
<% @challenges.each do |challenge| %>
<%= render 'challenges/challenge_panel',
challenge: challenge,
entry_count: challenge.published_entries.length
%>
<% end %>
<% if @nation_wides.any? %>
<h3>Nation Wide (<%= @national.name %>) Challenges</h3>
<% @nation_wides.each do |challenge| %>
<%= render 'challenges/challenge_panel',
challenge: challenge,
entry_count: challenge.published_entries.length
%>
<% end %>
<% end %>
<% if @national.present? %>
<% unless @region.national? %>
<h3><%= @national.name %> (National) Challenges</h3>
<% @national_challenges.each do |challenge| %>
<section class="challenges_list_container">
<%= render partial: 'side_menu' %>
<div>
<% @challenges.each do |challenge| %>
<%= render 'challenges/challenge_panel',
challenge: challenge,
entry_count: challenge.published_entries.length
%>
<% end %>
<% end %>
<% end %>
<% unless @region.international? %>
<h3>International Challenges</h3>
<% @international_challenges.each do |challenge| %>
<%= render 'challenges/challenge_panel',
challenge: challenge,
entry_count: challenge.published_entries.length
%>
<% end %>
<% end %>
<% if @national_regions.any? %>
<h3>National Regions</h3>
<section class="tiles">
<% @national_regions.each do |region| %>
<% next unless @checker.show?(region) %>
<%= link_to (render 'challenges/region_tile', region: region ), region_path(region) %>
<% if @nation_wides.any? %>
<h3>Nation Wide (<%= @national.name %>) Challenges</h3>
<% @nation_wides.each do |challenge| %>
<%= render 'challenges/challenge_panel',
challenge: challenge,
entry_count: challenge.published_entries.length
%>
<% end %>
<% end %>
</section>
<% end %>
<% if @regions.any? %>
<h3>Regions</h3>
<section class="tiles">
<% @regions.each do |region| %>
<% next unless @checker.show?(region) %>
<%= link_to (render 'challenges/region_tile', region: region ), region_path(region) %>
<% if @national.present? %>
<% unless @region.national? %>
<h3><%= @national.name %> (National) Challenges</h3>
<% @national_challenges.each do |challenge| %>
<%= render 'challenges/challenge_panel',
challenge: challenge,
entry_count: challenge.published_entries.length
%>
<% end %>
<% end %>
<% end %>
</section>
<% end %>
<% unless @region.international? %>
<h3>International Challenges</h3>
<% @international_challenges.each do |challenge| %>
<%= render 'challenges/challenge_panel',
challenge: challenge,
entry_count: challenge.published_entries.length
%>
<% end %>
<% end %>
<% if @national_regions.any? %>
<h3>National Regions</h3>
<section class="tiles">
<% @national_regions.each do |region| %>
<% next unless @checker.show?(region) %>
<%= link_to (render 'challenges/region_tile', region: region ), region_path(region) %>
<% end %>
</section>
<% end %>
<% if @regions.any? %>
<h3>Regions</h3>
<section class="tiles">
<% @regions.each do |region| %>
<% next unless @checker.show?(region) %>
<%= link_to (render 'challenges/region_tile', region: region ), region_path(region) %>
<% end %>
</section>
<% end %>
<%= link_to 'Back to Challenges Catalogue', challenges_path %>
</div>
</section>
</main>
<%= link_to 'Back to Challenges Catalogue', challenges_path %>
16 changes: 13 additions & 3 deletions test/models/competition_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,20 @@ class CompetitionTest < ActiveSupport::TestCase

test 'during sunday judging?' do
time_now = Time.now.in_time_zone('Brisbane')
# end time in the past and after 4pm
@competition.update! end_time: Time.new(time_now.year, time_now.month, time_now.day, 0, 0, 0)

assert @competition.in_sunday_judging?('Brisbane')
if time_now.hour < 12
# when current time is before 12pm, set previous day as end day and expect competition to be in sunday judging
@competition.update! end_time: time_now - 1.day
assert @competition.in_sunday_judging?('Brisbane')
elsif time_now.hour >= 16
# when current time is after 4pm, set current day as end day and expect competition to be in current judging
@competition.update! end_time: time_now
assert @competition.in_sunday_judging?('Brisbane')
else
# when the current time is not a valid sunday judging time expect the competition not to be in current judging
@competition.update! end_time: time_now
assert_not @competition.in_sunday_judging?('Brisbane')
end
end

test 'after sunday judging?' do
Expand Down

0 comments on commit 5c73bcf

Please sign in to comment.