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

[A11Y] Replace invalid link elements with buttons #3021

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
10 changes: 7 additions & 3 deletions js/src/forum/components/DiscussionListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,13 @@ export default class DiscussionListItem extends Component {
text={app.translator.trans('core.forum.discussion_list.started_text', { user, ago: humanTime(discussion.createdAt()) })}
position="right"
>
<Link className="DiscussionListItem-author" href={user ? app.route.user(user) : '#'}>
{avatar(user, { title: '' })}
</Link>
{user ? (
<Link className="DiscussionListItem-author" href={app.route.user(user)}>
{avatar(user, { title: '' })}
</Link>
) : (
<span className="DiscussionListItem-author">{avatar(user, { title: '' })}</span>
)}
</Tooltip>

<ul className="DiscussionListItem-badges badges">{listItems(discussion.badges().toArray())}</ul>
Expand Down
10 changes: 8 additions & 2 deletions js/src/forum/components/LogInModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,17 @@ export default class LogInModal extends Modal {
footer() {
return [
<p className="LogInModal-forgotPassword">
<a onclick={this.forgotPassword.bind(this)}>{app.translator.trans('core.forum.log_in.forgot_password_link')}</a>
<Button class="Button Button--reset" onclick={this.forgotPassword.bind(this)}>
{app.translator.trans('core.forum.log_in.forgot_password_link')}
</Button>
</p>,

app.forum.attribute('allowSignUp') ? (
<p className="LogInModal-signUp">{app.translator.trans('core.forum.log_in.sign_up_text', { a: <a onclick={this.signUp.bind(this)} /> })}</p>
<p className="LogInModal-signUp">
{app.translator.trans('core.forum.log_in.sign_up_text', {
a: <Button class="Button Button--reset" onclick={this.signUp.bind(this)} />,
Comment on lines +128 to +136
Copy link
Member

Choose a reason for hiding this comment

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

these look weird as well, colored with no effect on hover, the underline hovering effect of the link was nice.
perhaps we should add a new Button--textlink that would mimic an exact link?

})}
</p>
) : (
''
),
Expand Down
5 changes: 3 additions & 2 deletions js/src/forum/components/PostMeta.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Component from '../../common/Component';
import humanTime from '../../common/helpers/humanTime';
import fullTime from '../../common/helpers/fullTime';
import Button from '../../common/components/Button';

/**
* The `PostMeta` component displays the time of a post, and when clicked, shows
Expand Down Expand Up @@ -28,9 +29,9 @@ export default class PostMeta extends Component {

return (
<div className="Dropdown PostMeta">
<a className="Dropdown-toggle" onclick={selectPermalink} data-toggle="dropdown">
<Button className="Button Button--reset Dropdown-toggle" onclick={selectPermalink} data-toggle="dropdown">
Copy link
Member

Choose a reason for hiding this comment

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

the timestamp looks colored at all times, can we instead use Button--text here and just add a vertical-align: bottom; to .Button--text ? it's a lot more consistent.

{humanTime(time)}
</a>
</Button>

<div className="Dropdown-menu dropdown-menu">
<span className="PostMeta-number">{app.translator.trans('core.forum.post.number_tooltip', { number: post.number() })}</span>{' '}
Expand Down
9 changes: 5 additions & 4 deletions js/src/forum/components/PostStreamScrubber.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Component from '../../common/Component';
import Button from '../../common/components/Button';
import icon from '../../common/helpers/icon';
import formatNumber from '../../common/utils/formatNumber';
import ScrollListener from '../../common/utils/ScrollListener';
Expand Down Expand Up @@ -61,9 +62,9 @@ export default class PostStreamScrubber extends Component {

<div className="Dropdown-menu dropdown-menu">
<div className="Scrubber">
<a className="Scrubber-first" onclick={this.goToFirst.bind(this)}>
<Button className="Button Button--reset Scrubber-first" onclick={this.goToFirst.bind(this)}>
{icon('fas fa-angle-double-up')} {app.translator.trans('core.forum.post_scrubber.original_post_link')}
</a>
</Button>

<div className="Scrubber-scrollbar">
<div className="Scrubber-before" />
Expand All @@ -81,9 +82,9 @@ export default class PostStreamScrubber extends Component {
</div>
</div>

<a className="Scrubber-last" onclick={this.goToLast.bind(this)}>
<Button className="Button Button--reset Scrubber-last" onclick={this.goToLast.bind(this)}>
{icon('fas fa-angle-double-down')} {app.translator.trans('core.forum.post_scrubber.now_link')}
</a>
</Button>
</div>
</div>
</div>
Expand Down
10 changes: 6 additions & 4 deletions js/src/forum/components/SignUpModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ export default class SignUpModal extends Modal {
/**
* The value of the username input.
*
* @type {Function}
* @type {Stream<string>}
*/
this.username = Stream(this.attrs.username || '');

/**
* The value of the email input.
*
* @type {Function}
* @type {Stream<string>}
*/
this.email = Stream(this.attrs.email || '');

/**
* The value of the password input.
*
* @type {Function}
* @type {Stream<string>}
*/
this.password = Stream(this.attrs.password || '');
}
Expand Down Expand Up @@ -127,7 +127,9 @@ export default class SignUpModal extends Modal {

footer() {
return [
<p className="SignUpModal-logIn">{app.translator.trans('core.forum.sign_up.log_in_text', { a: <a onclick={this.logIn.bind(this)} /> })}</p>,
<p className="SignUpModal-logIn">
{app.translator.trans('core.forum.sign_up.log_in_text', { a: <Button class="Button Button--reset" onclick={this.logIn.bind(this)} /> })}
</p>,
];
}

Expand Down
38 changes: 27 additions & 11 deletions less/common/Button.less
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
&:active,
&.active,
.open > &.Dropdown-toggle {
.box-shadow(inset 0 3px 5px rgba(0, 0, 0, .125));
box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
outline: none;
}

Expand All @@ -77,7 +77,7 @@
fieldset[disabled] & {
cursor: default;
opacity: 0.65;
.box-shadow(none);
box-shadow: none;
}

a& {
Expand Down Expand Up @@ -121,7 +121,6 @@
}
}


.Button--square {
padding-left: 9px;
padding-right: 9px;
Expand All @@ -134,20 +133,37 @@
border-radius: 18px;
}
.Button--link {
background: transparent !important;
color: @control-color;
background: none;

&:hover {
background: transparent !important;
&:active,
&:hover,
&:focus {
color: @link-color;
box-shadow: none;
background: none;
}
}
.Button--reset {
padding: 0;
margin: 0;
display: inline;
text-align: unset;
color: @link-color;
background: none;
vertical-align: unset;
white-space: unset;
line-height: unset;
.user-select(auto);
width: auto !important;

&:active,
&.active,
&:hover,
&:focus,
&.focus,
Copy link
Member

Choose a reason for hiding this comment

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

Won't moving these styles from --link to --reset be breaking if the button doesn't update to use --reset with a dropdown toggle? Is it a big deal?

.open > &.Dropdown-toggle {
background: transparent !important;
.box-shadow(none);
color: @link-color;
box-shadow: none;
background: none;
}
}
.Button--text {
Expand All @@ -162,7 +178,7 @@
&:active,
&.active,
.open > &.Dropdown-toggle {
.box-shadow(none);
box-shadow: none;
}
}
.Button--primary {
Expand Down
18 changes: 15 additions & 3 deletions less/forum/Scrubber.less
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@
font-size: 14px;
margin-right: 2px;
}
&:hover, &:focus {
&:hover,
&:focus {
text-decoration: none;
color: @link-color;
}
}

&-first,
&-last {
color: @control-color;
}
}
.Scrubber-scrollbar {
margin: 8px 0 8px 3px;
Expand All @@ -21,14 +27,20 @@
cursor: pointer;
.user-select(none);
}
.Scrubber-before, .Scrubber-after {
.Scrubber-before,
.Scrubber-after {
border-left: 1px solid @control-bg;
}
.Scrubber-unread {
position: absolute;
border-left: 1px solid lighten(@muted-color, 10%);
width: 100%;
background-image: linear-gradient(to right, @control-bg, fade(@control-bg, 0) 10px, fade(@control-bg, 0));
background-image: linear-gradient(
to right,
@control-bg,
fade(@control-bg, 0) 10px,
fade(@control-bg, 0)
);
display: flex;
align-items: center;
color: @muted-color;
Expand Down