Skip to content

Commit e82d9ae

Browse files
committed
Add reverse secondary navigation styles
This will be used on the new sessions page header. Jira-Issue: MAV-2645
1 parent 49ee5ef commit e82d9ae

4 files changed

Lines changed: 63 additions & 16 deletions

File tree

app/assets/stylesheets/components/_secondary-navigation.scss

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,31 @@
8787
.app-secondary-navigation__list-item {
8888
margin-bottom: 0;
8989
}
90+
91+
.app-secondary-navigation--reverse {
92+
color: $nhsuk-reverse-text-colour;
93+
94+
.app-secondary-navigation__link {
95+
@include nhsuk-link-style-white;
96+
97+
&[aria-current] {
98+
box-shadow: inset $nhsuk-border-width 0 $nhsuk-reverse-text-colour;
99+
100+
// stylelint-disable-next-line max-nesting-depth
101+
@include nhsuk-media-query($from: tablet) {
102+
box-shadow: inset 0 ($nhsuk-border-width * -1)
103+
$nhsuk-reverse-text-colour;
104+
}
105+
}
106+
107+
&:link,
108+
&:visited,
109+
&:hover,
110+
&:visited:hover,
111+
&:active {
112+
.nhsuk-icon--alert {
113+
fill: nhsuk-colour("yellow");
114+
}
115+
}
116+
}
117+
}

app/components/app_secondary_navigation_component.html.erb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<nav class="app-secondary-navigation" aria-label="Secondary menu"
2-
<%= tag.attributes @attributes %>>
1+
<nav aria-label="Secondary menu" <%= tag.attributes(@attributes) %>>
32
<ul class="app-secondary-navigation__list">
43
<% items.each do |item| %>
54
<li class="app-secondary-navigation__list-item">
@@ -28,4 +27,4 @@
2827

2928
<h2 class="nhsuk-u-visually-hidden">
3029
<%= selected_item_text %>
31-
</h2>
30+
</h2>

app/components/app_secondary_navigation_component.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
class AppSecondaryNavigationComponent < ViewComponent::Base
44
renders_many :items, "Item"
55

6-
def initialize(classes: nil, attributes: {})
7-
classes = classes.join(" ") if classes.is_a? Array
8-
@classes =
9-
"app-secondary-navigation nhsuk-u-margin-bottom-4#{classes.present? ? " #{classes}" : ""}"
6+
def initialize(reverse: false, classes: nil, attributes: {})
7+
@classes = [
8+
"app-secondary-navigation",
9+
reverse ? "app-secondary-navigation--reverse" : nil,
10+
"nhsuk-u-margin-bottom-4",
11+
*Array(classes)
12+
].compact.join(" ")
13+
1014
@attributes =
1115
attributes.merge(class: @classes, "aria-label": "Secondary menu")
1216
end

spec/components/app_secondary_navigation_component_spec.rb

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,22 @@
33
describe AppSecondaryNavigationComponent do
44
subject(:rendered) { render_inline(component) }
55

6+
let(:reverse) { false }
7+
68
let(:component) do
7-
described_class.new.tap do |nav|
8-
nav.with_item(selected: true, href: "https://example.com") { "Example 1" }
9-
nav.with_item(
10-
selected: false,
11-
text: "Example 2",
12-
href: "https://example.com",
13-
ticked: true
14-
)
15-
end
9+
described_class
10+
.new(reverse:)
11+
.tap do |nav|
12+
nav.with_item(selected: true, href: "https://example.com") do
13+
"Example 1"
14+
end
15+
nav.with_item(
16+
selected: false,
17+
text: "Example 2",
18+
href: "https://example.com",
19+
ticked: true
20+
)
21+
end
1622
end
1723

1824
it { should have_css("nav.app-secondary-navigation") }
@@ -25,4 +31,14 @@
2531

2632
it { should have_link("Example 1", href: "https://example.com") }
2733
it { should have_link("Example 2", href: "https://example.com") }
34+
35+
context "with reverse styles" do
36+
let(:reverse) { true }
37+
38+
it do
39+
should have_css(
40+
"nav.app-secondary-navigation.app-secondary-navigation--reverse"
41+
)
42+
end
43+
end
2844
end

0 commit comments

Comments
 (0)