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

Rework clickable cards using CSS invisible overlay rather than JS event handler #762

Merged
merged 17 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
:wrench: **Fixes**

- Transactional header defaults to wrapping underneath the logo without the need for a modifier ([Issue 720](https://github.com/nhsuk/nhsuk-frontend/issues/720)).
- Rework clickable cards using CSS invisible overlay rather than JS event handler to avoid problems with using Ctrl-click, middle click, right click to open new tabs ([PR 762](https://github.com/nhsuk/nhsuk-frontend/pull/762))

## 5.1.0 - 14 May 2021

Expand Down
12 changes: 0 additions & 12 deletions packages/components/card/card.js

This file was deleted.

29 changes: 13 additions & 16 deletions packages/components/card/card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
========================================================================== */

/**
* 1. Is needed for the :active top positioning.
* 1. Is needed for the :active top positioning, and invisible clickable overlay.
* 2. Border is used to create a divider between the white content
* box and an image.
* 3. Creates the 'pressed down' effect when clicked.
* 4. Removes padding-top from headings directly after the card group.
* 5. Includes the border width to achieve the correct left alignment.
* 6. Stops the heading from spanning the full width of the card.
* 7. Removes padding top for the feature heading positioning.
* 8. Trick IE10 into rendering the invisible clickable area. Without this it does not.
*/

$card-border-width: 1px;
Expand Down Expand Up @@ -38,8 +39,6 @@ $card-border-hover-color: $color_nhsuk-grey-3;
.nhsuk-card__content {
@include top-and-bottom();
@include nhsuk-responsive-padding(5);

position: relative;
}

.nhsuk-card__heading,
Expand All @@ -54,20 +53,18 @@ $card-border-hover-color: $color_nhsuk-grey-3;
.nhsuk-card--clickable {
border-bottom-width: $card-border-bottom-width;

&:hover,
&:active {
cursor: pointer;

.nhsuk-card__heading a,
.nhsuk-card__link {
color: $nhsuk-link-hover-color;
text-decoration: none;

&:focus {
color: $nhsuk-focus-text-color;
}
.nhsuk-card__heading a,
.nhsuk-card__link {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrimesdev I've put both these selectors in here in order to be consistent with what came before. Is this still necessary? I assume it's backwards compatibility before the .nhsuk-card__link class was added

&::before {
background-color: rgba(255, 255, 255, 0); /* [8] */
bottom: 0;
content: '';
display: block;
left: 0;
position: absolute;
right: 0;
top: 0;
}

}

&:hover {
Expand Down
2 changes: 0 additions & 2 deletions packages/nhsuk.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Components
import Card from './components/card/card';
import Checkboxes from './components/checkboxes/checkboxes';
import Details from './components/details/details';
import ErrorSummary from './components/error-summary/error-summary';
Expand All @@ -11,7 +10,6 @@ import './polyfills';

// Initialize components
document.addEventListener('DOMContentLoaded', () => {
Card();
Checkboxes();
Details();
ErrorSummary();
Expand Down