Skip to content

Commit 2fc5032

Browse files
add createTheme helper
1 parent 20462a6 commit 2fc5032

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

src/themes/roli.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import merge from 'lodash.merge';
21
import defaultTheme from './default';
2+
import { createTheme } from '../utils/themes';
33

4-
const roliTheme = merge({}, defaultTheme, {
4+
const roliTheme = createTheme(defaultTheme, {
55
timeline: {
66
backgroundColor: '#0C1734',
77
a: { color: 'yellow' },

src/utils/themes.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import merge from 'lodash.merge';
2+
3+
export function createTheme(baseTheme, newTheme) {
4+
return merge({}, baseTheme, newTheme);
5+
}

src/utils/themes.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { createTheme } from './themes';
2+
3+
test('createTheme creates a theme', () => {
4+
const baseTheme = { timelinex: { backgroundColor: '#fff' } };
5+
const newTheme = createTheme(baseTheme, {
6+
timelineTrack: { backgroundColor: '#000' },
7+
});
8+
9+
const expected = {
10+
timeline: {
11+
backgroundColor: '#fff',
12+
},
13+
timelineTrack: {
14+
backgroundColor: '#000',
15+
},
16+
};
17+
18+
expect(newTheme).toEqual(expected);
19+
});

0 commit comments

Comments
 (0)