-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4260 from DFE-Digital/1720-page-updates-to-course…
…-details-page-tabs [1720] Replace tabs with secondary navigation component
- Loading branch information
Showing
10 changed files
with
155 additions
and
81 deletions.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
app/assets/stylesheets/components/publish/_secondary-navigation.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
.app-secondary-navigation { | ||
margin-bottom: govuk-spacing(7); | ||
} | ||
|
||
.app-secondary-navigation__list { | ||
font-size: 0; // Removes white space when using inline-block on child element. | ||
list-style: none; | ||
margin: 0; | ||
padding: 0; | ||
|
||
@include govuk-media-query($from: tablet) { | ||
box-shadow: inset 0 -1px 0 $govuk-border-colour; | ||
width: 100%; | ||
} | ||
} | ||
|
||
.app-secondary-navigation__item { | ||
@include govuk-font(19); | ||
box-shadow: inset 0 -1px 0 $govuk-border-colour; | ||
display: block; | ||
margin-top: -1px; | ||
|
||
&:last-child { | ||
box-shadow: none; | ||
} | ||
|
||
@include govuk-media-query($from: tablet) { | ||
box-shadow: none; | ||
display: inline-block; | ||
margin-right: govuk-spacing(4); | ||
margin-top: 0; | ||
} | ||
} | ||
|
||
.app-secondary-navigation__link { | ||
@include govuk-link-common; | ||
@include govuk-link-style-default; | ||
display: block; | ||
padding-top: govuk-spacing(2); | ||
padding-bottom: govuk-spacing(3); | ||
padding-left: govuk-spacing(3); | ||
text-decoration: none; | ||
position: relative; | ||
font-weight: bold; | ||
|
||
@include govuk-media-query($from: tablet) { | ||
padding-left: 0; | ||
} | ||
|
||
&:link, | ||
&:visited { | ||
color: govuk-colour("blue"); | ||
} | ||
|
||
&:focus { | ||
color: govuk-colour("black"); // Focus colour on yellow should really be black. | ||
position: relative; // Ensure focus sits above everything else. | ||
box-shadow: none; | ||
} | ||
|
||
&:focus:before { | ||
background-color: govuk-colour("black"); | ||
content: ""; | ||
display: block; | ||
width: 100%; | ||
position: absolute; | ||
bottom: 0; | ||
left: 0; | ||
right: 0; | ||
height: govuk-spacing(1); | ||
} | ||
} | ||
|
||
.app-secondary-navigation__link[aria-current="page"] { | ||
color: govuk-colour("black"); | ||
position: relative; | ||
text-decoration: none; | ||
|
||
&:before { | ||
background-color: govuk-colour("blue"); | ||
content: ""; | ||
display: block; | ||
height: 100%; | ||
position: absolute; | ||
bottom: 0; | ||
left: 0; | ||
width: govuk-spacing(1); | ||
|
||
@include govuk-media-query($from: tablet) { | ||
height: govuk-spacing(1); | ||
width: 100%; | ||
} | ||
} | ||
|
||
&:focus:before { | ||
background-color: govuk-colour("black"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div class="app-secondary-navigation"> | ||
<ul class="app-secondary-navigation__list"> | ||
<% navigation_items.each do |navigation_item| %> | ||
<%= navigation_item %> | ||
<% end %> | ||
</ul> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
class SecondaryNavigationComponent < ViewComponent::Base | ||
renders_many :navigation_items, 'NavigationItemComponent' | ||
|
||
class NavigationItemComponent < ViewComponent::Base | ||
attr_reader :name, :url | ||
|
||
def initialize(name, url, classes: [], html_attributes: {}) | ||
@name = name | ||
@url = url | ||
|
||
super(classes:, html_attributes:) | ||
end | ||
|
||
def call | ||
content_tag(:li, class: 'app-secondary-navigation__item') do | ||
link_to name, url, class: 'app-secondary-navigation__link', aria: { current: current_page?(url) && 'page' } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<%= render SecondaryNavigationComponent.new do |component| %> | ||
<% component.with_navigation_item t("secondary_navigation.description"), publish_provider_recruitment_cycle_course_path(@provider.provider_code, course.recruitment_cycle_year, course.course_code) %> | ||
<% component.with_navigation_item t("secondary_navigation.basic_details"), details_publish_provider_recruitment_cycle_course_path(@provider.provider_code, course.recruitment_cycle_year, course.course_code) %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters