Merge pull request #5255 from consuldemocracy/focus_contrast

Increase links and buttons contrast on focus
This commit is contained in:
Javi Martín
2023-10-10 15:31:55 +02:00
committed by GitHub
19 changed files with 144 additions and 70 deletions

View File

@@ -115,7 +115,11 @@ $color-alert: #a94442 !default;
$pdf-primary: #0300ff !default; $pdf-primary: #0300ff !default;
$pdf-secondary: #ff9e00 !default; $pdf-secondary: #ff9e00 !default;
$outline-focus: 3px solid #ffbf47 !default; $focus-middle: #ffbf47 !default;
$focus-outer: $brand !default;
$focus-inner-width: 1px !default;
$focus-middle-width: 3px !default;
$focus-outer-width: 2px !default;
$input-height: $line-height * 2 !default; $input-height: $line-height * 2 !default;

View File

@@ -42,8 +42,8 @@
&:focus, &:focus,
&:hover { &:hover {
@include brand-background; @include brand-background;
@include no-outline;
text-decoration: none; text-decoration: none;
outline: none;
} }
} }
} }

View File

@@ -112,9 +112,6 @@
} }
li { li {
margin: 0;
outline: 0;
ul { ul {
margin-left: $line-height / 1.5; margin-left: $line-height / 1.5;
border-left: 1px solid $sidebar-hover; border-left: 1px solid $sidebar-hover;

View File

@@ -40,8 +40,6 @@
span { span {
color: inherit; color: inherit;
outline: 0;
text-decoration: none;
} }
} }
} }

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

@@ -82,7 +82,7 @@
} }
&:focus { &:focus {
outline: none; @include no-outline;
} }
&[aria-selected="true"], &[aria-selected="true"],

View File

@@ -102,20 +102,20 @@ button,
[type="button"], [type="button"],
[type="submit"] { [type="submit"] {
&:focus { &:focus {
outline: $outline-focus; @include focus-outline;
} }
&:focus-visible { &:focus-visible {
outline: $outline-focus; @include focus-outline;
} }
&:focus:not(:focus-visible) { &:focus:not(:focus-visible) {
outline: none; @include no-outline;
} }
&:active, &:active,
&:focus:active { &:focus:active {
outline: $outline-focus; @include focus-outline;
} }
} }
@@ -1135,6 +1135,7 @@ form {
.notification-link { .notification-link {
@include text-colored-link; @include text-colored-link;
display: inline-block;
} }
&:hover { &:hover {
@@ -1986,13 +1987,15 @@ 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:not(:focus-within) {
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 +2006,7 @@ table {
position: absolute; position: absolute;
right: 12px; right: 12px;
top: -18px; top: -18px;
z-index: 2;
} }
// 20. Documents // 20. Documents
@@ -2216,7 +2220,7 @@ table {
} }
} }
a:hover { a:hover:not(:focus) {
box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.2); box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.2);
text-decoration: none; text-decoration: none;

View File

@@ -36,11 +36,13 @@
outline: none; outline: none;
padding-left: $line-height / 4; padding-left: $line-height / 4;
padding-right: calc(#{$line-height / 4} + 1em); padding-right: calc(#{$line-height / 4} + 1em);
transition: none;
width: auto; width: auto;
&:focus { &:focus {
@include focus-outline;
border: 0; border: 0;
outline: $outline-focus; transition: none;
} }
option { option {

View File

@@ -57,6 +57,7 @@
h3 a { h3 a {
color: inherit; color: inherit;
display: inline-block;
margin-bottom: 1rem; margin-bottom: 1rem;
} }
} }

View File

@@ -0,0 +1,80 @@
@mixin focus-outline {
$total-width: $focus-inner-width + $focus-middle-width + $focus-outer-width;
box-shadow: 0 0 0 $total-width $focus-outer;
outline: $focus-middle-width solid $focus-middle;
outline-offset: $focus-inner-width;
}
@mixin no-outline {
box-shadow: none;
outline: none;
}
@mixin focus-outline-on-img {
&:focus {
@include no-outline;
img {
@include focus-outline;
}
}
&:focus-visible {
@include no-outline;
img {
@include focus-outline;
}
}
&:focus:not(:focus-visible) {
img {
@include no-outline;
}
}
&:active {
@include no-outline;
img {
@include focus-outline;
}
}
&:focus:active {
@include no-outline;
img {
@include focus-outline;
}
}
}
@mixin card {
position: relative;
&:focus-within {
@include focus-outline;
a:focus {
@include no-outline;
}
}
a {
&::after,
&::before {
bottom: 0;
content: "";
left: 0;
position: absolute;
right: 0;
top: 0;
}
&:hover {
text-decoration: none;
}
}
}

View File

@@ -24,6 +24,10 @@
a:hover .sdg-goal-icon { a:hover .sdg-goal-icon {
filter: brightness(90%); filter: brightness(90%);
} }
a {
@include focus-outline-on-img;
}
} }
%sdg-goal-list { %sdg-goal-list {
@@ -47,12 +51,8 @@
width: 100%; width: 100%;
} }
a:focus { a {
outline: none; @include focus-outline-on-img;
img {
outline: $outline-focus;
}
} }
} }
} }

