-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve API docs for menu button component (#2027)
# Pull Request ## π€¨ Rationale As part of #824 we want to improve the accuracy and comprehensiveness of our storybook API documentation. ## π©βπ» Implementation Apply the following patterns to the menu button docs: 1. create sections in the args table for attributes, slots, and events. (We'd also add methods for components that expose interesting ones) 2. Ensure the title and description are accurate for each member 3. link to shared docs about component APIs. Other minor bug fixes: 1. hide the "patterns" page from public storybook 2. hide text from β icon mapping in component status table ### Possible follow up work 1. update doc templates and the docs for other existing components similarly 1. more detailed API overview docs - explanation of event patterns in web components and how they map to frameworks - using forms instead of change events 1. see if we can remove the type annotation from control descriptions 2. [wait for further feedback] more curated examples and highlight most important APIs for each component 1. [out of scope] I wish I could hide the Default column since we don't bother populating it but that doesn't seem to be possible storybookjs/storybook#15780 ## π§ͺ Testing Manual storybook interaction ## β Checklist <!--- Review the list and put an x in the boxes that apply or ~~strike through~~ around items that don't (along with an explanation). --> - [x] I have updated the project documentation to reflect my changes or determined no changes are needed.
- Loading branch information
Showing
10 changed files
with
196 additions
and
29 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@ni-nimble-components-7b65608b-da35-44f3-bff4-d787fac390c5.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "none", | ||
"comment": "Storybook documentation improvements", | ||
"packageName": "@ni/nimble-components", | ||
"email": "[email protected]", | ||
"dependentChangeType": "none" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/nimble-components/src/patterns/docs/component-apis-link.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
For more information about the structure of Nimble APIs, see [Component APIs](?path=/docs/component-apis--docs). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import { Meta } from '@storybook/addon-docs'; | ||
|
||
<Meta title="Component APIs" /> | ||
|
||
# Component APIs | ||
|
||
This page describes common patterns for programmatically configuring Nimble components. | ||
|
||
## Elements | ||
|
||
Nimble components are [web component custom elements](https://developer.mozilla.org/en-US/docs/Web/API/Web_components). | ||
Applications can use custom elements directly or use framework-specific APIs for [Angular](https://angular.io/) | ||
or [Blazor](https://dotnet.microsoft.com/en-us/apps/aspnet/web-apps/blazor). | ||
|
||
Components follow a standard naming convention: | ||
|
||
| Name | Purpose | Example | | ||
| ---------------------- | --------------------------------------------------------- | ----------------------- | | ||
| Custom element name | Add the component to HTML | `nimble-button` | | ||
| JavaScript class name | Interact with the component from JavaScript or TypeScript | `NimbleButton` | | ||
| Angular module name | Import the component in Angular | `NimbleButtonModule` | | ||
| Angular directive name | Interact with the component from Angular | `NimbleButtonDirective` | | ||
| Blazor component name | Use the component in Blazor template or C# class | `NimbleButton` | | ||
|
||
## Slots | ||
|
||
Component content can be configured by inserting it as a child of the component via | ||
[slots](https://developer.mozilla.org/en-US/docs/Web/API/Element/slot). | ||
|
||
Content can be inserted in the default slot: | ||
|
||
```html | ||
<nimble-button>Click me</nimble-button> | ||
``` | ||
|
||
Or in a named slot: | ||
|
||
```html | ||
<nimble-button> | ||
<nimble-icon-key slot="start"></nimble-icon-key> | ||
Click me | ||
</nimble-button> | ||
``` | ||
|
||
## Attributes and Properties | ||
|
||
Configure components from HTML using attributes or from code using properties. Attributes and properties typically | ||
correspond to each other one-to-one; Nimble documentation refers to the attribute name. | ||
|
||
### Attributes | ||
|
||
Attributes have `kebab-case` names in HTML and Angular templates. | ||
|
||
```html | ||
<nimble-button appearance="outline">...</nimble-button> | ||
``` | ||
|
||
### Boolean attributes | ||
|
||
Boolean attributes don't need a value; they are `true` when present and `false` when absent. | ||
|
||
```html | ||
<nimble-button content-hidden>...</nimble-button> | ||
``` | ||
|
||
### Properties | ||
|
||
Properties have `camelCase` names in JavaScript, TypeScript, and Angular. | ||
|
||
```ts | ||
const button = document.querySelector('nimble-button'); | ||
button.appearance = ButtonAppearance.outline; | ||
``` | ||
|
||
### Blazor | ||
|
||
In Blazor, properties and attributes have `PascalCase` names. For values that are enumerations of strings, the type is a C# enum. | ||
|
||
``` | ||
<NimbleButton Appearance="ButtonAppearance.Outline">...</NimbleButton> | ||
``` | ||
|
||
## Methods | ||
|
||
Some components expose methods for providing complex data or invoking operations. Methods are only available in code, not in HTML. | ||
|
||
## Events | ||
|
||
Components raise events to notify the application of changes or user interactions. | ||
Prefer to use documented Nimble events when available rather than native DOM events as they cover more user interactions | ||
(for example, `change` will be raised for both click and keyboard interactions). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters