File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,13 +25,20 @@ Install peer dependencies `react` and `react-dom` in your project.
2525``` js
2626import styled from ' styled-jss'
2727
28- const Button = styled (' button' , {
28+ const Button = styled (' button' )( {
2929 fontSize: 12 ,
3030 color : (props ) => props .theme .textColor
3131})
3232
33+ // You can also use curried interface this way.
34+ const div = styled (' div' )
35+
36+ const Container = div ({
37+ padding: 20
38+ })
39+
3340// Composition.
34- const PrimaryButton = styled (Button, {
41+ const PrimaryButton = styled (Button)( {
3542 color: ' red'
3643})
3744```
@@ -59,14 +66,14 @@ const styled = Styled({
5966 }
6067})
6168
62- const NormalButton = styled (' button' , {
69+ const NormalButton = styled (' button' )( {
6370 composes: ' $baseButton' ,
6471 border: [1 , ' solid' , ' grey' ],
6572 color: ' black'
6673})
6774
6875// Composition - same way.
69- const PrimaryButton = styled (NormalButton, {
76+ const PrimaryButton = styled (NormalButton)( {
7077 color: ' red'
7178})
7279
Original file line number Diff line number Diff line change @@ -40,7 +40,8 @@ const createStyled = (jss: Function) => (baseStyles: BaseStylesType = {}): Style
4040 }
4141
4242 return Object . assign ( (
43- tagNameOrStyledElement : TagNameOrStyledElementType ,
43+ tagNameOrStyledElement : TagNameOrStyledElementType
44+ ) => (
4445 ownStyle : ComponentStyleType
4546 ) : StyledElementType => {
4647 const { tagName, style} = getStyledArgs ( tagNameOrStyledElement )
Original file line number Diff line number Diff line change @@ -2,31 +2,35 @@ import React from 'react'
22import type { StyledType } from '../types'
33
44export default ( styled : StyledType ) => {
5- const App = styled ( 'div' , {
5+ const App = styled ( 'div' ) ( {
66 margin : 50 ,
77 } )
88
9- const Header = styled ( 'header' , {
9+ const Header = styled ( 'header' ) ( {
1010 padding : 10 ,
1111 } )
1212
13- const Section = styled ( 'section' , {
13+ // curried
14+ const section = styled ( 'section' )
15+
16+ const Section = section ( {
1417 color : 'red' ,
1518 } )
1619
17- const AnotherSection = styled ( Section , {
20+ // composition
21+ const AnotherSection = styled ( Section ) ( {
1822 color : 'yellow' ,
1923 } )
2024
21- const Title = styled ( 'h1' , {
25+ const Title = styled ( 'h1' ) ( {
2226 color : 'red' ,
2327 } )
2428
25- const Button = styled ( 'button' , {
29+ // function value
30+ const Button = styled ( 'button' ) ( {
2631 margin : ( { margin = 0 } ) => margin ,
2732 } )
2833
29-
3034 return ( ) => (
3135 < App >
3236 < Header >
You can’t perform that action at this time.
0 commit comments