UX: Convert alert & modal close to buttons for improved accessibility

This commit is contained in:
Kris 2019-10-28 16:04:29 -04:00
parent 3b72a36c5d
commit bacc114462
8 changed files with 46 additions and 63 deletions

View File

@ -3,11 +3,7 @@
<div class="modal-inner-container">
<div class="modal-header">
{{#if dismissable}}
<div class='modal-close'>
<a class="close" href {{action closeModal}}>
{{d-icon "times"}}
</a>
</div>
{{d-button icon="times" action=(route-action "closeModal") class="btn btn-flat modal-close close" }}
{{/if}}
{{#if panels}}

View File

@ -1,9 +1,7 @@
{{#if visible}}
<div class="row">
<div id="banner" class={{overlay}}>
<div class="close" {{action "dismiss"}}>
{{d-icon "times" title="banner.close"}}
</div>
{{d-button icon="times" action="dismiss" class="btn btn-flat close" title="banner.close"}}
<div id="banner-content">
{{{banner.html}}}
{{#if currentUser.staff}}

View File

@ -1,9 +1,7 @@
{{#if showNotificationPromptBanner}}
<div class="row">
<div class="consent_banner alert alert-info">
<div class="close" {{action "dismiss"}}>
{{d-icon 'times'}}
</div>
{{d-button icon="times" action="dismiss" class="btn btn-flat close" title="banner.close"}}
{{i18n 'user.desktop_notifications.consent_prompt'}} <a {{action "turnon"}}>{{i18n 'user.desktop_notifications.enable'}}</a>.
</div>
</div>

View File

@ -1,9 +1,7 @@
{{#if showPWAInstallBanner}}
<div class="row">
<div class="pwa-install-banner alert alert-info">
<div class="close" {{action "dismiss"}}>
{{d-icon 'times'}}
</div>
{{d-button icon="times" action="dismiss" class="btn btn-flat close" title="banner.close"}}
<span>
{{discourse-linked-text action=(action "turnOn") translatedText=(i18n "pwa.install_banner" title=siteSettings.title)}}
</span>

View File

@ -35,8 +35,7 @@
</div>
{{/if}}
<a href {{action "close"}} class="close-share" aria-label={{i18n "share.close"}} title={{i18n "share.close"}}>
{{d-icon "times"}}
</a>
{{d-button action="close" class="btn btn-flat close" icon="times" aria-label="share.close" title="share.close"}}
</div>
</div>

View File

@ -8,21 +8,12 @@
position: absolute;
top: 8px;
right: 8px;
line-height: $line-height-small;
font-size: $font-up-3;
color: $primary-low-mid;
@include hover {
color: $primary-medium;
cursor: pointer;
.d-icon {
color: $primary-low-mid;
}
}
button.close {
padding: 0;
cursor: pointer;
background: transparent;
border: 0;
-webkit-appearance: none;
}
&.alert-success {
background-color: $success-low;
color: $primary;

View File

@ -59,15 +59,11 @@
color: $primary;
min-height: unset; // ovverides button defaults
}
.discourse-no-touch & {
// only allow hover on no-touch devices
&:hover,
&.btn-hover {
background: $primary-medium;
color: $secondary;
.d-icon {
color: $secondary-very-high;
}
@include hover {
background: $primary-medium;
color: $secondary;
.d-icon {
color: $secondary-very-high;
}
}
&[disabled],
@ -104,17 +100,13 @@
&[href] {
color: $secondary;
}
.discourse-no-touch & {
// only allow hover on no-touch devices
&:hover,
&.btn-hover {
background: dark-light-choose(
scale-color($tertiary, $lightness: -20%),
scale-color($tertiary, $lightness: 20%)
);
.d-icon {
color: currentColor;
}
@include hover {
background: dark-light-choose(
scale-color($tertiary, $lightness: -20%),
scale-color($tertiary, $lightness: 20%)
);
.d-icon {
color: currentColor;
}
}
&:active,
@ -146,17 +138,13 @@
&[href] {
color: $secondary;
}
.discourse-no-touch & {
// only allow hover on no-touch devices
&:hover,
&.btn-hover {
background: dark-light-choose(
scale-color($danger, $lightness: -20%),
scale-color($danger, $lightness: 20%)
);
.d-icon {
color: $danger-low;
}
@include hover {
background: dark-light-choose(
scale-color($danger, $lightness: -20%),
scale-color($danger, $lightness: 20%)
);
.d-icon {
color: $danger-low;
}
}
&:active,
@ -266,8 +254,21 @@
.d-icon {
color: $primary-low-mid;
}
.discourse-no-touch & {
&:hover {
@include hover {
.d-icon {
color: $primary;
}
}
&.close {
padding: 0;
min-height: unset;
background: transparent;
font-size: $font-up-3;
.d-icon {
color: $primary-high;
}
@include hover {
background: transparent;
.d-icon {
color: $primary;
}

View File

@ -47,9 +47,11 @@ $breakpoints: (
// Visibility
// --------------------------------------------------
// Only shows hover on non-touch devices
@mixin hover {
.discourse-no-touch & {
&:hover {
&:hover,
&.btn-hover {
@content;
}
}