Skip to content

Commit 63616a6

Browse files
katiekleinkatiegoineshbuchel
authored
a11y- Use nested list for <h3> links within the table of contents (#7883)
--------- Co-authored-by: katiegoines <[email protected]> Co-authored-by: Heather <[email protected]>
1 parent d1f94e8 commit 63616a6

File tree

54 files changed

+259
-214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+259
-214
lines changed

src/components/Layout/Layout.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,15 @@ export const Layout = ({
149149

150150
pageHeadings.forEach((node) => {
151151
const { innerText, id, localName } = node as HTMLElement;
152-
if (innerText && id && (localName == 'h2' || localName == 'h3')) {
152+
if (innerText && id && localName == 'h2') {
153153
headings.push({
154+
linkText: innerText,
155+
hash: id,
156+
level: localName,
157+
subheadings: []
158+
});
159+
} else if (innerText && id && localName == 'h3') {
160+
headings[headings.length - 1].subheadings.push({
154161
linkText: innerText,
155162
hash: id,
156163
level: localName

src/components/TableOfContents/TableOfContents.tsx

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export interface HeadingInterface {
44
linkText: string;
55
hash: string;
66
level: string;
7+
subheadings: Array<object>;
78
}
89
interface TableOfContents {
910
headers?: HeadingInterface[];
@@ -21,20 +22,57 @@ export const TableOfContents = ({ headers }) => {
2122
)}
2223
<View as="ul" className="toc-list">
2324
{headers.map(({ linkText, hash, level }, index) => {
24-
return (
25-
<View
26-
as="li"
27-
className={`toc-item toc-item--${level}`}
28-
key={`toc-${index}`}
29-
>
30-
<Link
31-
href={`#${hash}`}
32-
className={`toc-item__link toc-item__link--${level}`}
25+
if (headers[index].subheadings?.length === 0) {
26+
return (
27+
<View
28+
as="li"
29+
className={`toc-item toc-item--${level}`}
30+
key={`toc-${index}`}
3331
>
34-
{linkText}
35-
</Link>
36-
</View>
37-
);
32+
<Link
33+
href={`#${hash}`}
34+
className={`toc-item__link toc-item__link--${level}`}
35+
>
36+
{linkText}
37+
</Link>
38+
</View>
39+
);
40+
} else {
41+
return (
42+
<View
43+
as="li"
44+
className={`toc-item toc-item--${level}`}
45+
key={`toc-${index}`}
46+
>
47+
<Link
48+
href={`#${hash}`}
49+
className={`toc-item__link toc-item__link--${level}`}
50+
>
51+
{linkText}
52+
</Link>
53+
<View as="ul" className="toc-list">
54+
{headers[index].subheadings?.map(
55+
({ linkText, hash, level }, index) => {
56+
return (
57+
<View
58+
as="li"
59+
className={`toc-item toc-item--${level}`}
60+
key={`toc-${index}`}
61+
>
62+
<Link
63+
href={`#${hash}`}
64+
className={`toc-item__link toc-item__link--${level}`}
65+
>
66+
{linkText}
67+
</Link>
68+
</View>
69+
);
70+
}
71+
)}
72+
</View>
73+
</View>
74+
);
75+
}
3876
})}
3977
</View>
4078
</Flex>

src/fragments/lib-v1/analytics/js/personalize.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ To record event data, you need the following:
77

88
For more information, see [Record Events](https://docs.aws.amazon.com/personalize/latest/dg/recording-events.html).
99

10-
### Installation and Configuration
10+
## Installation and Configuration
1111

1212
Register the *AmazonPersonalizeProvider* with the Analytics category:
1313
You need the tracking ID of your event tracker. For more information, see [Get a Tracking ID](https://docs.aws.amazon.com/personalize/latest/dg/recording-events.html#event-get-tracker).
@@ -38,7 +38,7 @@ Analytics.configure({
3838
}
3939
});
4040
```
41-
### Working with the API
41+
## Working with the API
4242

4343
You can use the `Identify` event type to track a user identity. This lets you connect a user to their actions and record traits about them. To identify a user, specify a unique identifier for the userId property.
4444
Consider the following user interactions when choosing when and how often to call record with the Identify eventType:

src/fragments/lib-v1/auth/native_common/signin_next_steps/common.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import flutter0 from '/src/fragments/lib-v1/auth/flutter/signin_next_steps/10_si
1010

1111
<Fragments fragments={{ swift: ios0, flutter: flutter0 }} />
1212

13-
### Confirm signin with SMS MFA
13+
## Confirm signin with SMS MFA
1414

1515
import ios1 from '/src/fragments/lib-v1/auth/ios/signin_next_steps/20_confirm_sms_mfa.mdx';
1616

@@ -19,62 +19,62 @@ import flutter1 from '/src/fragments/lib-v1/auth/flutter/signin_next_steps/20_co
1919
<Fragments fragments={{ swift: ios1, flutter: flutter1 }} />
2020

2121
<InlineFilter filters={["flutter"]}>
22-
### Confirm signin with TOTP MFA
22+
## Confirm signin with TOTP MFA
2323
</InlineFilter>
2424

2525
import flutter7 from '/src/fragments/lib-v1/auth/flutter/signin_next_steps/80_totp.mdx';
2626

2727
<Fragments fragments={{ flutter: flutter7 }} />
2828

2929
<InlineFilter filters={["flutter"]}>
30-
### Continue signin with MFA Selection
30+
## Continue signin with MFA Selection
3131
</InlineFilter>
3232

3333
import flutter8 from '/src/fragments/lib-v1/auth/flutter/signin_next_steps/90_mfa_selection.mdx';
3434

3535
<Fragments fragments={{ flutter: flutter8 }} />
3636

3737
<InlineFilter filters={["flutter"]}>
38-
### Continue signin with TOTP Setup
38+
## Continue signin with TOTP Setup
3939
</InlineFilter>
4040

4141
import flutter9 from '/src/fragments/lib-v1/auth/flutter/signin_next_steps/100_totp_setup.mdx';
4242

4343
<Fragments fragments={{ flutter: flutter9 }} />
4444

45-
### Confirm signin with custom challenge
45+
## Confirm signin with custom challenge
4646

4747
import ios2 from '/src/fragments/lib-v1/auth/ios/signin_next_steps/30_confirm_custom_challenge.mdx';
4848

4949
import flutter2 from '/src/fragments/lib-v1/auth/flutter/signin_next_steps/30_confirm_custom_challenge.mdx';
5050

5151
<Fragments fragments={{ swift: ios2, flutter: flutter2 }} />
5252

53-
### Confirm signin with new password
53+
## Confirm signin with new password
5454

5555
import ios3 from '/src/fragments/lib-v1/auth/ios/signin_next_steps/40_confirm_new_password.mdx';
5656

5757
import flutter3 from '/src/fragments/lib-v1/auth/flutter/signin_next_steps/40_confirm_new_password.mdx';
5858

5959
<Fragments fragments={{ swift: ios3, flutter: flutter3 }} />
6060

61-
### Reset password
61+
## Reset password
6262

6363
import ios4 from '/src/fragments/lib-v1/auth/ios/signin_next_steps/50_reset_password.mdx';
6464

6565
import flutter4 from '/src/fragments/lib-v1/auth/flutter/signin_next_steps/50_reset_password.mdx';
6666

6767
<Fragments fragments={{ swift: ios4, flutter: flutter4 }} />
6868

69-
### Confirm Signup
69+
## Confirm Signup
7070

7171
import ios5 from '/src/fragments/lib-v1/auth/ios/signin_next_steps/60_confirm_signup.mdx';
7272

7373
import flutter5 from '/src/fragments/lib-v1/auth/flutter/signin_next_steps/60_confirm_signup.mdx';
7474

7575
<Fragments fragments={{ swift: ios5, flutter: flutter5 }} />
7676

77-
### Done
77+
## Done
7878

7979
import ios6 from '/src/fragments/lib-v1/auth/ios/signin_next_steps/70_done.mdx';
8080

src/fragments/lib-v1/geo/android/escapehatch.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Log.i("MyAmplifyApp", response.entries.toString())
5151
</Block>
5252
</BlockSwitcher>
5353

54-
### Documentation Resources
54+
## Documentation Resources
5555

5656
* [How to manage Amazon Location Service resources through console](https://docs.aws.amazon.com/location/latest/developerguide/welcome.html)
5757

src/fragments/lib-v1/geo/ios/escapehatch.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ do {
4747
}
4848
```
4949

50-
### Documentation Resources
50+
## Documentation Resources
5151

5252
* [How to manage Amazon Location Service resources through console](https://docs.aws.amazon.com/location/latest/developerguide/welcome.html)
5353

src/fragments/lib-v1/in-app-messaging/integrate-your-application/integrate-your-application.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import js1 from '/src/fragments/lib-v1/in-app-messaging/integrate-your-applicati
1616

1717
<Fragments fragments={{ javascript: js1 , angular: js1, nextjs: js1, react: js1, vue: js1 }} />
1818

19-
### Integrate In-App Messaging
19+
## Integrate In-App Messaging
2020

2121
Amplify UI provides a Higher-Order Component for ease of integrating the In-App Messaging UI with your application. Simply wrap your application root component in, for example, `App.js`.
2222

src/fragments/lib-v1/in-app-messaging/integrate-your-application/js/install-dependencies.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{/* TODO What should be done with this page for non-react frameworks */}
22

3-
### Install Amplify UI for React
3+
## Install Amplify UI for React
44

55
import js0 from '/src/fragments/lib-v1/in-app-messaging/integrate-your-application/ui-integration.mdx';
66

src/fragments/lib-v1/in-app-messaging/integrate-your-application/react-native/configure-amplify.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### Configure Amplify
1+
## Configure Amplify
22

33
import rn1 from '/src/fragments/lib-v1/common/react-native/import_configuration.mdx';
44

src/fragments/lib-v1/in-app-messaging/integrate-your-application/react-native/install-dependencies.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import reactnative0 from '/src/fragments/lib-v1/react-native-polyfills.mdx';
22

33
<Fragments fragments={{ 'react-native': reactnative0 }} />
44

5-
### Install Amplify UI for React Native and its dependencies
5+
## Install Amplify UI for React Native and its dependencies
66

77
import reactnative1 from '/src/fragments/lib-v1/in-app-messaging/integrate-your-application/ui-integration.mdx';
88

0 commit comments

Comments
 (0)