|
6 | 6 | import React, { PropTypes } from 'react'; |
7 | 7 | import JSONNode from './JSONNode'; |
8 | 8 | import createStylingFromTheme from './createStylingFromTheme'; |
| 9 | +import { invertTheme } from 'react-base16-styling'; |
9 | 10 |
|
10 | 11 | const identity = value => value; |
11 | 12 | const expandRootNode = (keyName, data, level) => level === 0; |
@@ -53,9 +54,22 @@ function checkLegacyTheming(theme, props) { |
53 | 54 | } |
54 | 55 |
|
55 | 56 | function getStateFromProps(props) { |
| 57 | + let theme = checkLegacyTheming(props.theme, props); |
| 58 | + if (props.invertTheme) { |
| 59 | + if (typeof theme === 'string') { |
| 60 | + theme = `${theme}:inverted`; |
| 61 | + } else if (theme && theme.extend) { |
| 62 | + if (typeof theme === 'string') { |
| 63 | + theme = { ...theme, extend: `${theme.extend}:inverted` }; |
| 64 | + } else { |
| 65 | + theme = { ...theme, extend: invertTheme(theme.extend) }; |
| 66 | + } |
| 67 | + } else if (theme) { |
| 68 | + theme = invertTheme(theme); |
| 69 | + } |
| 70 | + } |
56 | 71 | return { |
57 | | - styling: createStylingFromTheme( |
58 | | - checkLegacyTheming(props.theme, props), props.invertTheme) |
| 72 | + styling: createStylingFromTheme(theme) |
59 | 73 | }; |
60 | 74 | } |
61 | 75 |
|
@@ -115,7 +129,7 @@ export default class JSONTree extends React.Component { |
115 | 129 | postprocessValue, |
116 | 130 | hideRoot, |
117 | 131 | theme, // eslint-disable-line no-unused-vars |
118 | | - invertTheme, // eslint-disable-line no-unused-vars |
| 132 | + invertTheme: _, // eslint-disable-line no-unused-vars |
119 | 133 | ...rest |
120 | 134 | } = this.props; |
121 | 135 |
|
|
0 commit comments