(value, property, themeValues = {})
| 2 | import arrayKeyMapToObject from "./arrayKeyMapToObject"; |
| 3 | |
| 4 | const findDirection = (value, property, themeValues = {}) => { |
| 5 | if (!value) { |
| 6 | return; |
| 7 | } |
| 8 | |
| 9 | let style = []; |
| 10 | |
| 11 | if ( |
| 12 | typeof (value.x || value.y || value.b || value.t || value.l || value.r) === |
| 13 | "undefined" |
| 14 | ) { |
| 15 | style.push(makeResponsive(value, property, themeValues)); |
| 16 | } else { |
| 17 | // If x direction exist |
| 18 | if (value.x != "undefined") { |
| 19 | style.push(makeResponsive(value.x, `${property}-left`, themeValues)); |
| 20 | style.push(makeResponsive(value.x, `${property}-right`, themeValues)); |
| 21 | } |
| 22 | // If y direction exist |
| 23 | if (value.y != "undefined") { |
| 24 | style.push(makeResponsive(value.y, `${property}-top`, themeValues)); |
| 25 | style.push(makeResponsive(value.y, `${property}-bottom`, themeValues)); |
| 26 | } |
| 27 | // If t direction exist |
| 28 | if (value.t != "undefined") { |
| 29 | style.push(makeResponsive(value.t, `${property}-top`, themeValues)); |
| 30 | } |
| 31 | // If l direction exist |
| 32 | if (value.l != "undefined") { |
| 33 | style.push(makeResponsive(value.l, `${property}-left`, themeValues)); |
| 34 | } |
| 35 | // If r direction exist |
| 36 | if (value.r != "undefined") { |
| 37 | style.push(makeResponsive(value.r, `${property}-right`, themeValues)); |
| 38 | } |
| 39 | // If b direction exist |
| 40 | if (value.b != "undefined") { |
| 41 | style.push(makeResponsive(value.b, `${property}-bottom`, themeValues)); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | return arrayKeyMapToObject(style); |
| 46 | }; |
| 47 | |
| 48 | export default findDirection; |
no test coverage detected