-
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] Migrate Wonder Blocks off old id providers (#2391)
## Summary: This is the last piece in the first batch of work. This migrates all Wonder Blocks components off our old ID providers and onto the new `Id` component. There are also some documentation tweaks to make the deprecation clearer in our stories, since that's some primary documentation for folks. With this PR, we can cut a release and then begin updating consumer repos accordingly. First, to include this update, then to migrate them off the old ways and onto the new. ### Release process: Once this small stack of PRs are landed and released, the following PRs need to be updated with that release, then landed/deployed: - Perseus: Khan/perseus#2007 - Webapp - Khan/webapp#28105 - Khan/webapp#28127 Issue: WB-1812 ## Test plan: `yarn test` `yarn typecheck` `yarn start:storybook` Author: somewhatabstract Reviewers: jandrade, somewhatabstract Required Reviewers: Approved By: jandrade Checks: ⌛ Lint / Lint (ubuntu-latest, 20.x), ⌛ Check build sizes (ubuntu-latest, 20.x), ⌛ Chromatic - Build on regular PRs / chromatic (ubuntu-latest, 20.x), ⌛ Publish npm snapshot (ubuntu-latest, 20.x), ⌛ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ⏭️ Chromatic - Skip on Release PR (changesets), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x), ✅ gerald, ⏭️ dependabot Pull Request URL: #2391
- Loading branch information
1 parent
897686b
commit 56d961f
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.