c4785ef96e
* get context menu somewhat working ish * take screenshot rather than double rendering * get animations somewhat working * get transform animation working * rm log * upwards safe area * get working on android * get android working once and for all * fix positioning on both platforms * use dark blur on ios always, fix dark mode * allow closing with hardware back press * try and fix type error * add note about ts-ignore * round post * add image capture error handling * extract magic numbers * set explicit embed width, rm top margin * Message embed width tweaks * Format * fix position of embeds * same as above for web --------- Co-authored-by: Eric Bailey <git@esb.lol>
28 lines
661 B
TypeScript
28 lines
661 B
TypeScript
import React from 'react'
|
|
|
|
import type {ContextType, ItemContextType} from '#/components/Menu/types'
|
|
|
|
export const Context = React.createContext<ContextType | null>(null)
|
|
|
|
export const ItemContext = React.createContext<ItemContextType | null>(null)
|
|
|
|
export function useMenuContext() {
|
|
const context = React.useContext(Context)
|
|
|
|
if (!context) {
|
|
throw new Error('useMenuContext must be used within a Context.Provider')
|
|
}
|
|
|
|
return context
|
|
}
|
|
|
|
export function useMenuItemContext() {
|
|
const context = React.useContext(ItemContext)
|
|
|
|
if (!context) {
|
|
throw new Error('useMenuItemContext must be used within a Context.Provider')
|
|
}
|
|
|
|
return context
|
|
}
|