-
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.
PD-558: Add onElementClick prop (#297)
* Expose onElmeentClick prop * tests * wip * refactor and pr feedback * add university glyph * fix spacing for version link * fixed ignore
- Loading branch information
Showing
11 changed files
with
350 additions
and
217 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/mongo-nav': minor | ||
--- | ||
|
||
Add onElementClick prop |
Large diffs are not rendered by default.
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
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,29 @@ | ||
import React, { createContext, useContext } from 'react'; | ||
import { OnElementClick } from './types'; | ||
|
||
type OnElementClickType = ( | ||
type: OnElementClick, | ||
event: React.MouseEvent, | ||
) => void; | ||
|
||
interface OnElementClickProviderProps { | ||
children: React.ReactNode; | ||
onElementClick: OnElementClickType; | ||
} | ||
|
||
const OnElementClickContext = createContext<OnElementClickType>(() => {}); | ||
|
||
export function useOnElementClick() { | ||
return useContext(OnElementClickContext); | ||
} | ||
|
||
export default function OnElementClickProvider({ | ||
children, | ||
onElementClick, | ||
}: OnElementClickProviderProps) { | ||
return ( | ||
<OnElementClickContext.Provider value={onElementClick}> | ||
{children} | ||
</OnElementClickContext.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
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.