* turn article.scss into a module + componentized * Update Survey to use only component styles, add cancel button * Update GenericError + 404 page to use only standard classes * update LearningTrack to not use markdown-body * remove / consolidate stylesheets * cleanup Graphiql explorer page and scss * Componentize Breadcrumb styles * Componentize DeprecationBanner styles * scope h2 a link style to markdown-body * cleanup nav, organize page-header and page-footer components * remove unused scroll-button.scss * organize LanguagePicker and ProductPicker * add declarations file * remove featured-links.scss, update tests * update list utility and toc test * fix bad merge resolution * update breadcrumbs test
26 lines
563 B
TypeScript
26 lines
563 B
TypeScript
import { createContext, useContext } from 'react'
|
|
|
|
type LanguageItem = {
|
|
name: string
|
|
nativeName?: string
|
|
code: string
|
|
hreflang: string
|
|
wip?: boolean
|
|
}
|
|
|
|
export type LanguagesContextT = {
|
|
languages: Record<string, LanguageItem>
|
|
}
|
|
|
|
export const LanguagesContext = createContext<LanguagesContextT | null>(null)
|
|
|
|
export const useLanguages = (): LanguagesContextT => {
|
|
const context = useContext(LanguagesContext)
|
|
|
|
if (!context) {
|
|
throw new Error('"useLanguagesContext" may only be used inside "LanguagesContext.Provider"')
|
|
}
|
|
|
|
return context
|
|
}
|