Skip to content

Commit 8d1132e

Browse files
Rename namespace to themeNamespace
1 parent 6143221 commit 8d1132e

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/components/themr.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default (componentName, localTheme, options = {}) => (ThemedComponent) =>
2323
static propTypes = {
2424
composeTheme: PropTypes.oneOf([ COMPOSE_DEEPLY, COMPOSE_SOFTLY, DONT_COMPOSE ]),
2525
theme: PropTypes.object,
26-
namespace: PropTypes.string
26+
themeNamespace: PropTypes.string
2727
}
2828

2929
static defaultProps = {
@@ -40,14 +40,14 @@ export default (componentName, localTheme, options = {}) => (ThemedComponent) =>
4040
}
4141

4242
getNamespacedTheme() {
43-
const { namespace, theme } = this.props
44-
if (!namespace) return theme
45-
if (namespace && !theme) throw new Error('Invalid namespace use in react-css-themr. ' +
46-
'Namespace prop should be used only with theme prop.')
43+
const { themeNamespace, theme } = this.props
44+
if (!themeNamespace) return theme
45+
if (themeNamespace && !theme) throw new Error('Invalid themeNamespace use in react-css-themr. ' +
46+
'themeNamespace prop should be used only with theme prop.')
4747

4848
return Object.keys(theme)
49-
.filter(key => key.startsWith(namespace))
50-
.reduce((p, c) => ({ ...p, [removeNamespace(c, namespace)]: theme[c] }), {})
49+
.filter(key => key.startsWith(themeNamespace))
50+
.reduce((p, c) => ({ ...p, [removeNamespace(c, themeNamespace)]: theme[c] }), {})
5151
}
5252

5353
getThemeNotComposed() {
@@ -114,7 +114,7 @@ function validateComposeOption(composeTheme) {
114114
}
115115
}
116116

117-
function removeNamespace(key, namespace) {
118-
const capitilized = key.substr(namespace.length)
117+
function removeNamespace(key, themeNamespace) {
118+
const capitilized = key.substr(themeNamespace.length)
119119
return capitilized.slice(0, 1).toLowerCase() + capitilized.slice(1)
120120
}

test/components/themr.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ describe('Themr decorator function', () => {
325325
expect(decorated.refs.wrappedInstance.someInstanceMethod()).toBe(someData)
326326
})
327327

328-
it('should throw if namespace passed without theme', () => {
328+
it('should throw if themeNamespace passed without theme', () => {
329329
const theme = { Container: { foo: 'foo_1234' } }
330330

331331
@themr('Container')
@@ -337,12 +337,12 @@ describe('Themr decorator function', () => {
337337

338338
expect(() => TestUtils.renderIntoDocument(
339339
<ProviderMock theme={theme}>
340-
<Container namespace="container"/>
340+
<Container themeNamespace="container"/>
341341
</ProviderMock>
342-
)).toThrow(/Invalid namespace use in react-css-themr. Namespace prop should be used only with theme prop./)
342+
)).toThrow(/Invalid themeNamespace use in react-css-themr. themeNamespace prop should be used only with theme prop./)
343343
})
344344

345-
it('when providing a namespace prop composes a theme', () => {
345+
it('when providing a themeNamespace prop composes a theme', () => {
346346
const containerTheme = { foo: 'foo_123' }
347347
const containerThemeLocal = { foo: 'foo_567' }
348348
const containerThemeProps = { foo: 'foo_89', containerFoo: 'foo_000' }
@@ -357,7 +357,7 @@ describe('Themr decorator function', () => {
357357

358358
const tree = TestUtils.renderIntoDocument(
359359
<ProviderMock theme={theme}>
360-
<Container theme={containerThemeProps} namespace="container" />
360+
<Container theme={containerThemeProps} themeNamespace="container" />
361361
</ProviderMock>
362362
)
363363

0 commit comments

Comments
 (0)