Skip to content

Commit cb4262e

Browse files
authored
Add aria-label and grid header on test hover (#152)
* Add aria-label for hover label * Update grid header on test hover
1 parent adbd8a6 commit cb4262e

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/components/conformance/ResultsDisplay/components/SuiteDataContainer/cards/TestGrid/index.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from "@site/src/components/conformance/types";
99
import Heading from "@theme/Heading";
1010
import styles from "./styles.module.css";
11+
import clsx from "clsx";
1112

1213
type TestsGridProps = {
1314
state: ConformanceState;
@@ -16,19 +17,23 @@ type TestsGridProps = {
1617
};
1718

1819
export default function TestsGrid(props: TestsGridProps): JSX.Element {
20+
const [hoverName, setHoverName] = React.useState<undefined | String>()
1921
const cardBodyClass = "card__body " + styles.gridStyle;
2022

23+
const title = hoverName ? "Test: " + hoverName : "Suite: " + props.suite.name;
24+
2125
return (
2226
<div className={styles.testGridCard}>
2327
<div className="card">
24-
<div className="card__header">
25-
<Heading as="h3">{props.suite.name}</Heading>
28+
<div className={clsx("card__header", styles.testGridHeader)}>
29+
<Heading as="h3">{title}</Heading>
2630
</div>
2731
<div className={cardBodyClass}>
2832
<Grid
2933
tests={props.suite.tests}
3034
esFlag={props.state.ecmaScriptVersion}
3135
selectTest={props.selectTest}
36+
setHoverValue={(name)=>setHoverName(name)}
3237
/>
3338
</div>
3439
</div>
@@ -39,7 +44,8 @@ export default function TestsGrid(props: TestsGridProps): JSX.Element {
3944
type GridProps = {
4045
tests: TestResult[];
4146
esFlag: string | null;
42-
selectTest: (string) => void;
47+
selectTest: (test: string) => void;
48+
setHoverValue: (test: string | undefined) => void;
4349
};
4450

4551
function Grid(props: GridProps): JSX.Element {
@@ -54,6 +60,7 @@ function Grid(props: GridProps): JSX.Element {
5460
key={test.strict ? test.name + "-strict" : test.name}
5561
test={test}
5662
selectTest={props.selectTest}
63+
setHoverValue={props.setHoverValue}
5764
/>
5865
);
5966
})
@@ -63,6 +70,7 @@ function Grid(props: GridProps): JSX.Element {
6370
key={test.strict ? test.name + "-strict" : test.name}
6471
test={test}
6572
selectTest={props.selectTest}
73+
setHoverValue={props.setHoverValue}
6674
/>
6775
);
6876
})}
@@ -72,7 +80,8 @@ function Grid(props: GridProps): JSX.Element {
7280

7381
type GridItemProps = {
7482
test: TestResult;
75-
selectTest: (string) => void;
83+
selectTest: (test: string) => void;
84+
setHoverValue: (test: string | undefined) => void;
7685
};
7786

7887
function GridItem(props: GridItemProps): JSX.Element {
@@ -93,6 +102,9 @@ function GridItem(props: GridItemProps): JSX.Element {
93102
<div
94103
className={testResult}
95104
onClick={() => props.selectTest(props.test.name + ".js")}
105+
onMouseEnter={(_e)=>props.setHoverValue(props.test.name + ".js")}
106+
onMouseLeave={(_e)=>props.setHoverValue(undefined)}
107+
aria-label={props.test.name}
96108
title={
97109
props.test.strict
98110
? "(strict) " + props.test.name + ".js"

src/components/conformance/ResultsDisplay/components/SuiteDataContainer/cards/TestGrid/styles.module.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,22 @@
44
padding: 0.75rem;
55
}
66

7+
.testGridHeader {
8+
height: 3.5rem;
9+
}
10+
711
@media screen and (max-width: 996px) {
812
.testGridCard {
913
margin: 0.25rem auto;
1014
padding: 0;
1115
height: 75vh;
1216
width: 90vw;
1317
}
18+
19+
.testGridHeader {
20+
height: 4.25rem;
21+
overflow: hidden;
22+
}
1423
}
1524

1625
.gridStyle {

0 commit comments

Comments
 (0)