MCPcopy Create free account
hub / github.com/ptmt/react-native-macos / resolveBoxStyle

Function resolveBoxStyle

Libraries/Inspector/resolveBoxStyle.js:23–52  ·  view source on GitHub ↗

* Resolve a style property into it's component parts, e.g. * * resolveProperties('margin', {margin: 5, marginBottom: 10}) * -> * {top: 5, left: 5, right: 5, bottom: 10} * * If none are set, returns false.

(prefix: string, style: Object)

Source from the content-addressed store, hash-verified

21 * If none are set, returns false.
22 */
23function resolveBoxStyle(prefix: string, style: Object): ?Object {
24 var res = {};
25 var subs = ['top', 'left', 'bottom', 'right'];
26 var set = false;
27 subs.forEach(sub => {
28 res[sub] = style[prefix] || 0;
29 });
30 if (style[prefix]) {
31 set = true;
32 }
33 if (style[prefix + 'Vertical']) {
34 res.top = res.bottom = style[prefix + 'Vertical'];
35 set = true;
36 }
37 if (style[prefix + 'Horizontal']) {
38 res.left = res.right = style[prefix + 'Horizontal'];
39 set = true;
40 }
41 subs.forEach(sub => {
42 var val = style[prefix + capFirst(sub)];
43 if (val) {
44 res[sub] = val;
45 set = true;
46 }
47 });
48 if (!set) {
49 return;
50 }
51 return res;
52}
53
54function capFirst(text) {
55 return text[0].toUpperCase() + text.slice(1);

Callers 2

BoxInspector.jsFile · 0.85
ElementBox.jsFile · 0.85

Calls 1

capFirstFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…