-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[wb1812.3.migratewb] Update some docs and improve visibility of depre…
…cation notices
- Loading branch information
1 parent
8a85122
commit e259cf4
Showing
5 changed files
with
56 additions
and
8 deletions.
There are no files selected for viewing
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,39 @@ | ||
import * as React from "react"; | ||
import {Meta, Story, Canvas} from "@storybook/blocks"; | ||
import * as IdStories from "./id.stories"; | ||
|
||
<Meta of={IdStories} /> | ||
|
||
# Id | ||
|
||
`Id` is a component that provides an identifier to its children. | ||
|
||
It is useful for situations where the `useId` hook cannot be easily used, | ||
such as in class-based components. | ||
|
||
If an `id` prop is provided, that is passed through to the children; | ||
otherwise, a unique identifier is generated. | ||
|
||
## Usage | ||
|
||
```tsx | ||
import {Id} from "@khanacademy/wonder-blocks-core"; | ||
|
||
<Id id={maybeId}>{(id) => <div id={id}>Hello, world!</div>}</Id>; | ||
``` | ||
|
||
## Examples | ||
|
||
### 1. Generating an id | ||
|
||
An identifier will always be generated if an `id` prop is not provided, or the | ||
provided `id` property is falsy. | ||
|
||
<Canvas withSource="open" of={IdStories.GeneratedIdExample} /> | ||
|
||
### 2. Passthrough an id | ||
|
||
If an `id` prop is provided and it is truthy, that value will be passed through | ||
to the children. | ||
|
||
<Canvas sourceState="shown" of={IdStories.PassedThroughIdExample} /> |
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