Skip to content

Commit 02e431e

Browse files
Storybook overview and header bug (#1504)
* Adding our Overview page * Adding the feedback and icons to header * Typo on npm * Fixing with ensuring it's loaded with setTimeout * Update stories/feedback.stories.mdx Co-authored-by: Nicolas Vogt <[email protected]> Co-authored-by: Nicolas Vogt <[email protected]>
1 parent 0a4638a commit 02e431e

File tree

9 files changed

+195
-2
lines changed

9 files changed

+195
-2
lines changed

.storybook/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ module.exports = {
1616
// }
1717
// }
1818
],
19-
stories: ['../stories/**/*.@(js|mdx)'],
19+
stories: ['../stories/overview.stories.mdx', '../stories/**/*.@(js|mdx)'],
2020
addons: [
21+
'@storybook/addon-docs'
2122
// '@storybook/addon-a11y/register',
2223
// '@storybook/addon-actions/register',
2324
// '@storybook/addon-knobs/register',

.storybook/manager-head.html

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,78 @@
1919
awa.init(config);
2020

2121
window.onload = () => {
22+
addUsefulLinks();
23+
}
24+
25+
function addUsefulLinks() {
26+
const linkStyle = 'color: black; text-decoration: none; text-align: center; cursor: pointer; padding-right: 0.5rem;';
27+
const imageStyle = 'height: 0.75rem; margin-top: 0.125rem;';
28+
const textStyle = 'margin-left: 0.25rem; font-size: 0.75rem;';
29+
const linkContentStyle = 'display: flex;';
30+
31+
const sidebarHeader = document.getElementsByClassName('sidebar-header');
32+
if (sidebarHeader.length === 0) {
33+
// sidebar container has not loaded in the page yet, retry in 500ms
34+
setTimeout(addUsefulLinks, 500);
35+
return false;
36+
}
37+
2238
// This is a fix for an accessibility issue: https://github.com/microsoftgraph/microsoft-graph-toolkit/issues/1085
23-
const sidebarHeader = document.getElementsByClassName('sidebar-header')[0];
39+
const sidebarHeader = sidebarHeader[0];
2440
sidebarHeader.innerHTML = '<h1 tabindex="0" class="css-1su1ft1">' + '<a href="https://aka.ms/mgt" target="_blank" class="css-ixbm00">' +
2541
'Microsoft Graph Toolkit Playground</a>' +
2642
'</h1>';
43+
44+
const sidebarNode = sidebarHeader[0].parentNode;
45+
46+
// GitHub
47+
const githubImage = document.createElement('img');
48+
githubImage.src = './github.png';
49+
githubImage.style = imageStyle;
50+
51+
const githubText = document.createElement('span');
52+
githubText.style = textStyle;
53+
githubText.innerText = 'GitHub';
54+
55+
const repoLinkContent = document.createElement('span');
56+
repoLinkContent.style = linkContentStyle;
57+
repoLinkContent.append(githubImage, githubText);
58+
59+
const repoLink = document.createElement('a');
60+
repoLink.href = 'https://aka.ms/mgt';
61+
repoLink.target='_blank';
62+
repoLink.style = linkStyle;
63+
repoLink.appendChild(repoLinkContent);
64+
65+
// npm
66+
const npmImage = document.createElement('img');
67+
npmImage.src = './npm.png';
68+
npmImage.style = imageStyle;
69+
70+
const npmText = document.createElement('span');
71+
npmText.style = textStyle;
72+
npmText.innerText = 'npm';
73+
74+
const npmLinkContent = document.createElement('span');
75+
npmLinkContent.style = linkContentStyle;
76+
npmLinkContent.append(npmImage, npmText);
77+
78+
const npmLink = document.createElement('a');
79+
npmLink.href = 'https://www.npmjs.com/package/@microsoft/mgt';
80+
npmLink.target='_blank';
81+
npmLink.style = linkStyle + ' margin-left: 0.5rem;';
82+
npmLink.appendChild(npmLinkContent);
83+
84+
// links container
85+
const usefulLinksContainer = document.createElement('div');
86+
usefulLinksContainer.id = 'useful-links';
87+
usefulLinksContainer.style = 'display: flex; margin: 1rem 0rem; font-size: 0.875rem;';
88+
89+
usefulLinksContainer.append(repoLink, npmLink);
90+
91+
sidebarNode.insertBefore(usefulLinksContainer, sidebarNode.childNodes[1]);
2792
}
93+
</script>
2894

2995
</script>
3096

.storybook/preview-body.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
'Helvetica Neue', sans-serif;
99
}
1010

11+
.docs-img-centered {
12+
display: block;
13+
float: none;
14+
margin-left: auto;
15+
margin-right: auto;
16+
}
17+
1118
body {
1219
margin: 0px;
1320
}

.storybook/preview.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ import customElements from '../custom-elements.json';
1515
setCustomElements(customElements);
1616

1717
addParameters({
18+
previewTabs: {
19+
'storybook/docs/panel': {
20+
hidden: true
21+
}
22+
},
1823
docs: {
1924
iframeHeight: '400px',
2025
inlineStories: false

assets/github.png

7.6 KB
Loading

assets/mgt.png

137 KB
Loading

assets/npm.png

200 Bytes
Loading

stories/feedback.stories.mdx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { Meta } from '@storybook/addon-docs/blocks';
2+
3+
<Meta title="Feedback" />
4+
5+
# Feedback
6+
7+
In order to improve the Microsoft Graph Toolkit, we need your feedback!
8+
9+
There are various ways for you to provide feedback of your experience and help us make the Toolkit better.
10+
11+
## Contribute to Microsoft Graph Toolkit
12+
13+
If there is a feature or bug you find and you are intersted in contributing directly to our code base please refer to our [contribution guide](https://github.com/microsoftgraph/microsoft-graph-toolkit/wiki).
14+
We encourage developers to feel welcomed into the code base and directly contribute.
15+
16+
## Report Issues
17+
18+
File feature requests, bugs or other issues against the [Microsoft Graph Toolkit repo](https://aka.ms/mgt/issues).
19+
To help us get to your issue faster use the GitHub labels provided.
20+
A team member will look to help out with outstanding issues and navigate them to the right owner.
21+
22+
## Online Forums
23+
24+
For any questions on Microsoft Graph Toolkit or Microsoft Graph, use [Microsoft Q&A](https://docs.microsoft.com/en-us/answers/topics/microsoft-graph-toolkit.html) or [Stack Overflow](https://stackoverflow.com/questions/tagged/microsoft-graph-toolkit).
25+
There use the tag `microsoft-graph-toolkit` for the question to be funneled to our team.

stories/overview.stories.mdx

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import { Meta } from '@storybook/addon-docs/blocks';
2+
3+
<Meta title="Overview" />
4+
5+
# Microsoft Graph Toolkit: UI Components and Authentication Providers for Microsoft Graph
6+
7+
The Microsoft Graph Toolkit is a collection of reusable, framework-agnostic components and authentication providers for accessing and working with Microsoft Graph. The components are fully functional right of out of the box, with built in providers that authenticate with and fetch data from Microsoft Graph.
8+
9+
<img src="graff.png" class="docs-img-centered" width="15%"/>
10+
11+
The Microsoft Graph Toolkit makes it easy to use Microsoft Graph in your application. In the following example, a signed in user and their calendar events are displayed with just two lines of code by using the [Login](?path=/story/components-mgt-login--login) and [Agenda](?path=/story/components-mgt-agenda--simple) components.
12+
13+
## Installing the Microsoft Graph Toolkit
14+
15+
It's easy to get started! Add the Toolkit via our `mgt-loader` or via npm and you are ready to go!
16+
17+
### Via the mgt-loader
18+
19+
```html
20+
<script src="https://unpkg.com/@microsoft/mgt/dist/bundle/mgt-loader.js"></script>
21+
```
22+
23+
### Via npm
24+
25+
```shell
26+
npm i @microsoft/mgt
27+
```
28+
29+
## What's in the Microsoft Graph Toolkit?
30+
31+
### Components
32+
33+
The Microsoft Graph Toolkit includes a collection of web components for the most commonly built experiences powered by Microsoft Graph APIs.
34+
35+
The components are also available as [React components](https://docs.microsoft.com/graph/toolkit/get-started/mgt-react).
36+
37+
| Component | Description |
38+
| ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
39+
| [Login](?path=/story/components-mgt-login--login) | A button and a flyout control to authenticate a user with the Microsoft Identity platform and display the user's profile information on sign in. |
40+
| [Person](?path=/story/components-mgt-person--person) | Displays a person or contact by their photo, name, and/or email address. |
41+
| [People](?path=/story/components-mgt-people--people) | Displays a group of people or contacts by their photos or initials. |
42+
| [Agenda](?path=/story/components-mgt-agenda--simple) | Displays events in a user or group's calendar. |
43+
| [People picker](?path=/story/components-mgt-people-picker--people-picker) | Provides the ability to search for people and renders the list of results. |
44+
| [Person card](?path=/story/components-mgt-person-card--person-card) | A flyout used on the person component to display more profile information about a user. |
45+
| [File](?path=/story/components-mgt-file--file) | Represents a file or folder with icon, filename, author, and more. |
46+
| [File list](?path=/story/components-mgt-file-list--file-list) | Displays a list of multiple files or folders. |
47+
| [Get](?path=/story/components-mgt-get--get-email) | Make a GET query to any Microsoft Graph API directly in your HTML. |
48+
| [Teams Channel picker](?path=/story/components-mgt-teams-channel-picker--teams-channel-picker) | Provides the ability to search for Microsoft Teams channels to select a channel from a rendered list of results. |
49+
| [To Do](?path=/story/components-mgt-todo--tasks) | Displays and enables adding, removing, completing, or editing of tasks from Microsoft To Do. |
50+
| [Tasks](?path=/story/components-mgt-tasks--tasks) | Displays and enables adding, removing, completing, or editing of tasks from Microsoft Planner or Microsoft To Do. |
51+
52+
### Providers
53+
54+
[Providers](https://docs.microsoft.com/graph/toolkit/providers/providers) enable authentication and provide the implementation for acquiring access tokens on various platforms and expose a Microsoft Graph client for calling the Microsoft Graph APIs. The components work best when used with a provider, but the providers can be used on their own.
55+
56+
| Providers | Description |
57+
| ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
58+
| [MSAL](https://docs.microsoft.com/graph/toolkit/providers/msal) | Uses msal.js to sign in users and acquire tokens to use with Microsoft Graph. |
59+
| [MSAL2](https://docs.microsoft.com/graph/toolkit/providers/msal2) | Uses msal-browser to sign in users and acquire tokens to use with Microsoft Graph. |
60+
| [Electron](https://docs.microsoft.com/graph/toolkit/providers/electron) | Authenticates and provides Microsoft Graph access to components inside of Electron apps |
61+
| [SharePoint](https://docs.microsoft.com/graph/toolkit/providers/sharepoint) | Authenticates and provides Microsoft Graph access to components inside of SharePoint web parts. |
62+
| [Teams](https://docs.microsoft.com/graph/toolkit/providers/teams) | Uses msal.js to sign in users and acquire tokens on the client in Microsoft Teams tabs. |
63+
| [Teams MSAL2](https://docs.microsoft.com/graph/toolkit/providers/teams-msal2) | Uses msal-browser to sign in users and acquire tokens in Microsoft Teams tabs. Supports Single Sign-On with custom backend. |
64+
| [Proxy](https://docs.microsoft.com/graph/toolkit/providers/proxy) | Allows the use of backend authentication by routing all calls to Microsoft Graph through your backend. |
65+
| [Custom](https://docs.microsoft.com/graph/toolkit/providers/custom) | Create a custom provider to enable authentication and access to Microsoft Graph with your application's existing authentication code. |
66+
67+
## Who should use it?
68+
69+
The Microsoft Graph Toolkit is great for developers of all experience levels looking to develop an app that connects to and accesses data from Microsoft Graph, such as a:
70+
- Web app
71+
- Microsoft Teams tab
72+
- SharePoint web part
73+
- Progressive Web App (PWA)
74+
- Electron app
75+
76+
## Where can I use it?
77+
78+
The Microsoft Graph Toolkit is supported in the following browsers.
79+
80+
| ![Edge](https://docs.microsoft.com/graph/toolkit/images/edgeIcon.png) | ![Firefox](https://docs.microsoft.com/graph/toolkit/images/firefoxIcon.png) | ![Chrome](https://docs.microsoft.com/graph/toolkit/images/chromeIcon.png) | ![Safari](https://docs.microsoft.com/graph/toolkit/images/safariIcon.png) | ![Opera](https://docs.microsoft.com/graph/toolkit/images/operaIcon.png) | ![Samsung Internet](https://docs.microsoft.com/graph/toolkit/images/samsungInternetIcon.png) |
81+
| --------------------------------------------------------------------- | --------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ----------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
82+
| **Edge** | **Firefox** | **Chrome** | **Safari** | **Opera** | **Samsung** |
83+
84+
85+
## Next steps
86+
87+
- Read our [documentation](https://aka.ms/mgt/docs).
88+
- [Get started](https://docs.microsoft.com/graph/toolkit/get-started/overview) with the Microsoft Graph Toolkit.
89+
- Check out the Microsoft Graph Toolkit on [GitHub](https://aka.ms/mgt).

0 commit comments

Comments
 (0)