attributes.js
37 lines
| 1 | |
| 2 | export default function getFlexChildAttributes( defaults ) { |
| 3 | const options = [ |
| 4 | 'flexGrow', |
| 5 | 'flexShrink', |
| 6 | 'flexBasis', |
| 7 | 'order', |
| 8 | ]; |
| 9 | |
| 10 | const numberOptions = [ |
| 11 | 'flexGrow', |
| 12 | 'flexShrink', |
| 13 | 'order', |
| 14 | ]; |
| 15 | |
| 16 | const attributes = {}; |
| 17 | |
| 18 | options.forEach( ( option ) => { |
| 19 | attributes[ option ] = { |
| 20 | type: numberOptions.includes( option ) ? 'number' : 'string', |
| 21 | default: defaults[ option ], |
| 22 | }; |
| 23 | |
| 24 | attributes[ option + 'Tablet' ] = { |
| 25 | type: numberOptions.includes( option ) ? 'number' : 'string', |
| 26 | default: defaults[ option + 'Tablet' ], |
| 27 | }; |
| 28 | |
| 29 | attributes[ option + 'Mobile' ] = { |
| 30 | type: numberOptions.includes( option ) ? 'number' : 'string', |
| 31 | default: defaults[ option + 'Mobile' ], |
| 32 | }; |
| 33 | } ); |
| 34 | |
| 35 | return attributes; |
| 36 | } |
| 37 |