PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.3.0
GenerateBlocks v1.3.0
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / src / utils / shorthand-css / index.js
generateblocks / src / utils / shorthand-css Last commit date
index.js 6 years ago
index.js
27 lines
1 export default function shorthandCSS( top, right, bottom, left, unit ) {
2 if ( '' === top && '' === right && '' === bottom && '' === left ) {
3 return;
4 }
5
6 top = ( parseFloat( top ) != 0 && '' !== top ) ? parseFloat( top ) + unit + ' ' : '0 '; // eslint-disable-line eqeqeq
7 right = ( parseFloat( right ) != 0 && '' !== right ) ? parseFloat( right ) + unit + ' ' : '0 '; // eslint-disable-line eqeqeq
8 bottom = ( parseFloat( bottom ) != 0 && '' !== bottom ) ? parseFloat( bottom ) + unit + ' ' : '0 '; // eslint-disable-line eqeqeq
9 left = ( parseFloat( left ) != 0 && '' !== left ) ? parseFloat( left ) + unit + ' ' : '0 '; // eslint-disable-line eqeqeq
10
11 if ( right === left ) {
12 left = '';
13
14 if ( top === bottom ) {
15 bottom = '';
16
17 if ( top === right ) {
18 right = '';
19 }
20 }
21 }
22
23 const output = top + right + bottom + left;
24
25 return output.trim();
26 }
27