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

Warning button variant #976

Merged
merged 4 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
22 changes: 22 additions & 0 deletions app/components/button/warning.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% set html_style = 'background-color: #f0f4f5;' %}
{% set title = 'Button warning' %}
{% from 'components/button/macro.njk' import button %}
{% extends 'layout.njk' %}

{% block body %}

<div class="nhsuk-width-container">
<main class="nhsuk-main-wrapper" id="maincontent">

<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-two-thirds">
{{ button({
"text": "Yes, delete this vaccine",
"classes": "nhsuk-button--warning"
}) }}
</div>
</div>
</main>
</div>

{% endblock %}
1 change: 1 addition & 0 deletions app/pages/examples.njk
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<li><a href="../components/button/disabled.html">Button disabled</a></li>
<li><a href="../components/button/secondary.html">Button secondary</a></li>
<li><a href="../components/button/reverse.html">Button reverse</a></li>
<li><a href="../components/button/warning.html">Button warning</a></li>
<li><a href="../components/card/basic-card.html">Card - Basic card</a></li>
<li><a href="../components/card/card-with-image.html">Card - Card with an image</a></li>
<li><a href="../components/card/card-group.html">Card - Card group</a></li>
Expand Down
25 changes: 25 additions & 0 deletions packages/components/button/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,31 @@ Find out more about the button component and when to use it in the [NHS digital

---

### Button warning

[Preview the button warning component](https://nhsuk.github.io/nhsuk-frontend/components/button/warning.html)

#### HTML markup

```html
<button class="nhsuk-button nhsuk-button--warning" type="submit" data-module="nhsuk-button">
Delete account
</button>
```

#### Nunjucks macro

```
{% from 'components/button/macro.njk' import button %}

{{ button({
"text": "Yes, delete this vaccine",
"classes": "nhsuk-button--warning"
}) }}
```

---

### Button with double click prevention

#### HTML markup
Expand Down
27 changes: 27 additions & 0 deletions packages/components/button/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,33 @@ $button-shadow-size: 4px;
}
}

.nhsuk-button--warning {
background-color: $nhsuk-warning-button-color;
box-shadow: 0 $button-shadow-size 0 $nhsuk-warning-button-shadow-color;

&:hover {
background-color: darken($nhsuk-warning-button-color, 10%);
}

&:focus {
background: $nhsuk-focus-color;
box-shadow: 0 $button-shadow-size 0 $nhsuk-focus-text-color;
color: $nhsuk-focus-text-color;
outline: $nhsuk-focus-width solid transparent;
}

&:active {
background: $nhsuk-warning-button-active-color;
box-shadow: none;
color: $nhsuk-button-text-color;
top: $button-shadow-size;
}

&.nhsuk-button--disabled {
background-color: $nhsuk-warning-button-color;
}
}

/**
* Button disabled states
*/
Expand Down
5 changes: 5 additions & 0 deletions packages/core/settings/_colours.scss
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,10 @@ $nhsuk-reverse-button-hover-color: shade($nhsuk-reverse-button-color, 20%);
$nhsuk-reverse-button-active-color: $color-nhsuk-black;
$nhsuk-reverse-button-shadow-color: $color-nhsuk-black;

$nhsuk-warning-button-color: $color_nhsuk-red;
$nhsuk-warning-button-hover-color: shade($nhsuk-warning-button-color, 20%);
$nhsuk-warning-button-active-color: shade($nhsuk-warning-button-color, 50%);
$nhsuk-warning-button-shadow-color: shade($nhsuk-warning-button-color, 50%);

$nhsuk-button-text-color: $color_nhsuk-white;
$nhsuk-reverse-button-text-color: $color_nhsuk-black;
Loading