-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creates highlight management utilities in
descendants
[LG-4389] (#2423
) * creates highlight package * mv descendants files to subdir * mv highlight to descendants * cleanup descendants utils * types for highlight fns * creates useHighlightContext * create basic story * create Grid story * create getRelativeDescendant util * adds tests for getRelativeDescendant * mv onChange to options.onChange * adds `filter` option * Cleanup ActionType * implement Position action * Creates ValuesOf * improve setter types & logic * add docs & changelog * adds onInit * Update README.md * adds todo tests * Update README.md * Update Highlight.stories.tsx * Update Highlight.stories.tsx * Descendants DX (#2430) * useInitDescendants accepts context * Create swift-points-sip.md * Update Highlight.stories.tsx * Update Tabs to use latest Descendants API * Update Menu to use latest Descendants API * rename setters. rm setter from context * Returns Provider from useHighlight * Update README.md * adds tests for useHighlight * Update Highlight.spec.tsx * Update Descendants.stories.tsx * Update README.md * Update README.md
- Loading branch information
1 parent
76d605e
commit 4c04aa0
Showing
55 changed files
with
1,456 additions
and
229 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,5 @@ | ||
--- | ||
'@leafygreen-ui/lib': minor | ||
--- | ||
|
||
Creates utility types `Only`, `ExclusiveUnion` and `ValuesOf` |
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 @@ | ||
--- | ||
'@leafygreen-ui/menu': patch | ||
--- | ||
|
||
Update Menu to use latest Descendants API |
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 @@ | ||
--- | ||
'@leafygreen-ui/tabs': patch | ||
--- | ||
|
||
Updates Tabs to use latest Descendants API |
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,37 @@ | ||
--- | ||
'@leafygreen-ui/descendants': major | ||
--- | ||
|
||
Updates `useInitDescendants` signature to require a Context value, and return a `Provider` component. | ||
|
||
Eliminates the need to destructure `descendants` and `dispatch` from the hook's return value just to pass into the provider. Instead, the hook will construct a pre-populated provider unique to the Context value given. | ||
|
||
Note: `descendants`, `dispatch` and `getDescendants` are still returned by the hook for use in the parent component if necessary. | ||
|
||
Before: | ||
```tsx | ||
const MyDescendantContext = createDescendantsContext(); | ||
const { descendants, dispatch } = useInitDescendants(); | ||
|
||
return ( | ||
<DescendantsProvider | ||
context={MyDescendantContext} | ||
descendants={descendants} | ||
dispatch={dispatch} | ||
> | ||
<MyDescendantItem /> | ||
</DescendantsProvider> | ||
) | ||
``` | ||
|
||
After: | ||
```tsx | ||
const MyDescendantContext = createDescendantsContext(); | ||
const { Provider } = useInitDescendants(MyDescendantContext); | ||
|
||
return ( | ||
<Provider> | ||
<MyDescendantItem /> | ||
</Provider> | ||
) | ||
``` |
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,9 @@ | ||
--- | ||
'@leafygreen-ui/descendants': minor | ||
--- | ||
|
||
Adds Highlight management utilities. | ||
- `useHighlight`: A hook to initialize the highlight state management | ||
- `HighlightProvider`: A context provider for consuming the highlight state from descendant components | ||
- `createHighlightContext`: Constructs a unique Context object in order to support nested contexts | ||
|
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.