@@ -18,11 +18,14 @@ By now I have authored and collaborated on many different libraries and found I
1818
1919## Utilities
2020* [ ` camelCaseProperty(property) ` ] ( #camelcasepropertyproperty )
21+ * [ ` cssifyDeclaration(property, value) ` ] ( #cssifydeclarationproperty-value )
22+ * [ ` cssifyObject(object) ` ] ( #cssifyobjectproperty )
2123* [ ` hyphenateProperty(property) ` ] ( #hyphenatepropertyproperty )
2224* [ ` isPrefixedProperty(property) ` ] ( #isprefixedpropertyproperty )
2325* [ ` isPrefixedValue(value) ` ] ( #isprefixedvaluevalue )
2426* [ ` isUnitlessProperty(property) ` ] ( #isunitlessproperty )
2527* [ ` normalizeProperty(property) ` ] ( #normalizepropertyproperty )
28+ * [ ` resolveArrayValue(property, value) ` ] ( #resolvearrayvalueproperty-value )
2629* [ ` unprefixProperty(property) ` ] ( #unprefixpropertyproperty )
2730* [ ` unprefixValue(value) ` ] ( #unprefixvaluevalue )
2831
@@ -34,26 +37,59 @@ Converts the `property` to camelCase.
3437``` javascript
3538import { camelCaseProperty } from ' css-in-js-utils'
3639
37- console . log ( camelCaseProperty (' padding-top' ) )
40+ camelCaseProperty (' padding-top' )
3841// => 'paddingTop'
3942
40- console . log ( camelCaseProperty (' -webkit-transition' ) )
43+ camelCaseProperty (' -webkit-transition' )
4144// => 'WebkitTransition'
4245```
4346
4447------
4548
49+ ### ` cssifyDeclaration(property, value) `
50+ Generates a CSS declaration (` property ` :` value ` ) string.
51+
52+ ``` javascript
53+ import { cssifyDeclaration } from ' css-in-js-utils'
54+
55+ cssifyDeclaration (' paddingTop' , ' 400px' )
56+ // => 'padding-top:400px'
57+
58+ cssifyDeclaration (' WebkitFlex' , 3 )
59+ // => '-webkit-flex:3'
60+ ```
61+
62+ ------
63+
64+ ### ` cssifyObject(object) `
65+ Generates a CSS string using all key-property pairs in ` object ` .
66+ It automatically removes declarations with value types other than ` number ` and ` string ` .
67+
68+ ``` javascript
69+ import { cssifyObject } from ' css-in-js-utils'
70+
71+ cssifyObject ({
72+ paddingTop: ' 400px' ,
73+ paddingBottom: undefined ,
74+ WebkitFlex: 3 ,
75+ _anyKey: [1 , 2 , 4 ]
76+ })
77+ // => 'padding-top:400px;-webkit-flex:3'
78+ ```
79+
80+ ------
81+
4682### ` hyphenateProperty(property) `
4783Converts the ` property ` to hyphen-case.
4884> Directly mirrors [ hyphenate-style-name] ( https://github.com/rexxars/hyphenate-style-name ) .
4985
5086``` javascript
5187import { hyphenateProperty } from ' css-in-js-utils'
5288
53- console . log ( hyphenateProperty (' paddingTop' ) )
89+ hyphenateProperty (' paddingTop' )
5490// => 'padding-top'
5591
56- console . log ( hyphenateProperty (' WebkitTransition' ) )
92+ hyphenateProperty (' WebkitTransition' )
5793// => '-webkit-transition'
5894```
5995
@@ -65,10 +101,10 @@ Checks if a `property` includes a vendor prefix.
65101``` javascript
66102import { isPrefixedProperty } from ' css-in-js-utils'
67103
68- console . log ( isPrefixedProperty (' paddingTop' ) )
104+ isPrefixedProperty (' paddingTop' )
69105// => false
70106
71- console . log ( isPrefixedProperty (' WebkitTransition' ) )
107+ isPrefixedProperty (' WebkitTransition' )
72108// => true
73109```
74110
@@ -79,11 +115,11 @@ Checks if a `value` includes vendor prefixes.
79115``` javascript
80116import { isPrefixedValue } from ' css-in-js-utils'
81117
82- console . log ( isPrefixedValue (' 200px' ) )
83- console . log ( isPrefixedValue (200 ) )
118+ isPrefixedValue (' 200px' )
119+ isPrefixedValue (200 )
84120// => false
85121
86- console . log ( isPrefixedValue (' -webkit-calc(100% - 50px)' ) )
122+ isPrefixedValue (' -webkit-calc(100% - 50px)' )
87123// => true
88124```
89125
@@ -96,11 +132,11 @@ Checks if a `property` accepts unitless values.
96132``` javascript
97133import { isUnitlessProperty } from ' css-in-js-utils'
98134
99- console . log ( isUnitlessProperty (' width' ) )
135+ isUnitlessProperty (' width' )
100136// => false
101137
102- console . log ( isUnitlessProperty (' flexGrow' ) )
103- console . log ( isUnitlessProperty (' lineHeight' ) )
138+ isUnitlessProperty (' flexGrow' )
139+ isUnitlessProperty (' lineHeight' )
104140// => true
105141```
106142
@@ -113,22 +149,39 @@ Normalizes the `property` by unprefixing **and** camelCasing it.
113149``` javascript
114150import { normalizeProperty } from ' css-in-js-utils'
115151
116- console . log ( normalizeProperty (' -webkit-transition-delay' ) )
152+ normalizeProperty (' -webkit-transition-delay' )
117153// => 'transitionDelay'
118154```
119155
120156------
121157
158+ ### ` resolveArrayValue(property, value) `
159+ Concatenates array values to single CSS value.
160+ > Uses the [ ` hyphenateProperty ` ] ( #hyphenatepropertyproperty ) -method.
161+
162+
163+ ``` javascript
164+ import { resolveArrayValue } from ' css-in-js-utils'
165+
166+ resolveArrayValue (' display' , [ ' -webkit-flex' , ' flex' ])
167+ // => '-webkit-flex;display:flex'
168+
169+ resolveArrayValue (' paddingTop' , [ ' calc(100% - 50px)' , ' 100px' ])
170+ // => 'calc(100% - 50px);padding-top:100px'
171+ ```
172+
173+ ------
174+
122175### ` unprefixProperty(property) `
123176Removes the vendor prefix (if set) from the ` property ` .
124177
125178``` javascript
126179import { unprefixProperty } from ' css-in-js-utils'
127180
128- console . log ( unprefixProperty (' WebkitTransition' ) )
181+ unprefixProperty (' WebkitTransition' )
129182// => 'transition'
130183
131- console . log ( unprefixProperty (' transitionDelay' ) )
184+ unprefixProperty (' transitionDelay' )
132185// => 'transitionDelay'
133186```
134187
@@ -140,10 +193,10 @@ Removes all vendor prefixes (if any) from the `value`.
140193``` javascript
141194import { unprefixValue } from ' css-in-js-utils'
142195
143- console . log ( unprefixValue (' -webkit-calc(-moz-calc(100% - 50px)/2)' ) )
196+ unprefixValue (' -webkit-calc(-moz-calc(100% - 50px)/2)' )
144197// => 'calc(calc(100% - 50px)/2)'
145198
146- console . log ( unprefixValue (' 100px' ) )
199+ unprefixValue (' 100px' )
147200// => '100px'
148201```
149202
0 commit comments