9160043d401b46f5d9dbd508d0f375a19d672f49.svn-base
5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _yogaLayoutPrebuilt = _interopRequireDefault(require("yoga-layout-prebuilt"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const applyMarginStyles = (node, style) => {
if (style.margin) {
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_TOP, style.margin);
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_BOTTOM, style.margin);
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_START, style.margin);
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_END, style.margin);
}
if (style.marginX) {
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_START, style.marginX);
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_END, style.marginX);
}
if (style.marginY) {
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_TOP, style.marginY);
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_BOTTOM, style.marginY);
}
if (style.marginTop) {
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_TOP, style.marginTop);
}
if (style.marginBottom) {
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_BOTTOM, style.marginBottom);
}
if (style.marginLeft) {
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_START, style.marginLeft);
}
if (style.marginRight) {
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_END, style.marginRight);
}
};
const applyPaddingStyles = (node, style) => {
if (style.padding) {
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_TOP, style.padding);
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_BOTTOM, style.padding);
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_LEFT, style.padding);
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_RIGHT, style.padding);
}
if (style.paddingX) {
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_LEFT, style.paddingX);
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_RIGHT, style.paddingX);
}
if (style.paddingY) {
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_TOP, style.paddingY);
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_BOTTOM, style.paddingY);
}
if (style.paddingTop) {
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_TOP, style.paddingTop);
}
if (style.paddingBottom) {
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_BOTTOM, style.paddingBottom);
}
if (style.paddingLeft) {
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_LEFT, style.paddingLeft);
}
if (style.paddingRight) {
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_RIGHT, style.paddingRight);
}
};
const applyFlexStyles = (node, style) => {
if (style.flexGrow) {
node.setFlexGrow(style.flexGrow);
}
if (style.flexShrink) {
node.setFlexShrink(style.flexShrink);
}
if (style.flexDirection) {
if (style.flexDirection === 'row') {
node.setFlexDirection(_yogaLayoutPrebuilt.default.FLEX_DIRECTION_ROW);
}
if (style.flexDirection === 'row-reverse') {
node.setFlexDirection(_yogaLayoutPrebuilt.default.FLEX_DIRECTION_ROW_REVERSE);
}
if (style.flexDirection === 'column') {
node.setFlexDirection(_yogaLayoutPrebuilt.default.FLEX_DIRECTION_COLUMN);
}
if (style.flexDirection === 'column-reverse') {
node.setFlexDirection(_yogaLayoutPrebuilt.default.FLEX_DIRECTION_COLUMN_REVERSE);
}
}
if (style.flexBasis !== undefined) {
node.setFlexBasis(style.flexBasis);
}
if (style.alignItems) {
if (style.alignItems === 'flex-start') {
node.setAlignItems(_yogaLayoutPrebuilt.default.ALIGN_FLEX_START);
}
if (style.alignItems === 'center') {
node.setAlignItems(_yogaLayoutPrebuilt.default.ALIGN_CENTER);
}
if (style.alignItems === 'flex-end') {
node.setAlignItems(_yogaLayoutPrebuilt.default.ALIGN_FLEX_END);
}
}
if (style.justifyContent) {
if (style.justifyContent === 'flex-start') {
node.setJustifyContent(_yogaLayoutPrebuilt.default.JUSTIFY_FLEX_START);
}
if (style.justifyContent === 'center') {
node.setJustifyContent(_yogaLayoutPrebuilt.default.JUSTIFY_CENTER);
}
if (style.justifyContent === 'flex-end') {
node.setJustifyContent(_yogaLayoutPrebuilt.default.JUSTIFY_FLEX_END);
}
if (style.justifyContent === 'space-between') {
node.setJustifyContent(_yogaLayoutPrebuilt.default.JUSTIFY_SPACE_BETWEEN);
}
if (style.justifyContent === 'space-around') {
node.setJustifyContent(_yogaLayoutPrebuilt.default.JUSTIFY_SPACE_AROUND);
}
}
};
const applyDimensionStyles = (node, style) => {
if (style.width !== undefined) {
node.setWidth(style.width);
}
if (style.height !== undefined) {
node.setHeight(style.height);
}
if (style.minWidth !== undefined) {
node.setMinWidth(style.minWidth);
}
if (style.minHeight !== undefined) {
node.setMinHeight(style.minHeight);
}
};
var _default = (node, style = {}) => {
applyMarginStyles(node, style);
applyPaddingStyles(node, style);
applyFlexStyles(node, style);
applyDimensionStyles(node, style);
};
exports.default = _default;