Skip to content

Commit 12e1f9f

Browse files
Add a theme provider
1 parent 7a1ea77 commit 12e1f9f

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@observation.org/react-native-components",
3-
"version": "1.72.0",
3+
"version": "1.73.0",
44
"main": "src/index.ts",
55
"repository": "git@github.com:observation/react-native-components.git",
66
"author": "Observation.org",

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import BrandIcons from './lib/BrandIcons'
3434
import Icons, { IconName } from './lib/Icons'
3535
import { setLogConfiguration } from './lib/Log'
3636
import { openUrl } from './lib/Url'
37+
import { ThemeProvider } from './theme/ThemeProvider'
3738

3839
export {
3940
Accordion,
@@ -66,6 +67,7 @@ export {
6667
ProgressBar,
6768
ProgressBarList,
6869
TextLink,
70+
ThemeProvider,
6971
Tooltip,
7072
WebLink,
7173
openUrl,

src/theme/ThemeProvider.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { createContext, useContext } from 'react'
2+
3+
import { Theme } from '../@types/theme'
4+
import defaultTheme from '../styles/theme'
5+
6+
const ThemeContext = createContext<Theme>(defaultTheme)
7+
8+
export const ThemeProvider = ({ theme, children }: { theme: Theme; children: React.ReactNode }) => {
9+
return <ThemeContext.Provider value={theme}>{children}</ThemeContext.Provider>
10+
}
11+
12+
export const useTheme = () => useContext(ThemeContext)

0 commit comments

Comments
 (0)