Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legislature tabs #15426

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions t/web/tab_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: true
require 'test_helper'
require_relative '../../app'

describe 'Tab component in term table' do
subject { Nokogiri::HTML(last_response.body) }

before do
stub_everypolitician_data_request('6139efe/data/Australia/Representatives/ep-popolo-v1.0.json')
get '/australia/representatives/term-table/44.html'
end

it 'should have as many tabs as houses' do
subject.css('.house-tab').count.must_equal 2
end

describe 'active tab' do
it 'should be the House of Representatives' do
subject.css('.house-tab--active').text.strip.must_equal 'House of Representatives'
end
end

describe 'tab links' do
let(:tabs) { subject.css('.house-tab/@href') }

it 'links to first term in House of Representatives' do
tabs.first.text.must_equal '/australia/representatives/term-table/44.html'
end

it 'links to first term in Senate' do
tabs.last.text.must_equal '/australia/senate/term-table/44.html'
end
end
end
62 changes: 54 additions & 8 deletions views/sass/_components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,58 @@ p.lead {

// Little round social icons for membership tables
.person-link {
display: inline-block;
width: 24px;
padding-top: 24px;
height: 0;
overflow: hidden;
vertical-align: middle;
border-radius: 100%;
margin-right: 0.3em;
display: inline-block;
width: 24px;
padding-top: 24px;
height: 0;
overflow: hidden;
vertical-align: middle;
border-radius: 100%;
margin-right: 0.3em;
}

.house-tabs {
@extend .unstyled-list;
@extend .inline-list;
padding-top: 1em;

// Make the tabs scroll horizontally on small screens.
// TODO: Make this not suck when the currently selected tab is
// hidden off to the far right of the line.
@media (max-width: $small_screen_max) {
text-align: left;
white-space: nowrap;
overflow: auto;
margin: 0 -1em;
padding: 1em 0.5em 0 0.5em;
}

@media (min-width: $medium_screen) and (min-height: 600px) {
padding-top: 1.5em;
}
}

.house-tab {
display: inline-block;
padding: 0.5em 1em;
border-radius: 5px 5px 0 0;
background-color: mix($colour_green, #fff, 25%);
background: linear-gradient(180deg, mix($colour_green, #fff, 20%), 50%, mix($colour_green, #fff, 30%));
color: darken($colour_green, 10%) !important;

&:hover,
&:focus {
background-color: mix($colour_green, #fff, 15%);
background: linear-gradient(180deg, mix($colour_green, #fff, 10%), 50%, mix($colour_green, #fff, 20%));
}
}

.house-tab--active,
.house-tab--active:hover,
.house-tab--active:focus {
background: #fff;
}

.source-credits a {
@extend .break-word;
}
15 changes: 15 additions & 0 deletions views/sass/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,18 @@
}
}
}

.break-word {
// https://css-tricks.com/snippets/css/prevent-long-urls-from-breaking-out-of-container/
overflow-wrap: break-word;
word-wrap: break-word;

-ms-word-break: break-all;
word-break: break-all;
word-break: break-word;

-ms-hyphens: auto;
-moz-hyphens: auto;
-webkit-hyphens: auto;
hyphens: auto;
}
4 changes: 4 additions & 0 deletions views/sass/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ textarea {
-webkit-appearance: none;
}

select {
max-width: 100%;
}

fieldset {
padding: 0;
border: 0;
Expand Down
1 change: 1 addition & 0 deletions views/sass/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ $high_dpi_screen: '-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi

$large_screen_max: $giant_screen - (1em * (1px / $size_font-base));
$medium_screen_max: $large_screen - (1em * (1px / $size_font-base));
$small_screen_max: $medium_screen - (1em * (1px / $size_font-base));

$animation-short: 0.2s ease-out;

Expand Down
16 changes: 16 additions & 0 deletions views/term_table.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
<div class="page-section page-section--green page-section--no-padding">
<div class="container text-center">
<ul class="house-tabs">
<% @page.country.legislatures.each do |house| %>
<li>
<a
class="house-tab <% if @page.house == house %>house-tab--active<% end %>"
href="<%= term_table_url(house.legislative_periods.first) %>">
<%= house.name %>
</a>
</li>
<% end %>
</ul>
</div>
</div>

<div class="page-section" id="term">
<div class="container text-center">
<h1><span class="avatar"><i class="fa fa-university"></i></span> <%= @page.current_term.name %></h1>
Expand Down