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

Fix basic accessibility issues #62

Merged
merged 8 commits into from
Feb 22, 2023
Merged
15 changes: 12 additions & 3 deletions settings/src/components/account-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* WordPress dependencies
*/
import { Card, CardBody } from '@wordpress/components';
import { useContext } from '@wordpress/element';
import { useContext, useState } from '@wordpress/element';
import { Icon, cancelCircleFilled, check, chevronRight, warning } from '@wordpress/icons';

/**
Expand Down Expand Up @@ -65,9 +65,16 @@ export default function AccountStatus() {
/**
* Render a card for the status of the given setting.
*/
function SettingStatusCard( { screen, status, headerText, bodyText } ) {
function SettingStatusCard({ screen, status, headerText, bodyText }) {
const [ isFocused, setIsFocused ] = useState( false );
const className = [
"wporg-2fa__status-card",
"wporg-2fa__status-card-" + screen,
...( isFocused ? [ "wporg-2fa__status-card__focused" ] : [] ),
adamwoodnz marked this conversation as resolved.
Show resolved Hide resolved
].join( " " );

return (
<Card className={ 'wporg-2fa__status-card wporg-2fa__status-card-' + screen }>
<Card className={ className }>
<ScreenLink
screen={ screen }
anchorText={
Expand All @@ -78,6 +85,8 @@ function SettingStatusCard( { screen, status, headerText, bodyText } ) {
<Icon icon={ chevronRight } size={ 26 } className="wporg-2fa__status-card-open" />
</CardBody>
}
onFocus={ () => setIsFocused( true ) }
onBlur={ () => setIsFocused( false ) }
/>
</Card>
);
Expand Down
12 changes: 12 additions & 0 deletions settings/src/components/account-status.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
.wporg-2fa__account-status {
.wporg-2fa__status-card {
&:hover,
&.wporg-2fa__status-card__focused {
z-index: 1;
}

a {
display: block;
text-decoration: none;

&:hover,
&:focus {
outline: 1px solid var(--wp-admin-theme-color);
outline-offset: 0;
}
}

.components-card__body {
Expand Down
11 changes: 10 additions & 1 deletion settings/src/components/screen-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ import { useContext } from '@wordpress/element';
*/
import { GlobalContext } from '../script';

export default function ScreenLink( { screen, anchorText, buttonStyle = false } ) {
export default function ScreenLink( {
screen,
anchorText,
buttonStyle = false,
onFocus = () => {},
onBlur = () => {},
} ) {
const { clickScreenLink } = useContext( GlobalContext );
const classes = [];
let screenUrl = new URL( document.location.href );
Expand All @@ -28,6 +34,9 @@ export default function ScreenLink( { screen, anchorText, buttonStyle = false }
href={ screenUrl.href }
onClick={ ( event ) => clickScreenLink( event, screen ) }
className={ classes.join( ' ' ) }
tabIndex={ 0 }
iandunn marked this conversation as resolved.
Show resolved Hide resolved
onFocus={ () => onFocus() }
onBlur={ () => onBlur() }
>
{ anchorText }
</a>
Expand Down