Skip to content

Commit

Permalink
Support form submission from header account items
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrobertlloyd committed Feb 22, 2025
1 parent a57b40f commit e39fa33
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/components/header/header-account-custom-html.njk
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
html: '<a class="nhsuk-header__account-link" href="#">Notifications</a> <span class="app-count">8</span>'
},
{
href: "#",
action: "#",
text: "Log out"
}
]
Expand Down
2 changes: 1 addition & 1 deletion app/components/header/header-account-logged-in.njk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
icon: true
},
{
href: "#",
action: "#",
text: "Log out"
}
]
Expand Down
2 changes: 1 addition & 1 deletion app/components/header/header-account-rbac.njk
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
text: "Change role"
},
{
href: "#",
action: "#",
text: "Log out"
}
]
Expand Down
2 changes: 1 addition & 1 deletion app/components/header/header-org-white-account.njk
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
icon: true
},
{
href: "#",
action: "#",
text: "Log out"
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
icon: true
},
{
href: "#",
action: "#",
text: "Log out"
}
]
Expand Down
14 changes: 14 additions & 0 deletions packages/components/header/_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,26 @@
flex-grow: 0;
}

.nhsuk-header__account-button,
.nhsuk-header__account-link {
@include nhsuk-link-style-header;
display: flex;
gap: nhsuk-spacing(2);
}

.nhsuk-header__account-button {
@include nhsuk-font(16);
background: none;
border: 0;
padding: 0;
text-decoration: underline;

&:hover {
cursor: pointer;
text-decoration: none;
}
}

/// Search

.nhsuk-header__search {
Expand Down
4 changes: 4 additions & 0 deletions packages/components/header/template.njk
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
<a class="nhsuk-header__account-link" href="{{ item.href }}">
{{ _accountItem(item) }}
</a>
{% elif item.action %}
<button class="nhsuk-header__account-button" formaction="{{ item.action }}" formmethod="{{ item.method or "post" }}">
{{ _accountItem(item) }}
</button>
{% else %}
{{ _accountItem(item) }}
{% endif %}
Expand Down

0 comments on commit e39fa33

Please sign in to comment.