Skip to content

Commit

Permalink
template without links
Browse files Browse the repository at this point in the history
model and template

template model and spec

rubocop
  • Loading branch information
SocFoot committed Dec 22, 2023
1 parent a485bee commit ad32226
Show file tree
Hide file tree
Showing 12 changed files with 286 additions and 27 deletions.
83 changes: 82 additions & 1 deletion app/assets/stylesheets/application.sass.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,86 @@ $govuk-new-link-styles: true;
$govuk-assets-path: "";

@import "govuk-frontend/dist/govuk/all";

@import "components/all";
// // @import "govuk-frontend/govuk/base";
// @import "govuk-frontend/dist/govuk/base";
// @import "@ministryofjustice/frontend/moj/settings/all";
// @import "@ministryofjustice/frontend/moj/helpers/all";
// @import "@ministryofjustice/frontend/moj/objects/all";

// @import "@ministryofjustice/frontend/moj/components/primary-navigation/primary-navigation";
// // @import "@ministryofjustice/frontend/moj/all";
// $moj-images-path: "@ministryofjustice/frontend/moj/assets/images/";
// $mobile-small-start: 400px;
// $mobile-small-end: 401px;
// $mobile-big-start: 500px;
// $mobile-big-end: 501px;
// $git-brand-colour: #159964;
.app-primary-navigation {
background-color: govuk-colour("light-grey");
}

.app-primary-navigation--justify-between {
display: flex;
justify-content: space-between;
}

.app-primary-navigation__list {
@include govuk-clearfix;
list-style: none;
margin: 0;
padding: 0;
}

.app-primary-navigation__item {
@include govuk-font($size: 19);
float: left;
margin-right: govuk-spacing(3);
margin-top: 0;

&:last-child {
margin-right: 0;
}

@include govuk-media-query($from: tablet) {
margin-right: govuk-spacing(4);
}
}

.app-primary-navigation__item--align-right {
@include govuk-media-query($from: tablet) {
float: right;
}
}

.app-primary-navigation__link {
@include govuk-link-common;
@include govuk-link-style-no-visited-state;
display: block;
font-weight: bold;
padding-bottom: govuk-spacing(3);
padding-top: govuk-spacing(3);
text-decoration: none;

&:focus {
background-color: $govuk-focus-colour;
box-shadow: inset 0 -5px 0 0 $govuk-focus-text-colour;
color: $govuk-focus-text-colour;
outline: $govuk-focus-width solid transparent;
}

&[aria-current] {
box-shadow: inset 0 -5px 0 0 $govuk-link-colour;
color: $govuk-link-colour;

&:hover {
box-shadow: inset 0 -5px 0 0 $govuk-link-hover-colour;
color: $govuk-link-hover-colour;
}

&:focus {
box-shadow: inset 0 -7px 0 0 $govuk-focus-text-colour;
color: $govuk-focus-text-colour;
}
}
}
13 changes: 13 additions & 0 deletions app/components/application_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

class ApplicationComponent < GovukComponent::Base
def initialize(classes: [], html_attributes: {})
super(classes:, html_attributes:)
end

private

def default_attributes
{}
end
end
22 changes: 22 additions & 0 deletions app/components/navigation_bar.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<div class="app-primary-navigation">
<div class="app-primary-navigation govuk-!-display-none-print">
<div class="govuk-width-container app-primary-navigation--justify-between">
<nav class="app-primary-navigation__nav" aria-label="main menu">
<ul class="app-primary-navigation__list">
<li class="app-primary-navigation__item">
<a class="app-primary-navigation__link" href="#">Claims</a>
</li>
<% items.each do |item| %>
<li class="app-primary-navigation__item">
<% if item[:active] %>
<%= govuk_link_to item[:name], item[:href], class:"app-primary-navigation__link", aria: { current: "page" } %>
<% else %>
<%= govuk_link_to item[:name], item[:href], class:"app-primary-navigation__link" %>
<% end %>
</li>
<% end %>
</ul>
</nav>
</div>
</div>
</div>
36 changes: 36 additions & 0 deletions app/components/navigation_bar.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# frozen_string_literal: true

class NavigationBar < ApplicationComponent
attr_reader :items, :current_path

def initialize(
items:,
current_path:,
current_user: {},
classes: [],
html_attributes: {}
)
super(classes:, html_attributes:)
@items = items
@current_path = current_path
@current_user = current_user
end

def item_link(item)
link_params.merge!(aria: { current: "page" }) if show_current_link?(item)
govuk_link_to(item[:name], item[:url], no_underline: true)
end

def user_signed_in?
@current_user.present?
end

private

def show_current_link?(item)
item.fetch(:current, false) ||
[item.fetch(:url), item[:additional_url]].compact.any? do |url|
current_path.include?(url)
end
end
end
3 changes: 3 additions & 0 deletions app/controllers/claims/pages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
class Claims::PagesController < ApplicationController
def index
@school = GiasSchool.first
end
end
23 changes: 23 additions & 0 deletions app/helpers/navigation_bar_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

module NavigationBarHelper
def render_navigation_bar?(provider)
request.path.exclude?("support") && provider && !current_page?(root_path) &&
!current_page?(publish_provider_path(provider.provider_code)) &&
provider.recruitment_cycle
end

def navigation_items(_provider)
[
{
name: t("navigation_bar.users"),
url: "#",
additional_url:
"request_access_publish_provider_path(provider.provider_code)"
},
name: t("navigation_bar.organisation_details"),
url: root_path,
active: request.path == root_path
]
end
end
71 changes: 47 additions & 24 deletions app/views/claims/pages/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,26 +1,49 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-xl">It works! 🎉</h1>
<%= render(NavigationBar.new(
items: navigation_items(@provider),
current_path: request.path,
current_user: User.first
)) %>

