@@ -6,9 +6,12 @@ Styled primitives for JSS.
66
77## Usage
88
9- ``` jsx
9+ ### Styled function
10+
11+ > Note, that styles applies to the page on the function call, so it's better to use [ injectStyled] ( #injectstyled ) in most cases
1012
11- import Styled from ' jss-styled'
13+ ``` jsx
14+ import { Styled } from ' jss-styled'
1215
1316const styled = Styled ({
1417 h1: {
@@ -32,7 +35,7 @@ const App = () => (
3235)
3336```
3437
35- ### With custom jss setting
38+ ### Styled function With custom jss setting
3639
3740``` jsx
3841import jss from ' jss'
@@ -47,3 +50,92 @@ const Styled = prepareStyled({ jss })
4750
4851...
4952```
53+
54+ ### injectStyled
55+
56+ This wrapper applies styles only on the first component mount.
57+
58+ ``` jsx
59+ import injectStyled from ' jss-styled'
60+
61+
62+ const styles = {
63+ h1: {
64+ fontSize: ' 30px' ,
65+ },
66+ app: {
67+ padding: 10px ,
68+ },
69+ button: {
70+ color : ({ color }) => color
71+ }
72+ }
73+
74+ const App = ({ styled }) => (
75+ < styled .app >
76+ < styled .h1 > Hello World! < / styled .h1 >
77+
78+ < styled .button color= " red" > click me! < / styled .button >
79+ < / styled .app >
80+ )
81+
82+
83+ export default injectStyled (styles)(App)
84+ ```
85+
86+ #### With custom Styled function
87+
88+ ``` jsx
89+ import jss from ' jss'
90+ import preset from ' jss-preset-default'
91+
92+ import injectStyled , { prepareStyled } from ' jss-styled'
93+
94+
95+ const jss = createJSS (preset ())
96+ jss .use (somePlugin ())
97+
98+ const Styled = prepareStyled ({ jss })
99+
100+ const styles = {
101+ h1: {
102+ fontSize: ' 30px' ,
103+ },
104+ app: {
105+ padding: 10px ,
106+ },
107+ button: {
108+ color : ({ color }) => color
109+ }
110+ }
111+
112+ const App = ({ styled }) => (
113+ < styled .app >
114+ < styled .h1 > Hello World! < / styled .h1 >
115+
116+ < styled .button color= " red" > click me! < / styled .button >
117+ < / styled .app >
118+ )
119+
120+
121+ export default injectStyled (styles, Styled)(App)
122+ ```
123+
124+ #### StyledComponent customization
125+
126+ ``` jsx
127+ import StyledApp from ' ./App'
128+
129+
130+ const customStyles = {
131+ app: {
132+ padding: 30px ,
133+ },
134+ }
135+
136+ const CustomApp = () => (
137+ // App will reassign App component styles for .app
138+
139+ < App styles= {customStyles} / >
140+ )
141+ ```
0 commit comments