View File

@@ -22,7 +22,7 @@
} }
&:focus-within label { &:focus-within label {
outline: $outline-focus; @include focus-outline;
} }
} }

View File

@@ -464,6 +464,7 @@
a { a {
color: inherit; color: inherit;
display: inline-block;
} }
} }
@@ -1284,6 +1285,7 @@
} }
.budget-execution { .budget-execution {
@include card;
border: 1px solid $border; border: 1px solid $border;
overflow: hidden; overflow: hidden;
position: relative; position: relative;
@@ -1332,7 +1334,7 @@
font-size: rem-calc(24); font-size: rem-calc(24);
} }
&:hover { &:hover:not(:focus-within) {
box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.2); box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.2);
} }
} }
@@ -1595,6 +1597,7 @@
a { a {
color: inherit; color: inherit;
display: inline-block;
} }
} }
} }

View File

@@ -0,0 +1,5 @@
.proposals-geozones {
a {
@include focus-outline-on-img;
}
}

View File

@@ -7,7 +7,7 @@
li { li {
&:focus { &:focus {
outline: $outline-focus; @include focus-outline;
} }
} }
} }

View File

@@ -34,7 +34,7 @@
@include element-invisible; @include element-invisible;
&:focus + label { &:focus + label {
outline: $outline-focus; @include focus-outline;
} }
&:checked + label img { &:checked + label img {

View File

@@ -1,6 +1,9 @@
<div class="sidebar-divider"></div> <div class="sidebar-divider"></div>
<div class="proposals-geozones">
<h2 class="sidebar-title"><%= t("shared.tags_cloud.districts") %></h2> <h2 class="sidebar-title"><%= t("shared.tags_cloud.districts") %></h2>
<br> <br>
<%= link_to map_proposals_path, id: "map", title: t("shared.tags_cloud.districts_list") do %> <%= link_to map_proposals_path, id: "map", title: t("shared.tags_cloud.districts_list") do %>
<%= image_tag(image_path_for("map.jpg"), alt: t("shared.tags_cloud.districts_list")) %> <%= image_tag(image_path_for("map.jpg"), alt: t("shared.tags_cloud.districts_list")) %>
<% end %> <% end %>
</div>

View File

@@ -5,19 +5,20 @@
<div class="row" data-equalizer-on="medium" data-equalizer> <div class="row" data-equalizer-on="medium" data-equalizer>
<% investments.each do |investment| %> <% investments.each do |investment| %>
<div class="small-12 medium-6 large-4 column end margin-bottom"> <div class="small-12 medium-6 large-4 column end margin-bottom">
<div class="budget-execution"> <div class="budget-execution" data-equalizer-watch>
<%= link_to budget_investment_path(@budget, investment, anchor: "tab-milestones"), data: { "equalizer-watch": true } do %>
<%= render Budgets::Executions::ImageComponent.new(investment) %> <%= render Budgets::Executions::ImageComponent.new(investment) %>
<div class="budget-execution-info"> <div class="budget-execution-info">
<div class="budget-execution-content"> <div class="budget-execution-content">
<h5><%= investment.title %></h5> <h5>
<%= link_to investment.title,
budget_investment_path(@budget, investment, anchor: "tab-milestones") %>
</h5>
<span class="author"><%= investment.author.name %></span> <span class="author"><%= investment.author.name %></span>
</div> </div>
<p class="price margin-top text-center"> <p class="price margin-top text-center">
<strong><%= investment.formatted_price %></strong> <strong><%= investment.formatted_price %></strong>
</p> </p>
</div> </div>
<% end %>
</div> </div>
</div> </div>
<% end %> <% end %>

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 %>