Simplify HTML in proposal/debates recommendations

This way it's going to be easier to style the link on focus, since
styles like `box-shadow` weren't working properly when we had an inline
link with block elements inside, and adding the `display: inline-block`
element to the link didn't play well with the layout we were using for
the recommendations.

We're also fixing the focus outline on recommendations, which didn't
look properly because of the border added with:

```
.recommended-index {
  // (...)
  @include full-width-border(top, 1px solid #fafafa);
}
```

The border was on top of the outline, breaking it. Increasing the
`z-index` of the element containing the outline solves the issue.

In a similar way, we're making sure the button to hide recommendations
stays visible so it's easier to click it.
This commit is contained in:
Javi Martín
2023-09-25 21:47:14 +02:00
parent d874697310
commit f285dfcbac
4 changed files with 34 additions and 28 deletions

View File

@@ -9,13 +9,13 @@
.heading { .heading {
@include brand-color; @include brand-color;
@include card;
border: 2px solid $border; border: 2px solid $border;
border-radius: rem-calc(6); border-radius: rem-calc(6);
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1); box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
margin-bottom: $line-height / 2; margin-bottom: $line-height / 2;
margin-top: $line-height / 4; margin-top: $line-height / 4;
padding: $line-height / 2; padding: $line-height / 2;
position: relative;
width: 100%; width: 100%;
@include breakpoint(medium) { @include breakpoint(medium) {
@@ -26,31 +26,9 @@
width: calc(100% / 6 - #{$spacing}); width: calc(100% / 6 - #{$spacing});
} }
&:focus-within {
outline: $outline-focus;
a:focus {
outline: none;
}
}
a { a {
font-weight: bold; font-weight: bold;
&::after,
&::before {
bottom: 0;
content: "";
left: 0;
position: absolute;
right: 0;
top: 0;
}
&:hover {
text-decoration: none;
}
&:hover::before { &:hover::before {
background: $light; background: $light;
z-index: -1; z-index: -1;

View File

@@ -1986,11 +1986,13 @@ table {
} }
.recommendation { .recommendation {
@include card;
background: $body-background; background: $body-background;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.15); box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.15);
display: block; display: block;
margin-bottom: $line-height / 4; margin-bottom: $line-height / 4;
padding: $line-height / 2; padding: $line-height / 2;
z-index: 1;
&:hover { &:hover {
box-shadow: 0 4px 6px 0 rgba(0, 0, 0, 0.15); box-shadow: 0 4px 6px 0 rgba(0, 0, 0, 0.15);
@@ -2003,6 +2005,7 @@ table {
position: absolute; position: absolute;
right: 12px; right: 12px;
top: -18px; top: -18px;
z-index: 2;
} }
// 20. Documents // 20. Documents

View File

@@ -0,0 +1,27 @@
@mixin card {
position: relative;
&:focus-within {
outline: $outline-focus;
a:focus {
outline: none;
}
}
a {
&::after,
&::before {
bottom: 0;
content: "";
left: 0;
position: absolute;
right: 0;
top: 0;
}
&:hover {
text-decoration: none;
}
}
}

View File

@@ -18,11 +18,9 @@
<% recommended.each_with_index do |recommended, index| %> <% recommended.each_with_index do |recommended, index| %>
<div class="small-12 medium-6 large-4 column end"> <div class="small-12 medium-6 large-4 column end">
<%= link_to recommended_path(recommended) do %>
<div class="recommendation" data-equalizer-watch> <div class="recommendation" data-equalizer-watch>
<h3><%= recommended.title %></h3> <h3><%= link_to recommended.title, recommended_path(recommended) %></h3>
</div> </div>
<% end %>
</div> </div>
<% end %> <% end %>