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

fix(button menu): bring back optional --inline modifier #1270

Merged
merged 1 commit into from
Mar 11, 2025
Merged
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
2 changes: 1 addition & 1 deletion docs/examples/button-menu-grouped/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ figma_link: https://www.figma.com/file/N2xqOFkyehXwcD9DxU1gEq/MoJ-Figma-Kit?type
{%- from "govuk/components/button/macro.njk" import govukButton %}
{%- from "moj/components/button-menu/macro.njk" import mojButtonMenu -%}

<div class="moj-button-group">
<div class="moj-button-group moj-button-group--inline">
{{ govukButton({
text: "Accept booking"
}) }}
Expand Down
8 changes: 6 additions & 2 deletions src/moj/components/button-menu/_button-menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@
}

.moj-button-menu__wrapper {
position: absolute;
z-index: 10;
width: 200px;
margin: 5px 0 0; // 2px shadow, 3px gap
padding: 0;
list-style: none;

&,
.moj-button-group--inline {
position: absolute;
width: 200px;
}

&--right {
right: 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/moj/components/page-header-actions/template.njk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</div>
{% if params.items %}
<div class="moj-page-header-actions__actions">
<div class="moj-button-group">
<div class="moj-button-group moj-button-group--inline">
{% for button in params.items %}
{{ govukButton(button) }}
{% endfor %}
Expand Down
16 changes: 15 additions & 1 deletion src/moj/objects/_button-group.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
margin-bottom: 0;
}

// Set button menu to full width on mobile to match GOV.UK Frontend
@include govuk-media-query($until: tablet) {
.moj-button-menu,
.moj-button-menu__wrapper,
Expand All @@ -73,7 +74,7 @@

// On tablet and above, we also introduce a 'column gap' between the
// buttons and links in each row and left align links
@include govuk-media-query($from: tablet) {
@mixin moj-button-group-inline() {
// Cancel out the column gap for the last item in each row
margin-right: ($horizontal-gap * -1);

Expand All @@ -84,6 +85,7 @@
.govuk-button,
.govuk-link,
.moj-button-menu {
width: auto;
margin-right: $horizontal-gap;
}

Expand All @@ -95,4 +97,16 @@
text-align: left;
}
}

// Inline buttons on mobile (optional)
&--inline {
@include govuk-media-query($until: tablet) {
@include moj-button-group-inline;
}
}

// Inline buttons on tablet and desktop
@include govuk-media-query($from: tablet) {
@include moj-button-group-inline;
}
}