-
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.
- Loading branch information
Showing
34 changed files
with
259 additions
and
292 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,14 @@ | ||
--- | ||
"@khanacademy/wonder-blocks-search-field": major | ||
"@khanacademy/wonder-blocks-accordion": major | ||
"@khanacademy/wonder-blocks-dropdown": major | ||
"@khanacademy/wonder-blocks-popover": major | ||
"@khanacademy/wonder-blocks-testing": major | ||
"@khanacademy/wonder-blocks-tooltip": major | ||
"@khanacademy/wonder-blocks-switch": major | ||
"@khanacademy/wonder-blocks-modal": major | ||
"@khanacademy/wonder-blocks-form": major | ||
"@khanacademy/wonder-blocks-core": patch | ||
--- | ||
|
||
- Migrate Wonder Blocks components off old id providers and onto new `Id` component |
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
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
Oops, something went wrong.