-
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
230 changed files
with
8,489 additions
and
5,912 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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-core": major | ||
"@khanacademy/wonder-blocks-search-field": patch | ||
"@khanacademy/wonder-blocks-accordion": patch | ||
"@khanacademy/wonder-blocks-dropdown": patch | ||
"@khanacademy/wonder-blocks-popover": patch | ||
"@khanacademy/wonder-blocks-testing": patch | ||
"@khanacademy/wonder-blocks-tooltip": patch | ||
"@khanacademy/wonder-blocks-switch": patch | ||
"@khanacademy/wonder-blocks-modal": patch | ||
"@khanacademy/wonder-blocks-form": patch | ||
--- | ||
|
||
Deprecate the ID provider and unique ID utilities |
This file was deleted.
Oops, something went wrong.
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,5 @@ | ||
--- | ||
"@khanacademy/wonder-blocks-core": minor | ||
--- | ||
|
||
- Add the `Id` component for cases where `useId` cannot be used directly |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import * as React from "react"; | ||
|
||
import {Meta} from "@storybook/react"; | ||
import {View, Id} from "@khanacademy/wonder-blocks-core"; | ||
import {Body, BodyMonospace} from "@khanacademy/wonder-blocks-typography"; | ||
import {Strut} from "@khanacademy/wonder-blocks-layout"; | ||
import {spacing} from "@khanacademy/wonder-blocks-tokens"; | ||
|
||
export default { | ||
title: "Packages / Core / Id", | ||
|
||
parameters: { | ||
chromatic: { | ||
// We don't need a snapshot for this. | ||
disableSnapshot: true, | ||
}, | ||
}, | ||
} as Meta; | ||
|
||
export const GeneratedIdExample = () => ( | ||
<View> | ||
<Id> | ||
{(id) => ( | ||
<View style={{flexDirection: "row"}}> | ||
<Body>Generated identifier: </Body> | ||
<Strut size={spacing.xSmall_8} /> | ||
<BodyMonospace>{id}</BodyMonospace> | ||
</View> | ||
)} | ||
</Id> | ||
</View> | ||
); | ||
|
||
export const PassedThroughIdExample = () => ( | ||
<View> | ||
<Id id="my-identifier"> | ||
{(id) => ( | ||
<View style={{flexDirection: "row"}}> | ||
<Body>Passed through identifier: </Body> | ||
<Strut size={spacing.xSmall_8} /> | ||
<BodyMonospace>{id}</BodyMonospace> | ||
</View> | ||
)} | ||
</Id> | ||
</View> | ||
); |
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.