Skip to content

Accessibility Improvements #1406

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

Open
wants to merge 10 commits into
base: redesign-2024
Choose a base branch
from
3 changes: 2 additions & 1 deletion src/app/components/elements/CollapsibleList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export const CollapsibleList = (props: CollapsibleListProps) => {
className={`collapsible-body overflow-hidden ${expanded ? "open" : "closed"}`}
style={{height: expanded ? expandedHeight : 0, maxHeight: expanded ? expandedHeight : 0, marginBottom: expanded ? (props.additionalOffset ?? 0) : 0}}
>
<div ref={listRef} className={classNames({"ms-2": props.asSubList})}>
<div ref={listRef} className={classNames({"ms-2": props.asSubList})} {...{"inert": expanded ? undefined : "true"}}>
{/* when react is updated to v19, switch inert definition to regular prop */}
{props.children}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/elements/StudentDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export const StudentDashboard = ({assignments, quizAssignments, streakRecord, gr
const {assignmentsCount, quizzesCount} = getActiveWorkCount(assignments, quizAssignments);

return <div className={classNames("dashboard w-100", {"dashboard-outer": !isTutorOrAbove(user)})}>
{nameToDisplay && <span className="welcome-text">Welcome back, {nameToDisplay}!</span>}
{nameToDisplay && <h3>Welcome back, {nameToDisplay}!</h3>}
{deviceSize === "lg"
? <>
<Row>
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/elements/TeacherDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const GroupsPanel = ({ groups }: GroupsPanelProps) => {
<h4>Manage group progress</h4>
{sortedGroups.length ?
<>
<div className="overflow-hidden">
<div>
{sortedGroups.map(group => <Link key={group.id} to={`/assignment_progress#${group.id}`} className="d-block panel-my-isaac-link">{group.groupName}</Link>)}
</div>
<Spacer/>
Expand Down Expand Up @@ -175,7 +175,7 @@ export const TeacherDashboard = ({ assignmentsSetByMe, quizzesSetByMe, myAssignm

return <div className="dashboard dashboard-outer w-100">
<div className="d-flex">
{nameToDisplay && <span className="welcome-text">Welcome back, {nameToDisplay}!</span>}
{nameToDisplay && <h3>Welcome back, {nameToDisplay}!</h3>}
<span className="ms-auto">
<div className="text-center">Dashboard view</div>
<StyledToggle
Expand Down
612 changes: 318 additions & 294 deletions src/app/components/elements/layout/SidebarLayout.tsx

Large diffs are not rendered by default.

27 changes: 14 additions & 13 deletions src/app/components/elements/list-groups/AbstractListViewItem.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Link } from "react-router-dom";
import React from "react";
import { Link, LinkProps } from "react-router-dom";

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused import LinkProps.

Copilot Autofix

AI 5 days ago

To fix the issue, we will remove the unused LinkProps import from the react-router-dom package. This will clean up the code and eliminate the unnecessary import. No other changes are required since the removal of this import does not affect the functionality of the code.

Suggested changeset 1
src/app/components/elements/list-groups/AbstractListViewItem.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/app/components/elements/list-groups/AbstractListViewItem.tsx b/src/app/components/elements/list-groups/AbstractListViewItem.tsx
--- a/src/app/components/elements/list-groups/AbstractListViewItem.tsx
+++ b/src/app/components/elements/list-groups/AbstractListViewItem.tsx
@@ -1,2 +1,2 @@
-import { Link, LinkProps } from "react-router-dom";
+import { Link } from "react-router-dom";
 import React, { HTMLAttributes } from "react";
EOF
@@ -1,2 +1,2 @@
import { Link, LinkProps } from "react-router-dom";
import { Link } from "react-router-dom";
import React, { HTMLAttributes } from "react";
Copilot is powered by AI and may make mistakes. Always verify output.
import React, { HTMLAttributes } from "react";
import { StageAndDifficultySummaryIcons } from "../StageAndDifficultySummaryIcons";
import { ViewingContext} from "../../../../IsaacAppTypes";
import classNames from "classnames";
Expand Down Expand Up @@ -35,12 +35,19 @@
}
};

const LinkTags = ({linkTags}: {linkTags: {tag: string, url?: string}[];}) => {
export interface ListViewTagProps extends HTMLAttributes<HTMLElement> {
tag: string;
url?: string;
}

const LinkTags = ({linkTags}: {linkTags: ListViewTagProps[];}) => {
return <>
{linkTags.map(t => t.url ?
<Link to={t.url} className="card-tag" key={t.tag}>{t.tag}</Link> :
<div className="card-tag" key={t.tag}>{t.tag}</div>
)}
{linkTags.map(t => {
const {url, tag, ...rest} = t;
return url ?
<Link {...rest} to={url} className="card-tag" key={tag}>{tag}</Link> :
<div {...rest} className="card-tag" key={tag}>{tag}</div>;
})}
</>;
};

Expand All @@ -55,12 +62,6 @@
{quizButton}
</span>;
};

export interface ListViewTagProps {
tag: string;
url?: string;
}

export interface AbstractListViewItemProps extends ListGroupItemProps {
title: string;
icon?: TitleIconProps;
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/site/cs/FooterCS.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const FooterCS = () => (
<Container fluid className="py-5">
<Row className="justify-content-start">
<Col xs={"auto"} className={"me-5 mb-4 mb-md-0"}>
<Link to="/">
<Link to="/" className="d-block">
<img
src="/assets/common/logos/ada_logo_stamp_aqua.svg"
className="footer-logo"
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/site/cs/HomepageCS.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ export const HomepageCS = () => {
</h1>
<Row className="justify-content-start align-items-center my-3">
<Col xs={6} sm={3}>
<a href="https://www.cam.ac.uk/" target="_blank" rel="noopener">
<a href="https://www.cam.ac.uk/" target="_blank" rel="noopener" className="d-block">
<img src="/assets/common/logos/university_of_cambridge.svg" alt='University of Cambridge website' className='img-fluid footer-org-logo' />
</a>
</Col>
<Col xs={6} sm={3}>
<a href="https://www.raspberrypi.org/" target="_blank" rel="noopener">
<a href="https://www.raspberrypi.org/" target="_blank" rel="noopener" className="d-block">
<img src="/assets/common/logos/ada_rpf_icon.svg" alt='Raspberry Pi website' className='img-fluid footer-org-logo' />
</a>
</Col>
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/site/phy/HomepagePhy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const getListViewSubjectCard = (sc: subjectCategory) => {
item: item,
icon: {type: "img", icon: `/assets/phy/icons/redesign/subject-${sc.subject}.svg`},
subject: sc.subject as Subject,
linkTags: sc.subcategories.map((subcat) => ({tag: subcat.humanStage, url: subcat.href})),
linkTags: sc.subcategories.map((subcat) => ({tag: subcat.humanStage, url: subcat.href, "aria-label": `Explore ${subcat.humanStage} ${sc.humanSubject}`})),
};

return listViewSubjectCard;
Expand Down
14 changes: 11 additions & 3 deletions src/scss/common/accessibility.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@
@include reduced-motion-compliant-animation;
}

#main {
// default values for all accessibility variables
--focus-outline: 2px solid #000; // TODO use this
@mixin focus-outline($color: var(--focus-outline-color), $width: var(--focus-outline-width)) {
// see https://stackoverflow.com/a/52616313
box-shadow: 0px 0px 0px var(--focus-outline-width) var(--focus-outline-color);

outline: $width solid transparent;
}

:root {
// default values for all accessibility variables; override as needed in /phy/accessibility.scss and /ada/accessibility.scss
--focus-outline-color: #000;
--focus-outline-width: 0.2rem;
}
3 changes: 0 additions & 3 deletions src/scss/common/assignments.scss
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,5 @@
&:focus {
outline: none;
}
&:focus-visible {
outline: 3px solid black;
}
}
}
5 changes: 0 additions & 5 deletions src/scss/common/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@
button {
-webkit-appearance: none;
border: none;
outline: none !important;
}

.btn.btn-primary:focus-visible, .btn.btn-outline-primary:focus-visible {
background-color: unset !important;
}

.btn-close {
Expand Down
3 changes: 1 addition & 2 deletions src/scss/common/elements.scss
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,7 @@ iframe.email-html {
}

&:has(> input:focus-visible) {
// TODO: find-replace all instances of this with some SCSS vars defined in isaac.scss
box-shadow: 0 0 0 2pt black !important;
@include focus-outline;
}

&:focus:not(:focus-visible) {
Expand Down
84 changes: 5 additions & 79 deletions src/scss/common/focus.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,78 +4,6 @@
border-color: $gray-160;
}

/** Focus styles **/

.form-control:focus, .form-select:focus {
box-shadow: none;
outline: 0.2rem solid $focus-blue;
}

.form-control-file:focus {
outline: none;
border: 0.2rem solid $focus-blue;
border-radius: 5px;
}

.form-check-input:focus {
outline: 0.2rem solid $focus-blue;
}

.page-link:focus {
box-shadow: none;
border: 0.2rem solid $focus-blue;
border-radius: 3px;
}

.navbar-toggler:focus {
box-shadow: none;
border: 0.2rem solid $focus-blue;
border-radius: 3px;
}

.link-list.a:focus {
box-shadow: none !important;
outline: 0.2rem solid $focus-blue !important;
}

.navbar-toggler:focus {
box-shadow: none;
outline: 0.2rem solid $black;
}

.nav-link.active:focus {
box-shadow: none;
outline: 0.2rem solid $secondary;
}

.book-chapter:focus {
box-shadow: 0 0 0 2pt black !important;
border-radius: 1px;
outline: none !important;
}

.nav-link:focus {
box-shadow: 0 0 0 2pt black !important;
border-radius: 1px;
outline: none !important;
}

.book-link:focus {
box-shadow: 0 0 0 2pt black !important;
border-radius: 0;
outline: none !important;
}

.login-b:focus {
box-shadow: none;
border: 0.2rem solid $focus-blue;
}

// Close modal button
.close:not(:disabled):not(.disabled):focus {
box-shadow: none;
outline: 0.2rem solid $focus-blue;
}

::placeholder { // Firefox, Chrome, Opera
color: $gray-160 !important;
Expand All @@ -89,13 +17,11 @@
color: $gray-160 !important;
}

:focus {
outline: 0.2rem solid $black;
:focus-visible:not([tabindex="-1"]):not(.select__input) {
@include focus-outline;
}

// TODO: Review blanket suppression of focus indicator on keyboard-unfocusable elements.
[tabindex="-1"]:focus {
outline: 0 !important;
:focus-visible[tabindex="-1"] {
// remove UA styling too
outline: none;
}

/** End of focus styles **/
6 changes: 0 additions & 6 deletions src/scss/common/scroll.scss
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,3 @@
}
}
}

.expand-button > button:focus-visible {
div {
outline: 0.1rem solid #000 !important;
}
}
6 changes: 6 additions & 0 deletions src/scss/cs/accessibility.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@import '../common/accessibility';

:root {
--focus-outline-color: #{$focus-blue};
--focus-outline-width: 2px;
}
1 change: 0 additions & 1 deletion src/scss/cs/boards.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
outline: none !important;
border: none !important;
&:focus-visible {
outline: 2px solid $focus-blue !important;
border-radius: 50px !important;
}
}
Expand Down
21 changes: 0 additions & 21 deletions src/scss/cs/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,13 @@
background-color: $active-color !important;
box-shadow: none !important;
}
&:focus:not(.disabled) {
box-shadow: none;
}
&:focus-visible {
box-shadow: 0 0 0 3px $focus-blue !important;
}
&.disabled, &:disabled {
color: $cs-jet;
background-color: $cs-silver;
border-color: $cs-silver;
}
}

.btn.btn-link:focus {
box-shadow: 0 0 0 0.2rem $focus-blue !important;
outline: none !important;
border-radius: 3px;
}

@mixin ada-button-outline($color, $hover-color, $active-color) {
background-color: transparent;
border: 3px solid $color;
Expand All @@ -56,12 +44,6 @@
background-color: transparent !important;
box-shadow: none !important;
}
&:focus:not(.disabled) {
box-shadow: none;
}
&:focus-visible {
box-shadow: 0 0 0 3px $focus-blue !important;
}
&.disabled, &:disabled {
color: $cs-jet;
border-color: $cs-silver;
Expand Down Expand Up @@ -132,7 +114,6 @@
background: none !important;
border: none !important;
border-radius: 0 !important;
box-shadow: none !important;
}
}

Expand All @@ -147,7 +128,6 @@
color: $light-active-dark-pink;
}
&:focus-visible {
outline: 2px solid $focus-blue !important;
border-radius: 0 !important;
z-index: 10;
}
Expand Down Expand Up @@ -303,7 +283,6 @@ a:not(.btn):not(.nav-link) {
outline: none;
}
&:focus-visible {
outline: 2px solid $focus-blue;
border-radius: 0 !important;
z-index: 10;
}
Expand Down
6 changes: 3 additions & 3 deletions src/scss/cs/header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ div.header-progress {
.navbar-toggler {
padding: 0.25rem;
&:focus-visible {
border-color: $cyan-300;
border-radius: 0;
}
&:focus:not(:focus-visible) {
Expand Down Expand Up @@ -54,7 +53,6 @@ div.header-progress {
background: none;
&:focus-visible {
box-sizing: content-box;
border: 0.2rem solid $cyan-300;
border-radius: 0;
}
&:focus:not(:focus-visible) {
Expand All @@ -75,6 +73,8 @@ header {
position: relative;
z-index: 20;

--focus-outline-color: #{$cyan-300};

a:not(.navbar-brand), .nav-link {
text-decoration: none !important;
color: $cs-white;
Expand All @@ -99,7 +99,7 @@ header {
top: 0;
left: 0;
height: 100%;
border: $cyan-300 solid 2px;
@include focus-outline;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/scss/cs/isaac.scss
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ $enable-negative-margins: true;
@import "../common/_utils";

// Theming
@import "../common/accessibility";
@import "accessibility";

// Atoms
@import "fonts";
Expand Down
Loading
Loading