Skip to content
This repository has been archived by the owner on Nov 12, 2017. It is now read-only.

Commit

Permalink
Merge pull request #278 from mattkrick/addCSS
Browse files Browse the repository at this point in the history
add multi-line support for addCSS
  • Loading branch information
Robin Frischmann committed May 2, 2016
2 parents 6350655 + e36febf commit ab9d9aa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/react-look/modules/api/StyleContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class StyleContainer {
* @param {string} styles - as css string
*/
addStatic(styles) {
this._addAndEmit(this.statics, styles)
this._addAndEmit(this.statics, styles.replace(/\s+/g, ''))
}

/**
Expand Down
17 changes: 16 additions & 1 deletion packages/react-look/test/api/StyleContainer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,22 @@ describe('Adding a static css string', () => {
it('should add it to the statics set', () => {
const css = '.h1 { color: red }'
StyleContainer.addStatic(css)
expect(StyleContainer.statics.has(css)).to.eql(true)
expect(StyleContainer.statics.has('.h1{color:red}')).to.eql(true)
})
})

describe('Adding a static css string with spaces and comments', () => {
it('should add it to the statics set', () => {
const css = `
/*!
* Banner
*/
.h1 {
color: red;
margin: 10px 10px 10px 10px;
}`
StyleContainer.addStatic(css)
expect(StyleContainer.statics.has(css.replace(/\s+/g, ''))).to.eql(true)
})
})

Expand Down
4 changes: 2 additions & 2 deletions packages/react-look/test/api/StyleSheet-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ describe('Generating global CSS', () => {
it('should treat strings as static css', () => {
const css = 'h1 { color: blue }'
StyleSheet.addCSS(css)
expect(StyleContainer.statics.has(css)).to.eql(true)
expect(StyleContainer.statics.has('h1{color:blue}')).to.eql(true)
})

it('toCSS should just call addCSS', () => {
const css = 'h1 { color: blue }'
StyleSheet.toCSS(css)
expect(StyleContainer.statics.has(css)).to.eql(true)
expect(StyleContainer.statics.has('h1{color:blue}')).to.eql(true)
})
})

Expand Down

0 comments on commit ab9d9aa

Please sign in to comment.