<p class="govuk-body">
Your application is ready - so long as this page rendered without any errors you're good to go.
</p>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l">Organisation details</h1>
<%= govuk_summary_list do |summary_list|
summary_list.with_row do |row|
row.with_key(text: "Organisation name")
row.with_value(text: @school.name)
end;summary_list.with_row do |row|
row.with_key(text: "UK provider reference number (UKPRN)")
row.with_value(text: @school.ukprn)
end;summary_list.with_row do |row|
row.with_key(text: "Unique reference number (URN)")
row.with_value(text: @school.urn)
end;end %>

<%= govuk_summary_list(
rows: [
{ key: { text: "Service" }, value: { text: "Claims" } },
{ key: { text: "Rails version" }, value: { text: Rails.version } },
{ key: { text: "Ruby version" }, value: { text: RUBY_VERSION } },
{ key: {
text: "GOV.UK Frontend" },
value: {
text: JSON
.parse(File.read(Rails.root.join("package.json")))
.dig("dependencies", "govuk-frontend")
.tr("^", "")
}
}
]
) %>
</div>
</div>
<h2 class="govuk-heading-m govuk-!-margin-top-9">Contact details</h2>
<%= govuk_summary_list do |summary_list|
summary_list.with_row do |row|
row.with_key(text: 'Email address')
row.with_value do %>
<a href="[email protected]">[email protected]</a>
<% end;row.with_action(text: 'Change', visually_hidden_text: 'email address', href: '/contact-details')
end;summary_list.with_row do |row|
row.with_key(text: 'Telephone number')
row.with_value(text: @school.telephone)
row.with_action(text: 'Change', visually_hidden_text: 'email address', href: '/contact-details')
end;summary_list.with_row do |row|
row.with_key(text: 'Website')
row.with_value do %>
<a href="<%= @school.website %>"><%= @school.website %></a>
<% end;row.with_action(text: 'Change', visually_hidden_text: 'email address', href: '/contact-details')
end;summary_list.with_row do |row|
row.with_key(text: 'Address')
row.with_value do %>
<p class="govuk-body">
<%= @school.address1 %><br>
<%= @school.address2 %><br>
<%= @school.address3 %><br>
</p>
<% end;row.with_action(text: 'Change', visually_hidden_text: 'email address', href: '/contact-details')
end;end %>
</div>
</div>
4 changes: 3 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@

<%= govuk_skip_link %>

<%= govuk_header(homepage_url: "https://www.gov.uk", service_name: t(".#{current_service}.header.service_name"), service_url: "/") %>
<%= govuk_header(homepage_url: "https://www.gov.uk") do |header| %>
<%= header.with_product_name(name: "Product") %>
<% end %>

<div class="app-phase-banner app-phase-banner__env--<%= HostingEnvironment.name(current_service) %>">
<div class="govuk-width-container">
Expand Down
2 changes: 1 addition & 1 deletion config/locales/claims/en/layouts/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ en:
application:
claims:
header:
service_name: Claim Funding for General Mentors
product_name: Claim Funding for General Mentors
4 changes: 4 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ en:
placements:
heading: Placements news and updates
contents: Contents
navigation_bar:
organisation_details: Organisation details
users: Users

6 changes: 6 additions & 0 deletions spec/factories/gias_schools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,11 @@
factory :gias_school do
sequence(:urn) { _1 }
name { "Hogwarts" }
ukprn { "fake_uprn" }
telephone { "0123456789" }
website { "www.hogwarts.com" }
address1 { "Hogwarts Castle" }
address2 { "Scotland" }
address3 { "United Kingdom" }
end
end
46 changes: 46 additions & 0 deletions spec/system/claims/pages/home_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
require "rails_helper"

RSpec.feature "Home Page" do
after { Capybara.app_host = nil }

scenario "User visits the claims homepage" do
given_there_is_an_existing_persona_for("Mary")
given_i_am_on_the_claims_site

when_i_visit_home_page
i_can_see_organisation_details
i_can_see_contact_details

end

private

def given_i_am_on_the_claims_site
Capybara.app_host = "http://#{ENV["CLAIMS_HOST"]}"
end

def when_i_visit_home_page
visit "/"
end

def given_there_is_an_existing_persona_for(persona_name)
user = create(:persona, persona_name.downcase.to_sym,service:"claims")
create(:gias_school)
DfESignInUser.load_from_session({"dfe_sign_in_user"=>{"email"=>user.email},"service" =>:claims})
end

def i_can_see_organisation_details
expect(page).to have_css(".govuk-summary-list__value", text: "Hogwarts")
expect(page).to have_css(".govuk-summary-list__value", text: "fake_uprn")
expect(page).to have_css(".govuk-summary-list__value", text: 1)
end

def i_can_see_contact_details
expect(page).to have_css(".govuk-summary-list__value", text: "[email protected]")
expect(page).to have_css(".govuk-summary-list__value", text: "0123456789")
expect(page).to have_css(".govuk-summary-list__value", text: "www.hogwarts.com")
expect(page).to have_css(".govuk-summary-list__value", text: "Hogwarts Castle")
expect(page).to have_css(".govuk-summary-list__value", text: "Scotland")
expect(page).to have_css(".govuk-summary-list__value", text: "United Kingdom")
end
end

0 comments on commit ad32226

Please sign in to comment.