Skip to content

Commit

Permalink
Merge branch 'main' of github.com:microsoftgraph/microsoft-graph-tool…
Browse files Browse the repository at this point in the history
…kit into bug-2201
  • Loading branch information
musale committed Jul 25, 2023
2 parents 88088ce + 4e52f41 commit ec440f3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 18 deletions.
37 changes: 37 additions & 0 deletions .storybook/components/ElementNamer.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React, { useEffect } from 'react';

export const TableNamer = ({ names }) => {
useEffect(() => {
const tables = document.querySelectorAll('table:not([aria-hidden="true"])');
if (tables.length !== names.length) {
console.error(
'🦒: TableNamer: number of tables does not match number of names',
`Found ${tables?.length ?? 0} and was provided ${names?.length ?? 0}`
);
}
for (let i = 0; i < tables.length; i++) {
tables[i].setAttribute('title', names[i]);
}
}, [names]);
return <></>;
};

export const CopyButtonNamer = ({ names }) => {
useEffect(() => {
const onWindowLoadHander = () => {
const buttons = document.getElementsByClassName('css-3ltsna');
if (buttons.length !== names.length) {
console.error(
'🦒: CopyButtonNamer: number of buttons does not match number of names',
`Found ${buttons?.length ?? 0} buttons and was provided ${names?.length ?? 0} names`
);
}
for (let i = 0; i < buttons.length; i++) {
buttons[i].setAttribute('aria-label', names[i]);
}
};
window.addEventListener('load', onWindowLoadHander);
return () => window.removeEventListener('load', onWindowLoadHander);
}, [names]);
return <></>;
};
17 changes: 0 additions & 17 deletions .storybook/components/TableNamer.jsx

This file was deleted.

3 changes: 2 additions & 1 deletion stories/overview.stories.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meta, Source } from '@storybook/addon-docs';
import { PACKAGE_VERSION } from '@microsoft/mgt';
import { versionInfo } from '../.storybook/versionInfo';
import { TableNamer } from '../.storybook/components/TableNamer';
import { TableNamer, CopyButtonNamer } from '../.storybook/components/ElementNamer';

<Meta title="Overview" />

Expand Down Expand Up @@ -105,3 +105,4 @@ The Microsoft Graph Toolkit is supported in the following browsers.
- Check out the Microsoft Graph Toolkit on [GitHub](https://aka.ms/mgt).

<TableNamer names={['Microsoft Graph Toolkit Components', 'Components in preview', 'Microsoft Graph Toolkit Providers', 'Supported browsers']}/>
<CopyButtonNamer names={['Copy mgt-loader script tag', 'Copy npm install command']}/>

0 comments on commit ec440f3

Please sign in to comment.