-
Notifications
You must be signed in to change notification settings - Fork 2k
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
1 parent
5ada27f
commit 9ece3ab
Showing
4 changed files
with
81 additions
and
50 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
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
24 changes: 24 additions & 0 deletions
24
packages/plans-grid-next/src/components/shared/header-price/header-price-context.tsx
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,24 @@ | ||
import { createContext, useContext, useState } from '@wordpress/element'; | ||
|
||
interface HeaderPriceContext { | ||
isAnyPlanPriceDiscounted: boolean; | ||
setIsAnyPlanPriceDiscounted: ( isAnyPlanPriceDiscounted: boolean ) => void; | ||
} | ||
|
||
const HeaderPriceContext = createContext< HeaderPriceContext >( {} as HeaderPriceContext ); | ||
|
||
const HeaderPriceContextProvider = ( { children }: { children: React.ReactNode } ) => { | ||
const [ isAnyPlanPriceDiscounted, setIsAnyPlanPriceDiscounted ] = useState( false ); | ||
|
||
return ( | ||
<HeaderPriceContext.Provider | ||
value={ { isAnyPlanPriceDiscounted, setIsAnyPlanPriceDiscounted } } | ||
> | ||
{ children } | ||
</HeaderPriceContext.Provider> | ||
); | ||
}; | ||
|
||
export const useHeaderPriceContext = (): HeaderPriceContext => useContext( HeaderPriceContext ); | ||
|
||
export default HeaderPriceContextProvider; |
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