-
Simplification in writing 'space-separated' properties. Now, in jss for defining
padding
we must writepadding: [[ 20, 30 ]]
Using jss-expand you can write properties with one bracket:foo: { padding: [ 5, 10, 5 ] }
and the output will be
foo { padding: 5 10 5; }
Properties, that can be written with short syntax:
margin
padding
border-radius
background-size
background-position
-
Simplified syntax for writing more complex constructions with arrays. In pure jss, if you want to write multi-values for e.g.
transition
you must write:foo: { transition: [[['opacity', '200ms']], [['width', '300ms']]] }
With jss-expand, syntax is simplified and you can write:
foo: { transition: [['opacity', '200ms'], ['width', '300ms']] }
-
You don't need to keep in mind writing order of 'partial' properties, plugin do it for you. So, you can write:
border: { color: '#f00', // You can write properties in any order width: '1px', style: 'solid' }
and CSS output will be:
border: 1px solid #f00;
Properties that supports 'expanded' syntax:
padding
margin
background
border
border-top
border-right
border-bottom
border-left
outline
list-style
transition
animation
box-shadow
text-shadow
flex
For more information see properties section
-
transition: [{ property: 'opacity', duration: '200ms' }, { property: 'width', duration: '300ms' } ]
and CSS output will be:
transition: opacity 200ms, width 300ms;
-
(more about jss fallback you can find here (section 'Fallbacks')):
foo: { background: { image: 'linear-gradient(red, green)' }, fallbacks: { background: { color: 'red', repeat: 'no-repeat', position: [ 0 , 0 ] } } }
and CSS output will be:
foo { background: red no-repeat 0 0; background: linear-gradient(red, green); }
-
Plugin have compatibility with jss-camel-case plugin. So you can write camelCased partial properties inside expanded syntax:
transition: { timingFunction: 'linear', // Camel cased property delay: '300ms', property: 'opacity', duration: '200ms' }
and CSS output will be:
transition: opacity 200ms linear 300ms;
Here are listed all CSS properties, that can be written in expanded way with all 'sub-properties'. Values of those 'sub-properties' are default values. So, if you don't set them - this value will be added in output. So if you write:
padding: {
top: '10px' // Other default values are 0
}
The output will be:
padding: 10px 0 0 0;
If default value is NULL - no default value will be written. For better understanding what any 'sub-property' mean - all 'sub-properties' are 'property' and 'sub-property' names joined together e.g.:
padding: {
top: 0
}
// Is 'padding' + 'top' = 'padding-top'
-
padding: { top: 0, right: 0, bottom: 0, left: 0 }
-
margin: { top: 0, right: 0, bottom: 0, left: 0 }
-
background: { attachment: null, color: null, image: null, position: null, // Can be written without double arrays, like [0, 0] repeat: null }
-
border: { width: null, style: null, color: null }
-
'border-top': { width: null, style: null, color: null }
-
'border-right': { width: null, style: null, color: null }
-
'border-bottom': { width: null, style: null, color: null }
-
'border-left': { width: null, style: null, color: null }
-
outline: { width: null, style: null, color: null }
-
'list-style': { type: null, position: null, image: null }
-
transition: { property: null, duration: null, 'timing-function': null, timingFunction: null, // You can write 'camelCased' property delay: null }
-
animation: { name: null, duration: null, 'timing-function': null, timingFunction: null, // You can write 'camelCased' property delay: null, 'iteration-count': null, iterationCount: null, // You can write 'camelCased' property direction: null, 'fill-mode': null, fillMode: null, // You can write 'camelCased' property 'play-state': null, playState: null // You can write 'camelCased' property }
-
'box-shadow': { x: 0, // X offset for shadow y: 0, // Y offset for shadow blur: null, spread: null, color: null, inset: null // If you want to add inset you need to write "inset: 'inset'" }
-
'text-shadow': { x: 0, // X offset for shadow y: 0, // Y offset for shadow blur: null, color: null }
-
'flex': { grow: null, shrink: null, basis: null }