Skip to content

Commit e67763f

Browse files
committed
feat: add createTheme utility
1 parent 9f65704 commit e67763f

6 files changed

Lines changed: 22 additions & 3 deletions

File tree

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"license": "MIT",
3737
"dependencies": {
3838
"@expo/vector-icons": "9.0.0",
39+
"deepmerge": "^3.0.0",
3940
"exenv": "1.2.2",
4041
"focus-trap": "4.0.2",
4142
"react": "16.7.0",
@@ -44,7 +45,8 @@
4445
"react-icons": "3.3.0",
4546
"react-native-web": "0.9.13",
4647
"react-powerplug": "1.0.0",
47-
"react-spring": "7.0.0"
48+
"react-spring": "7.0.0",
49+
"ts-essentials": "^1.0.2"
4850
},
4951
"devDependencies": {
5052
"@babel/core": "7.2.2",

src/components/Toast/Toast.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as React from 'react';
22
import { Animated } from 'react-native';
3+
import { Omit } from 'ts-essentials';
34

45
import { Theme, withTheme } from '../../theme';
5-
import { Omit } from '../../types/utils';
66
import { Alert, AlertProps } from '../Alert';
77

88
// Animation taken from https://medium.com/@norbajunior/react-native-facebook-and-instagram-like-top-bar-notifications-with-animated-api-43c48d0443dd

src/theme/createTheme.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// @ts-ignore
2+
import deepMerge from 'deepmerge';
3+
import { DeepPartial } from 'ts-essentials';
4+
5+
import { defaultTheme } from './default-theme';
6+
import { Theme } from './ThemeInterface';
7+
8+
export const createTheme = (
9+
theme: DeepPartial<Theme> = defaultTheme,
10+
): Theme => {
11+
return deepMerge(defaultTheme, theme);
12+
};

src/theme/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export { defaultTheme } from './default-theme';
22
export * from './ThemeContext';
33
export * from './ThemeInterface';
44
export { default as withTheme } from './withTheme';
5+
export { createTheme } from './createTheme';

src/types/utils.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12360,6 +12360,11 @@ tryer@^1.0.0:
1236012360
resolved "https://registry.yarnpkg.com/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8"
1236112361
integrity sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==
1236212362

12363+
ts-essentials@^1.0.2:
12364+
version "1.0.2"
12365+
resolved "https://registry.yarnpkg.com/ts-essentials/-/ts-essentials-1.0.2.tgz#ae3e50824e06ea8fbe7e25179a41c3618f79b798"
12366+
integrity sha512-D9TbEdIS+809h3tEESsHwgRFz0FtaCUEXCadqyFW9dw1/eMWjMeGzBsfkestAPexfNxMky6Fu1acI25XrgpIrw==
12367+
1236312368
ts-jest@23.10.5:
1236412369
version "23.10.5"
1236512370
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-23.10.5.tgz#cdb550df4466a30489bf70ba867615799f388dd5"

0 commit comments

Comments
 (0)