Skip to content

Commit

Permalink
Expose Server Rendering API
Browse files Browse the repository at this point in the history
- fixes styled-components#124
- remap flush to reset()
- convenience function getCSS() for SSR

update CHANGELOG.md

- reference issue styled-components#124 and the PR itself

removed prototype

changed to ServerStyleSheet as Pascal Case

- as per [@diegohaz](https://github.com/diegohaz) recommendation

remove mutation and capitlization in export

renamed serverStyle to styleSheet and refactor

- now just extending StyleSheet as pointed out by geeleen
- renamed flush as reset
- added convenience function to call rules.map...
  • Loading branch information
chiefjester committed Nov 23, 2016
1 parent 441b0b9 commit 2463e7f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -23,9 +23,12 @@ All notable changes to this project will be documented in this file. If a contri

### Added

- Expose API for Server Side rendering: `styleSheet.reset()` and `styleSheet.getCSS()`, thanks to [@thisguychris](https://github.com/thisguychris), (see [#214](https://github.com/styled-components/styled-components/pull/214)) fixes [#124](https://github.com/styled-components/styled-components/issues/124)
- Added support for deeply nested styles in ReactNative (e.g. `transform`), thanks [@jacobp100](https://github.com/jacobp100). (see [#139](https://github.com/styled-components/styled-components/pull/139))
- Added support for camelized style properties in ReactNative (e.g. `fontWeight`), thanks [@jacobp100](https://github.com/jacobp100). (see [#145](https://github.com/styled-components/styled-components/pull/145))
- Properly expose `flow` typings by adding a `flow:build` step and `flow` support docs, thanks to [@ryyppy](https://github.com/ryyppy). (see [#219](https://github.com/styled-components/styled-components/pull/219))
- Added support for deeply nested styles in ReactNative (e.g. `transform`), thanks [@jacobp100][https://github.com/jacobp100]. (see [#139](https://github.com/styled-components/styled-components/pull/139))
- Added support for camelized style properties in ReactNative (e.g. `fontWeight`), thanks [@jacobp100][https://github.com/jacobp100]. (see [#145](https://github.com/styled-components/styled-components/pull/145))

### Changed

Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Expand Up @@ -4,6 +4,7 @@
import generateAlphabeticName from './utils/generateAlphabeticName'
import css from './constructors/css'
import injectGlobal from './constructors/injectGlobal'
import styleSheet from './models/StyleSheet'

/* Import singleton constructors */
import _styledComponent from './models/StyledComponent'
Expand All @@ -20,4 +21,4 @@ const styled = _styled(_styledComponent(_ComponentStyle(generateAlphabeticName))

/* Export everything */
export default styled
export { css, keyframes, injectGlobal, ThemeProvider }
export { css, keyframes, injectGlobal, ThemeProvider, styleSheet }
11 changes: 10 additions & 1 deletion src/models/StyleSheet.js
Expand Up @@ -5,4 +5,13 @@

import { StyleSheet } from '../vendor/glamor/sheet'

export default new StyleSheet({ speedy: false, maxLength: 40 })
class StyleSheetExtended extends StyleSheet {
reset() {
return super.flush()
}
getCSS() {
return super.rules().map(rule => rule.cssText).join('\n')
}
}

export default new StyleSheetExtended({ speedy: false, maxLength: 40 })

0 comments on commit 2463e7f

Please sign in to comment.