MCPcopy
hub / github.com/proksh/atomize / findDirection

Function findDirection

src/style-functions/findDirection.js:4–46  ·  view source on GitHub ↗
(value, property, themeValues = {})

Source from the content-addressed store, hash-verified

2import arrayKeyMapToObject from "./arrayKeyMapToObject";
3
4const 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
48export default findDirection;

Callers 6

computeImageStyleFunction · 0.85
computeDivStyleFunction · 0.85
computeButtonStyleFunction · 0.85
computeIconStyleFunction · 0.85
computeDivStyleFunction · 0.85
computeTextStyleFunction · 0.85

Calls 2

makeResponsiveFunction · 0.85
arrayKeyMapToObjectFunction · 0.85

Tested by

no test coverage detected