Skip to content

Commit 0528249

Browse files
committed
feat: i18n prop
1 parent 30ab5f4 commit 0528249

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/ui-components/src/Common/TableOfContents/index.stories.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export const CustomDepth: Story = {
1717
export default {
1818
component: TableOfContents,
1919
args: {
20+
ariaLabel: 'Table of Contents',
21+
summaryTitle: 'On this page',
2022
headings: [
2123
{
2224
value: 'OpenSSL update assessment, and Node.js project plans',

packages/ui-components/src/Common/TableOfContents/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ import styles from './index.module.css';
99

1010
type TableOfContentsProps = {
1111
headings: Array<Heading>;
12+
ariaLabel: string;
13+
summaryTitle: string;
1214
minDepth?: number;
1315
maxDepth?: number;
1416
as?: LinkLike;
1517
};
1618

1719
const TableOfContents: FC<TableOfContentsProps> = ({
1820
headings,
21+
ariaLabel,
22+
summaryTitle,
1923
minDepth = 2,
2024
maxDepth = 4,
2125
as: Component = 'a',
@@ -25,8 +29,8 @@ const TableOfContents: FC<TableOfContentsProps> = ({
2529
);
2630

2731
return (
28-
<details className={styles.details} aria-label="Table of Contents">
29-
<summary className={styles.summary}>On this page</summary>
32+
<details className={styles.details} aria-label={ariaLabel}>
33+
<summary className={styles.summary}>{summaryTitle}</summary>
3034
<ul className={styles.list}>
3135
{filteredHeadings.map((head, index) => (
3236
<li key={head.data?.id ?? index}>

0 commit comments

Comments
 (0)