@cloudflare/component-box 2.3.2-beta → 2.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/es/Box.js +129 -0
- package/es/BoxTheme.js +1 -0
- package/es/index.js +5 -0
- package/es/propertiesSpec.js +347 -0
- package/lib/Box.js +142 -0
- package/lib/BoxTheme.js +16 -0
- package/lib/index.js +29 -0
- package/lib/propertiesSpec.js +361 -0
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.3.6](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/component-box@2.3.2...@cloudflare/component-box@2.3.6) (2021-10-28)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **component-box:** UI-4651: bump package version ([97d767b](http://stash.cfops.it:7999/fe/stratus/commits/97d767b))
|
|
12
|
+
* **stratus:** UI-000: Ran yarn run v1.18.0 ([54f1c7e](http://stash.cfops.it:7999/fe/stratus/commits/54f1c7e))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
## [2.3.2](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/component-box@2.3.1...@cloudflare/component-box@2.3.2) (2021-10-01)
|
|
7
19
|
|
|
8
20
|
**Note:** Version bump only for package @cloudflare/component-box
|
package/es/Box.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? Object(arguments[i]) : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
|
2
|
+
|
|
3
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
+
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { createStyledComponent } from '@cloudflare/style-container';
|
|
7
|
+
import propertiesSpec from './propertiesSpec';
|
|
8
|
+
const propertyNames = Object.keys(propertiesSpec); // Generates styles given the provided props.
|
|
9
|
+
//
|
|
10
|
+
// This is driven by the metadata provided in propertiesSpec
|
|
11
|
+
// and produces a data structure like this:
|
|
12
|
+
//
|
|
13
|
+
// {
|
|
14
|
+
// margin: props.margin || props.theme['margin']
|
|
15
|
+
// width: props.width || props.theme['width']
|
|
16
|
+
// ...
|
|
17
|
+
// }
|
|
18
|
+
//
|
|
19
|
+
// See propertySpec.js for more detail
|
|
20
|
+
//
|
|
21
|
+
|
|
22
|
+
const styles = props => {
|
|
23
|
+
let styles = {};
|
|
24
|
+
const propKeys = Object.keys(props);
|
|
25
|
+
propKeys.forEach(name => {
|
|
26
|
+
// Lookup the spec for the property
|
|
27
|
+
const spec = propertiesSpec[name]; // Ignore non-style props
|
|
28
|
+
|
|
29
|
+
if (spec === undefined) {
|
|
30
|
+
return;
|
|
31
|
+
} // Get the style value from props
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
let value = props[name]; // pre-process the value with all pre-processors
|
|
35
|
+
|
|
36
|
+
if (spec.preprocessWith) {
|
|
37
|
+
spec.preprocessWith.forEach(fn => {
|
|
38
|
+
value = fn(value);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
styles[name] = value;
|
|
43
|
+
}); // Only do checks in dev mode
|
|
44
|
+
|
|
45
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
46
|
+
checkForViolations(styles);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return styles;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const Box = createStyledComponent(styles, 'div');
|
|
53
|
+
|
|
54
|
+
const checkForViolations = props => {
|
|
55
|
+
// Check for conflicts given the spec's conflictsWith property
|
|
56
|
+
// See propertySpec.js for more detail
|
|
57
|
+
propertyNames.forEach(propName => {
|
|
58
|
+
const spec = propertiesSpec[propName];
|
|
59
|
+
if (!props[propName] || !spec.conflictsWith) return;
|
|
60
|
+
spec.conflictsWith.forEach(otherPropName => {
|
|
61
|
+
if (props[propName] && props[otherPropName]) {
|
|
62
|
+
const msg = `${propName} cannot be set in conjunction with ${otherPropName}`;
|
|
63
|
+
console.error(msg);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}); // TODO: To pull this check off, we'll need re-evaluate our baseline.
|
|
67
|
+
// current is 22.5px
|
|
68
|
+
// checkLineHeightViolations(props);
|
|
69
|
+
};
|
|
70
|
+
/*
|
|
71
|
+
const checkLineHeightViolations = props => {
|
|
72
|
+
const rem2px = rem => {
|
|
73
|
+
return parseFloat(rem) * props.fontSize;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const baseline = props.lineHeight * props.fontSize;
|
|
77
|
+
|
|
78
|
+
// Calculate total margin, padding, and border
|
|
79
|
+
let totalMargin = 0;
|
|
80
|
+
if (props.margin) {
|
|
81
|
+
totalMargin = rem2px(props.margin);
|
|
82
|
+
} else {
|
|
83
|
+
totalMargin += rem2px(props.marginTop) || 0;
|
|
84
|
+
totalMargin += rem2px(props.marginBottom) || 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
let totalPadding = 0;
|
|
88
|
+
if (props.padding) {
|
|
89
|
+
totalPadding = rem2px(props.padding);
|
|
90
|
+
} else {
|
|
91
|
+
totalPadding += rem2px(props.paddingTop) || 0;
|
|
92
|
+
totalPadding += rem2px(props.paddingBottom) || 0;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let totalBorder = 0;
|
|
96
|
+
if (props.borderHeight) {
|
|
97
|
+
totalBorder = rem2px(props.borderHeight);
|
|
98
|
+
} else {
|
|
99
|
+
totalBorder += rem2px(props.borderTopHeight) || 0;
|
|
100
|
+
totalBorder += rem2px(props.borderBottomHeight) || 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Warn the user if the total spacing isn't a multiple of the baseline
|
|
104
|
+
const spacing = totalMargin + totalBorder + totalPadding;
|
|
105
|
+
if (spacing && baseline % spacing !== 0) {
|
|
106
|
+
console.warn(
|
|
107
|
+
`Spacing from padding, border, and margin surrounding element should be a multiple of baseline ${baseline}.`
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
*/
|
|
112
|
+
// Extract proptypes from the propertiesSpec
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
const extractPropTypes = () => {
|
|
116
|
+
let propTypes = {}; // Loop through all property specs and pluck the prop type
|
|
117
|
+
|
|
118
|
+
propertyNames.forEach(name => {
|
|
119
|
+
propTypes[name] = propertiesSpec[name].propType;
|
|
120
|
+
});
|
|
121
|
+
return propTypes;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
Box.propTypes = _objectSpread({
|
|
125
|
+
className: PropTypes.string,
|
|
126
|
+
children: PropTypes.node
|
|
127
|
+
}, extractPropTypes());
|
|
128
|
+
Box.displayName = 'Box';
|
|
129
|
+
export default Box;
|
package/es/BoxTheme.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default (({}) => ({}));
|
package/es/index.js
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import { variables } from '@cloudflare/style-const'; // eslint-disable-line behance/no-deprecated
|
|
3
|
+
|
|
4
|
+
import { rem } from 'polished';
|
|
5
|
+
var numberOrString = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
|
|
6
|
+
|
|
7
|
+
const pxToRem = value => {
|
|
8
|
+
if (typeof value === 'number' || /\d+px/.test(value)) {
|
|
9
|
+
return rem(value, variables.fontSize);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return value;
|
|
13
|
+
}; // The export of this module is a datastructuer containing metadata
|
|
14
|
+
// which powers:
|
|
15
|
+
// - the creation of fela style rules
|
|
16
|
+
// - the creation of the theme in BoxTheme
|
|
17
|
+
// - a number of safety checks
|
|
18
|
+
//
|
|
19
|
+
// At a bare minimum, the propType must be specified to support a
|
|
20
|
+
// new style property
|
|
21
|
+
//
|
|
22
|
+
// In addition, several other properties can be specified in the spec.
|
|
23
|
+
//
|
|
24
|
+
// Conflicts with shows an error if the developer tries to use both props.
|
|
25
|
+
//
|
|
26
|
+
// For example, given the following spec:
|
|
27
|
+
//
|
|
28
|
+
// foo: {
|
|
29
|
+
// propType: numberOrString,
|
|
30
|
+
// conflictsWith: [
|
|
31
|
+
// 'bar',
|
|
32
|
+
// ]
|
|
33
|
+
// },
|
|
34
|
+
//
|
|
35
|
+
// passing the foo and bar props to the component will cause a warning.
|
|
36
|
+
//
|
|
37
|
+
// Providing 'preprocessWith' will cause all the provided callbacks
|
|
38
|
+
// to be invoked on the passed prop when building the components styles
|
|
39
|
+
//
|
|
40
|
+
// For example, given the following spec:
|
|
41
|
+
// foo: {
|
|
42
|
+
// propType: number,
|
|
43
|
+
// preprocessWith: [ 'pxToRem' ]
|
|
44
|
+
// },
|
|
45
|
+
//
|
|
46
|
+
// The value of the 'foo' prop will be transformed with pxToRem.
|
|
47
|
+
//
|
|
48
|
+
// The default property is currently un-used. They're left in place
|
|
49
|
+
// in case we arrive upon a performant solution to using them (like
|
|
50
|
+
// generating the code for the Box component).
|
|
51
|
+
//
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
export default {
|
|
55
|
+
margin: {
|
|
56
|
+
propType: numberOrString,
|
|
57
|
+
conflictsWith: ['marginTop', 'marginBottom', 'marginLeft', 'marginRight']
|
|
58
|
+
},
|
|
59
|
+
marginTop: {
|
|
60
|
+
propType: numberOrString,
|
|
61
|
+
default: 0
|
|
62
|
+
},
|
|
63
|
+
marginBottom: {
|
|
64
|
+
propType: numberOrString,
|
|
65
|
+
default: 0
|
|
66
|
+
},
|
|
67
|
+
marginLeft: {
|
|
68
|
+
propType: numberOrString,
|
|
69
|
+
default: 0
|
|
70
|
+
},
|
|
71
|
+
marginRight: {
|
|
72
|
+
propType: numberOrString,
|
|
73
|
+
default: 0
|
|
74
|
+
},
|
|
75
|
+
padding: {
|
|
76
|
+
propType: numberOrString,
|
|
77
|
+
conflictsWith: ['paddingTop', 'paddingBottom', 'paddingLeft', 'paddingRight']
|
|
78
|
+
},
|
|
79
|
+
paddingTop: {
|
|
80
|
+
propType: numberOrString,
|
|
81
|
+
default: 0
|
|
82
|
+
},
|
|
83
|
+
paddingBottom: {
|
|
84
|
+
propType: numberOrString,
|
|
85
|
+
default: 0
|
|
86
|
+
},
|
|
87
|
+
paddingLeft: {
|
|
88
|
+
propType: numberOrString,
|
|
89
|
+
default: 0
|
|
90
|
+
},
|
|
91
|
+
paddingRight: {
|
|
92
|
+
propType: numberOrString,
|
|
93
|
+
default: 0
|
|
94
|
+
},
|
|
95
|
+
overflow: {
|
|
96
|
+
propType: PropTypes.oneOf(['visible', 'hidden', 'scroll', 'auto', 'inherit', 'initial', 'unset'])
|
|
97
|
+
},
|
|
98
|
+
overflowX: {
|
|
99
|
+
propType: PropTypes.oneOf(['visible', 'hidden', 'scroll', 'auto', 'inherit', 'initial', 'unset'])
|
|
100
|
+
},
|
|
101
|
+
border: {
|
|
102
|
+
propType: PropTypes.string,
|
|
103
|
+
conflictsWith: ['borderStyle', 'borderColor', 'borderWidth', 'borderTopColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopStyle', 'borderBottomStyle', 'borderLeftStyle', 'borderRightStyle', 'borderTopWidth', 'borderBottomWidth', 'borderLeftWidth', 'borderRightWidth']
|
|
104
|
+
},
|
|
105
|
+
borderLeft: {
|
|
106
|
+
propType: PropTypes.string,
|
|
107
|
+
conflictsWith: ['borderLeftColor', 'borderLeftStyle', 'borderLeftWidth']
|
|
108
|
+
},
|
|
109
|
+
borderBottom: {
|
|
110
|
+
propType: PropTypes.string,
|
|
111
|
+
conflictsWith: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth']
|
|
112
|
+
},
|
|
113
|
+
borderColor: {
|
|
114
|
+
propType: PropTypes.string,
|
|
115
|
+
conflictsWith: ['borderTopColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor']
|
|
116
|
+
},
|
|
117
|
+
borderTopColor: {
|
|
118
|
+
propType: PropTypes.string
|
|
119
|
+
},
|
|
120
|
+
borderBottomColor: {
|
|
121
|
+
propType: PropTypes.string
|
|
122
|
+
},
|
|
123
|
+
borderLeftColor: {
|
|
124
|
+
propType: PropTypes.string
|
|
125
|
+
},
|
|
126
|
+
borderRightColor: {
|
|
127
|
+
propType: PropTypes.string
|
|
128
|
+
},
|
|
129
|
+
borderStyle: {
|
|
130
|
+
propType: PropTypes.string,
|
|
131
|
+
conflictsWith: ['borderTopStyle', 'borderBottomStyle', 'borderLeftStyle', 'borderRightStyle']
|
|
132
|
+
},
|
|
133
|
+
borderTopStyle: {
|
|
134
|
+
propType: PropTypes.string
|
|
135
|
+
},
|
|
136
|
+
borderBottomStyle: {
|
|
137
|
+
propType: PropTypes.string
|
|
138
|
+
},
|
|
139
|
+
borderLeftStyle: {
|
|
140
|
+
propType: PropTypes.string
|
|
141
|
+
},
|
|
142
|
+
borderRightStyle: {
|
|
143
|
+
propType: PropTypes.string
|
|
144
|
+
},
|
|
145
|
+
borderWidth: {
|
|
146
|
+
propType: PropTypes.number,
|
|
147
|
+
conflictsWith: ['borderTopWidth', 'borderBottomWidth', 'borderLeftWidth', 'borderRightWidth']
|
|
148
|
+
},
|
|
149
|
+
borderTopWidth: {
|
|
150
|
+
propType: PropTypes.number
|
|
151
|
+
},
|
|
152
|
+
borderBottomWidth: {
|
|
153
|
+
propType: PropTypes.number
|
|
154
|
+
},
|
|
155
|
+
borderLeftWidth: {
|
|
156
|
+
propType: PropTypes.number
|
|
157
|
+
},
|
|
158
|
+
borderRightWidth: {
|
|
159
|
+
propType: PropTypes.number
|
|
160
|
+
},
|
|
161
|
+
lineHeight: {
|
|
162
|
+
propType: PropTypes.number,
|
|
163
|
+
default: variables.lineHeight
|
|
164
|
+
},
|
|
165
|
+
fontSize: {
|
|
166
|
+
propType: numberOrString,
|
|
167
|
+
default: variables.fontSize
|
|
168
|
+
},
|
|
169
|
+
fontWeight: {
|
|
170
|
+
propType: numberOrString,
|
|
171
|
+
default: variables.fontWeight
|
|
172
|
+
},
|
|
173
|
+
fontFamily: {
|
|
174
|
+
propType: PropTypes.string,
|
|
175
|
+
default: variables.fontFamily
|
|
176
|
+
},
|
|
177
|
+
color: {
|
|
178
|
+
propType: PropTypes.string,
|
|
179
|
+
default: variables.colors.gray[1]
|
|
180
|
+
},
|
|
181
|
+
backgroundColor: {
|
|
182
|
+
propType: PropTypes.string,
|
|
183
|
+
default: 'transparent'
|
|
184
|
+
},
|
|
185
|
+
backgroundImage: {
|
|
186
|
+
propType: PropTypes.string
|
|
187
|
+
},
|
|
188
|
+
backgroundPosition: {
|
|
189
|
+
propType: PropTypes.string
|
|
190
|
+
},
|
|
191
|
+
backgroundPositionX: {
|
|
192
|
+
propType: PropTypes.string
|
|
193
|
+
},
|
|
194
|
+
backgroundPositionY: {
|
|
195
|
+
propType: PropTypes.string
|
|
196
|
+
},
|
|
197
|
+
display: {
|
|
198
|
+
propType: PropTypes.oneOf(['inline', 'block', 'inline-block', 'flex', 'inline-flex', 'table', 'table-cell', 'none']),
|
|
199
|
+
default: 'block'
|
|
200
|
+
},
|
|
201
|
+
position: {
|
|
202
|
+
propType: PropTypes.oneOf(['static', 'relative', 'absolute', 'fixed']),
|
|
203
|
+
default: 'static'
|
|
204
|
+
},
|
|
205
|
+
float: {
|
|
206
|
+
propType: PropTypes.oneOf(['left', 'right', 'none', 'inline-start', 'inline-end'])
|
|
207
|
+
},
|
|
208
|
+
top: {
|
|
209
|
+
propType: numberOrString,
|
|
210
|
+
default: 'auto',
|
|
211
|
+
preprocessWith: [pxToRem]
|
|
212
|
+
},
|
|
213
|
+
bottom: {
|
|
214
|
+
propType: numberOrString,
|
|
215
|
+
default: 'auto',
|
|
216
|
+
preprocessWith: [pxToRem]
|
|
217
|
+
},
|
|
218
|
+
left: {
|
|
219
|
+
propType: numberOrString,
|
|
220
|
+
default: 'auto',
|
|
221
|
+
preprocessWith: [pxToRem]
|
|
222
|
+
},
|
|
223
|
+
right: {
|
|
224
|
+
propType: numberOrString,
|
|
225
|
+
default: 'auto',
|
|
226
|
+
preprocessWith: [pxToRem]
|
|
227
|
+
},
|
|
228
|
+
width: {
|
|
229
|
+
propType: numberOrString,
|
|
230
|
+
default: 'auto',
|
|
231
|
+
preprocessWith: [pxToRem]
|
|
232
|
+
},
|
|
233
|
+
height: {
|
|
234
|
+
propType: numberOrString,
|
|
235
|
+
default: 'auto',
|
|
236
|
+
preprocessWith: [pxToRem]
|
|
237
|
+
},
|
|
238
|
+
minWidth: {
|
|
239
|
+
propType: numberOrString,
|
|
240
|
+
default: 0,
|
|
241
|
+
preprocessWith: [pxToRem]
|
|
242
|
+
},
|
|
243
|
+
minHeight: {
|
|
244
|
+
propType: numberOrString,
|
|
245
|
+
default: 0,
|
|
246
|
+
preprocessWith: [pxToRem]
|
|
247
|
+
},
|
|
248
|
+
maxWidth: {
|
|
249
|
+
propType: numberOrString,
|
|
250
|
+
default: 0,
|
|
251
|
+
preprocessWith: [pxToRem]
|
|
252
|
+
},
|
|
253
|
+
maxHeight: {
|
|
254
|
+
propType: numberOrString,
|
|
255
|
+
default: 0,
|
|
256
|
+
preprocessWith: [pxToRem]
|
|
257
|
+
},
|
|
258
|
+
verticalAlign: {
|
|
259
|
+
propType: numberOrString,
|
|
260
|
+
default: 'baseline'
|
|
261
|
+
},
|
|
262
|
+
transform: {
|
|
263
|
+
propType: PropTypes.string
|
|
264
|
+
},
|
|
265
|
+
flexDirection: {
|
|
266
|
+
propType: PropTypes.oneOf(['row', 'row-reverse', 'column', 'column-reverse']),
|
|
267
|
+
default: 'row'
|
|
268
|
+
},
|
|
269
|
+
flexWrap: {
|
|
270
|
+
propType: PropTypes.oneOf(['nowrap', 'wrap', 'wrap-reverse']),
|
|
271
|
+
default: 'nowrap'
|
|
272
|
+
},
|
|
273
|
+
justifyContent: {
|
|
274
|
+
propType: PropTypes.oneOf(['flex-start', 'flex-end', 'center', 'space-between', 'space-around']),
|
|
275
|
+
default: 'flex-start'
|
|
276
|
+
},
|
|
277
|
+
alignItems: {
|
|
278
|
+
propType: PropTypes.oneOf(['flex-start', 'flex-end', 'center', 'baseline', 'stretch']),
|
|
279
|
+
default: 'stretch'
|
|
280
|
+
},
|
|
281
|
+
alignContent: {
|
|
282
|
+
propType: PropTypes.oneOf(['flex-start', 'flex-end', 'center', 'space-between', 'space-around', 'stretch']),
|
|
283
|
+
default: 'stretch'
|
|
284
|
+
},
|
|
285
|
+
order: {
|
|
286
|
+
propType: PropTypes.number,
|
|
287
|
+
default: 0
|
|
288
|
+
},
|
|
289
|
+
flexGrow: {
|
|
290
|
+
propType: PropTypes.number,
|
|
291
|
+
default: 0
|
|
292
|
+
},
|
|
293
|
+
flexShrink: {
|
|
294
|
+
propType: PropTypes.number,
|
|
295
|
+
default: 1
|
|
296
|
+
},
|
|
297
|
+
flexBasis: {
|
|
298
|
+
propType: numberOrString,
|
|
299
|
+
default: 'auto'
|
|
300
|
+
},
|
|
301
|
+
flex: {
|
|
302
|
+
propType: PropTypes.string
|
|
303
|
+
},
|
|
304
|
+
alignSelf: {
|
|
305
|
+
propType: PropTypes.oneOf(['auto', 'flex-start', 'flex-end', 'center', 'baseline', 'stretch']),
|
|
306
|
+
default: 'auto'
|
|
307
|
+
},
|
|
308
|
+
zIndex: {
|
|
309
|
+
propType: numberOrString,
|
|
310
|
+
default: 'auto'
|
|
311
|
+
},
|
|
312
|
+
textAlign: {
|
|
313
|
+
propType: PropTypes.oneOf(['left', 'right', 'center', 'justify', 'justify-all', 'start', 'end', 'match-parent']),
|
|
314
|
+
default: 'start'
|
|
315
|
+
},
|
|
316
|
+
textDecoration: {
|
|
317
|
+
propType: PropTypes.oneOf(['none', 'underline', 'overline', 'line-through', 'initial', 'inherit']),
|
|
318
|
+
default: 'initial'
|
|
319
|
+
},
|
|
320
|
+
textTransform: {
|
|
321
|
+
propType: PropTypes.oneOf(['none', 'capitalize', 'uppercase', 'lowercase', 'full-width']),
|
|
322
|
+
default: 'none'
|
|
323
|
+
},
|
|
324
|
+
opacity: {
|
|
325
|
+
propType: numberOrString,
|
|
326
|
+
default: 1.0
|
|
327
|
+
},
|
|
328
|
+
userSelect: {
|
|
329
|
+
propType: PropTypes.oneOf(['none', 'auto', 'text', 'container', 'all']),
|
|
330
|
+
default: 'auto'
|
|
331
|
+
},
|
|
332
|
+
wordWrap: {
|
|
333
|
+
propType: PropTypes.oneOf(['normal', 'break-word', 'inherit', 'initial', 'unset']),
|
|
334
|
+
default: 'normal'
|
|
335
|
+
},
|
|
336
|
+
clear: {
|
|
337
|
+
propType: PropTypes.oneOf(['none', 'left', 'right', 'both', 'initial', 'inherit']),
|
|
338
|
+
default: 'none'
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
/*
|
|
342
|
+
* Need support for:
|
|
343
|
+
content
|
|
344
|
+
outline
|
|
345
|
+
border-radius
|
|
346
|
+
box-shadow
|
|
347
|
+
*/
|
package/lib/Box.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
|
|
10
|
+
var _styleContainer = require("@cloudflare/style-container");
|
|
11
|
+
|
|
12
|
+
var _propertiesSpec = _interopRequireDefault(require("./propertiesSpec"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? Object(arguments[i]) : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
|
17
|
+
|
|
18
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
+
|
|
20
|
+
var propertyNames = Object.keys(_propertiesSpec.default); // Generates styles given the provided props.
|
|
21
|
+
//
|
|
22
|
+
// This is driven by the metadata provided in propertiesSpec
|
|
23
|
+
// and produces a data structure like this:
|
|
24
|
+
//
|
|
25
|
+
// {
|
|
26
|
+
// margin: props.margin || props.theme['margin']
|
|
27
|
+
// width: props.width || props.theme['width']
|
|
28
|
+
// ...
|
|
29
|
+
// }
|
|
30
|
+
//
|
|
31
|
+
// See propertySpec.js for more detail
|
|
32
|
+
//
|
|
33
|
+
|
|
34
|
+
var styles = function styles(props) {
|
|
35
|
+
var styles = {};
|
|
36
|
+
var propKeys = Object.keys(props);
|
|
37
|
+
propKeys.forEach(function (name) {
|
|
38
|
+
// Lookup the spec for the property
|
|
39
|
+
var spec = _propertiesSpec.default[name]; // Ignore non-style props
|
|
40
|
+
|
|
41
|
+
if (spec === undefined) {
|
|
42
|
+
return;
|
|
43
|
+
} // Get the style value from props
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
var value = props[name]; // pre-process the value with all pre-processors
|
|
47
|
+
|
|
48
|
+
if (spec.preprocessWith) {
|
|
49
|
+
spec.preprocessWith.forEach(function (fn) {
|
|
50
|
+
value = fn(value);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
styles[name] = value;
|
|
55
|
+
}); // Only do checks in dev mode
|
|
56
|
+
|
|
57
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
58
|
+
checkForViolations(styles);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return styles;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
var Box = (0, _styleContainer.createStyledComponent)(styles, 'div');
|
|
65
|
+
|
|
66
|
+
var checkForViolations = function checkForViolations(props) {
|
|
67
|
+
// Check for conflicts given the spec's conflictsWith property
|
|
68
|
+
// See propertySpec.js for more detail
|
|
69
|
+
propertyNames.forEach(function (propName) {
|
|
70
|
+
var spec = _propertiesSpec.default[propName];
|
|
71
|
+
if (!props[propName] || !spec.conflictsWith) return;
|
|
72
|
+
spec.conflictsWith.forEach(function (otherPropName) {
|
|
73
|
+
if (props[propName] && props[otherPropName]) {
|
|
74
|
+
var msg = "".concat(propName, " cannot be set in conjunction with ").concat(otherPropName);
|
|
75
|
+
console.error(msg);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}); // TODO: To pull this check off, we'll need re-evaluate our baseline.
|
|
79
|
+
// current is 22.5px
|
|
80
|
+
// checkLineHeightViolations(props);
|
|
81
|
+
};
|
|
82
|
+
/*
|
|
83
|
+
const checkLineHeightViolations = props => {
|
|
84
|
+
const rem2px = rem => {
|
|
85
|
+
return parseFloat(rem) * props.fontSize;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const baseline = props.lineHeight * props.fontSize;
|
|
89
|
+
|
|
90
|
+
// Calculate total margin, padding, and border
|
|
91
|
+
let totalMargin = 0;
|
|
92
|
+
if (props.margin) {
|
|
93
|
+
totalMargin = rem2px(props.margin);
|
|
94
|
+
} else {
|
|
95
|
+
totalMargin += rem2px(props.marginTop) || 0;
|
|
96
|
+
totalMargin += rem2px(props.marginBottom) || 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let totalPadding = 0;
|
|
100
|
+
if (props.padding) {
|
|
101
|
+
totalPadding = rem2px(props.padding);
|
|
102
|
+
} else {
|
|
103
|
+
totalPadding += rem2px(props.paddingTop) || 0;
|
|
104
|
+
totalPadding += rem2px(props.paddingBottom) || 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
let totalBorder = 0;
|
|
108
|
+
if (props.borderHeight) {
|
|
109
|
+
totalBorder = rem2px(props.borderHeight);
|
|
110
|
+
} else {
|
|
111
|
+
totalBorder += rem2px(props.borderTopHeight) || 0;
|
|
112
|
+
totalBorder += rem2px(props.borderBottomHeight) || 0;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Warn the user if the total spacing isn't a multiple of the baseline
|
|
116
|
+
const spacing = totalMargin + totalBorder + totalPadding;
|
|
117
|
+
if (spacing && baseline % spacing !== 0) {
|
|
118
|
+
console.warn(
|
|
119
|
+
`Spacing from padding, border, and margin surrounding element should be a multiple of baseline ${baseline}.`
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
*/
|
|
124
|
+
// Extract proptypes from the propertiesSpec
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
var extractPropTypes = function extractPropTypes() {
|
|
128
|
+
var propTypes = {}; // Loop through all property specs and pluck the prop type
|
|
129
|
+
|
|
130
|
+
propertyNames.forEach(function (name) {
|
|
131
|
+
propTypes[name] = _propertiesSpec.default[name].propType;
|
|
132
|
+
});
|
|
133
|
+
return propTypes;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
Box.propTypes = _objectSpread({
|
|
137
|
+
className: _propTypes.default.string,
|
|
138
|
+
children: _propTypes.default.node
|
|
139
|
+
}, extractPropTypes());
|
|
140
|
+
Box.displayName = 'Box';
|
|
141
|
+
var _default = Box;
|
|
142
|
+
exports.default = _default;
|
package/lib/BoxTheme.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure undefined"); }
|
|
9
|
+
|
|
10
|
+
var _default = function _default(_ref) {
|
|
11
|
+
_objectDestructuringEmpty(_ref);
|
|
12
|
+
|
|
13
|
+
return {};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.default = _default;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "BoxUnstyled", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _Box.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "BoxTheme", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _BoxTheme.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
exports.Box = void 0;
|
|
19
|
+
|
|
20
|
+
var _styleContainer = require("@cloudflare/style-container");
|
|
21
|
+
|
|
22
|
+
var _Box = _interopRequireDefault(require("./Box"));
|
|
23
|
+
|
|
24
|
+
var _BoxTheme = _interopRequireDefault(require("./BoxTheme"));
|
|
25
|
+
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
|
|
28
|
+
var Box = (0, _styleContainer.applyTheme)(_Box.default, _BoxTheme.default);
|
|
29
|
+
exports.Box = Box;
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
|
|
10
|
+
var _styleConst = require("@cloudflare/style-const");
|
|
11
|
+
|
|
12
|
+
var _polished = require("polished");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
// eslint-disable-line behance/no-deprecated
|
|
17
|
+
var numberOrString = _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]);
|
|
18
|
+
|
|
19
|
+
var pxToRem = function pxToRem(value) {
|
|
20
|
+
if (typeof value === 'number' || /\d+px/.test(value)) {
|
|
21
|
+
return (0, _polished.rem)(value, _styleConst.variables.fontSize);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return value;
|
|
25
|
+
}; // The export of this module is a datastructuer containing metadata
|
|
26
|
+
// which powers:
|
|
27
|
+
// - the creation of fela style rules
|
|
28
|
+
// - the creation of the theme in BoxTheme
|
|
29
|
+
// - a number of safety checks
|
|
30
|
+
//
|
|
31
|
+
// At a bare minimum, the propType must be specified to support a
|
|
32
|
+
// new style property
|
|
33
|
+
//
|
|
34
|
+
// In addition, several other properties can be specified in the spec.
|
|
35
|
+
//
|
|
36
|
+
// Conflicts with shows an error if the developer tries to use both props.
|
|
37
|
+
//
|
|
38
|
+
// For example, given the following spec:
|
|
39
|
+
//
|
|
40
|
+
// foo: {
|
|
41
|
+
// propType: numberOrString,
|
|
42
|
+
// conflictsWith: [
|
|
43
|
+
// 'bar',
|
|
44
|
+
// ]
|
|
45
|
+
// },
|
|
46
|
+
//
|
|
47
|
+
// passing the foo and bar props to the component will cause a warning.
|
|
48
|
+
//
|
|
49
|
+
// Providing 'preprocessWith' will cause all the provided callbacks
|
|
50
|
+
// to be invoked on the passed prop when building the components styles
|
|
51
|
+
//
|
|
52
|
+
// For example, given the following spec:
|
|
53
|
+
// foo: {
|
|
54
|
+
// propType: number,
|
|
55
|
+
// preprocessWith: [ 'pxToRem' ]
|
|
56
|
+
// },
|
|
57
|
+
//
|
|
58
|
+
// The value of the 'foo' prop will be transformed with pxToRem.
|
|
59
|
+
//
|
|
60
|
+
// The default property is currently un-used. They're left in place
|
|
61
|
+
// in case we arrive upon a performant solution to using them (like
|
|
62
|
+
// generating the code for the Box component).
|
|
63
|
+
//
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
var _default = {
|
|
67
|
+
margin: {
|
|
68
|
+
propType: numberOrString,
|
|
69
|
+
conflictsWith: ['marginTop', 'marginBottom', 'marginLeft', 'marginRight']
|
|
70
|
+
},
|
|
71
|
+
marginTop: {
|
|
72
|
+
propType: numberOrString,
|
|
73
|
+
default: 0
|
|
74
|
+
},
|
|
75
|
+
marginBottom: {
|
|
76
|
+
propType: numberOrString,
|
|
77
|
+
default: 0
|
|
78
|
+
},
|
|
79
|
+
marginLeft: {
|
|
80
|
+
propType: numberOrString,
|
|
81
|
+
default: 0
|
|
82
|
+
},
|
|
83
|
+
marginRight: {
|
|
84
|
+
propType: numberOrString,
|
|
85
|
+
default: 0
|
|
86
|
+
},
|
|
87
|
+
padding: {
|
|
88
|
+
propType: numberOrString,
|
|
89
|
+
conflictsWith: ['paddingTop', 'paddingBottom', 'paddingLeft', 'paddingRight']
|
|
90
|
+
},
|
|
91
|
+
paddingTop: {
|
|
92
|
+
propType: numberOrString,
|
|
93
|
+
default: 0
|
|
94
|
+
},
|
|
95
|
+
paddingBottom: {
|
|
96
|
+
propType: numberOrString,
|
|
97
|
+
default: 0
|
|
98
|
+
},
|
|
99
|
+
paddingLeft: {
|
|
100
|
+
propType: numberOrString,
|
|
101
|
+
default: 0
|
|
102
|
+
},
|
|
103
|
+
paddingRight: {
|
|
104
|
+
propType: numberOrString,
|
|
105
|
+
default: 0
|
|
106
|
+
},
|
|
107
|
+
overflow: {
|
|
108
|
+
propType: _propTypes.default.oneOf(['visible', 'hidden', 'scroll', 'auto', 'inherit', 'initial', 'unset'])
|
|
109
|
+
},
|
|
110
|
+
overflowX: {
|
|
111
|
+
propType: _propTypes.default.oneOf(['visible', 'hidden', 'scroll', 'auto', 'inherit', 'initial', 'unset'])
|
|
112
|
+
},
|
|
113
|
+
border: {
|
|
114
|
+
propType: _propTypes.default.string,
|
|
115
|
+
conflictsWith: ['borderStyle', 'borderColor', 'borderWidth', 'borderTopColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopStyle', 'borderBottomStyle', 'borderLeftStyle', 'borderRightStyle', 'borderTopWidth', 'borderBottomWidth', 'borderLeftWidth', 'borderRightWidth']
|
|
116
|
+
},
|
|
117
|
+
borderLeft: {
|
|
118
|
+
propType: _propTypes.default.string,
|
|
119
|
+
conflictsWith: ['borderLeftColor', 'borderLeftStyle', 'borderLeftWidth']
|
|
120
|
+
},
|
|
121
|
+
borderBottom: {
|
|
122
|
+
propType: _propTypes.default.string,
|
|
123
|
+
conflictsWith: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth']
|
|
124
|
+
},
|
|
125
|
+
borderColor: {
|
|
126
|
+
propType: _propTypes.default.string,
|
|
127
|
+
conflictsWith: ['borderTopColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor']
|
|
128
|
+
},
|
|
129
|
+
borderTopColor: {
|
|
130
|
+
propType: _propTypes.default.string
|
|
131
|
+
},
|
|
132
|
+
borderBottomColor: {
|
|
133
|
+
propType: _propTypes.default.string
|
|
134
|
+
},
|
|
135
|
+
borderLeftColor: {
|
|
136
|
+
propType: _propTypes.default.string
|
|
137
|
+
},
|
|
138
|
+
borderRightColor: {
|
|
139
|
+
propType: _propTypes.default.string
|
|
140
|
+
},
|
|
141
|
+
borderStyle: {
|
|
142
|
+
propType: _propTypes.default.string,
|
|
143
|
+
conflictsWith: ['borderTopStyle', 'borderBottomStyle', 'borderLeftStyle', 'borderRightStyle']
|
|
144
|
+
},
|
|
145
|
+
borderTopStyle: {
|
|
146
|
+
propType: _propTypes.default.string
|
|
147
|
+
},
|
|
148
|
+
borderBottomStyle: {
|
|
149
|
+
propType: _propTypes.default.string
|
|
150
|
+
},
|
|
151
|
+
borderLeftStyle: {
|
|
152
|
+
propType: _propTypes.default.string
|
|
153
|
+
},
|
|
154
|
+
borderRightStyle: {
|
|
155
|
+
propType: _propTypes.default.string
|
|
156
|
+
},
|
|
157
|
+
borderWidth: {
|
|
158
|
+
propType: _propTypes.default.number,
|
|
159
|
+
conflictsWith: ['borderTopWidth', 'borderBottomWidth', 'borderLeftWidth', 'borderRightWidth']
|
|
160
|
+
},
|
|
161
|
+
borderTopWidth: {
|
|
162
|
+
propType: _propTypes.default.number
|
|
163
|
+
},
|
|
164
|
+
borderBottomWidth: {
|
|
165
|
+
propType: _propTypes.default.number
|
|
166
|
+
},
|
|
167
|
+
borderLeftWidth: {
|
|
168
|
+
propType: _propTypes.default.number
|
|
169
|
+
},
|
|
170
|
+
borderRightWidth: {
|
|
171
|
+
propType: _propTypes.default.number
|
|
172
|
+
},
|
|
173
|
+
lineHeight: {
|
|
174
|
+
propType: _propTypes.default.number,
|
|
175
|
+
default: _styleConst.variables.lineHeight
|
|
176
|
+
},
|
|
177
|
+
fontSize: {
|
|
178
|
+
propType: numberOrString,
|
|
179
|
+
default: _styleConst.variables.fontSize
|
|
180
|
+
},
|
|
181
|
+
fontWeight: {
|
|
182
|
+
propType: numberOrString,
|
|
183
|
+
default: _styleConst.variables.fontWeight
|
|
184
|
+
},
|
|
185
|
+
fontFamily: {
|
|
186
|
+
propType: _propTypes.default.string,
|
|
187
|
+
default: _styleConst.variables.fontFamily
|
|
188
|
+
},
|
|
189
|
+
color: {
|
|
190
|
+
propType: _propTypes.default.string,
|
|
191
|
+
default: _styleConst.variables.colors.gray[1]
|
|
192
|
+
},
|
|
193
|
+
backgroundColor: {
|
|
194
|
+
propType: _propTypes.default.string,
|
|
195
|
+
default: 'transparent'
|
|
196
|
+
},
|
|
197
|
+
backgroundImage: {
|
|
198
|
+
propType: _propTypes.default.string
|
|
199
|
+
},
|
|
200
|
+
backgroundPosition: {
|
|
201
|
+
propType: _propTypes.default.string
|
|
202
|
+
},
|
|
203
|
+
backgroundPositionX: {
|
|
204
|
+
propType: _propTypes.default.string
|
|
205
|
+
},
|
|
206
|
+
backgroundPositionY: {
|
|
207
|
+
propType: _propTypes.default.string
|
|
208
|
+
},
|
|
209
|
+
display: {
|
|
210
|
+
propType: _propTypes.default.oneOf(['inline', 'block', 'inline-block', 'flex', 'inline-flex', 'table', 'table-cell', 'none']),
|
|
211
|
+
default: 'block'
|
|
212
|
+
},
|
|
213
|
+
position: {
|
|
214
|
+
propType: _propTypes.default.oneOf(['static', 'relative', 'absolute', 'fixed']),
|
|
215
|
+
default: 'static'
|
|
216
|
+
},
|
|
217
|
+
float: {
|
|
218
|
+
propType: _propTypes.default.oneOf(['left', 'right', 'none', 'inline-start', 'inline-end'])
|
|
219
|
+
},
|
|
220
|
+
top: {
|
|
221
|
+
propType: numberOrString,
|
|
222
|
+
default: 'auto',
|
|
223
|
+
preprocessWith: [pxToRem]
|
|
224
|
+
},
|
|
225
|
+
bottom: {
|
|
226
|
+
propType: numberOrString,
|
|
227
|
+
default: 'auto',
|
|
228
|
+
preprocessWith: [pxToRem]
|
|
229
|
+
},
|
|
230
|
+
left: {
|
|
231
|
+
propType: numberOrString,
|
|
232
|
+
default: 'auto',
|
|
233
|
+
preprocessWith: [pxToRem]
|
|
234
|
+
},
|
|
235
|
+
right: {
|
|
236
|
+
propType: numberOrString,
|
|
237
|
+
default: 'auto',
|
|
238
|
+
preprocessWith: [pxToRem]
|
|
239
|
+
},
|
|
240
|
+
width: {
|
|
241
|
+
propType: numberOrString,
|
|
242
|
+
default: 'auto',
|
|
243
|
+
preprocessWith: [pxToRem]
|
|
244
|
+
},
|
|
245
|
+
height: {
|
|
246
|
+
propType: numberOrString,
|
|
247
|
+
default: 'auto',
|
|
248
|
+
preprocessWith: [pxToRem]
|
|
249
|
+
},
|
|
250
|
+
minWidth: {
|
|
251
|
+
propType: numberOrString,
|
|
252
|
+
default: 0,
|
|
253
|
+
preprocessWith: [pxToRem]
|
|
254
|
+
},
|
|
255
|
+
minHeight: {
|
|
256
|
+
propType: numberOrString,
|
|
257
|
+
default: 0,
|
|
258
|
+
preprocessWith: [pxToRem]
|
|
259
|
+
},
|
|
260
|
+
maxWidth: {
|
|
261
|
+
propType: numberOrString,
|
|
262
|
+
default: 0,
|
|
263
|
+
preprocessWith: [pxToRem]
|
|
264
|
+
},
|
|
265
|
+
maxHeight: {
|
|
266
|
+
propType: numberOrString,
|
|
267
|
+
default: 0,
|
|
268
|
+
preprocessWith: [pxToRem]
|
|
269
|
+
},
|
|
270
|
+
verticalAlign: {
|
|
271
|
+
propType: numberOrString,
|
|
272
|
+
default: 'baseline'
|
|
273
|
+
},
|
|
274
|
+
transform: {
|
|
275
|
+
propType: _propTypes.default.string
|
|
276
|
+
},
|
|
277
|
+
flexDirection: {
|
|
278
|
+
propType: _propTypes.default.oneOf(['row', 'row-reverse', 'column', 'column-reverse']),
|
|
279
|
+
default: 'row'
|
|
280
|
+
},
|
|
281
|
+
flexWrap: {
|
|
282
|
+
propType: _propTypes.default.oneOf(['nowrap', 'wrap', 'wrap-reverse']),
|
|
283
|
+
default: 'nowrap'
|
|
284
|
+
},
|
|
285
|
+
justifyContent: {
|
|
286
|
+
propType: _propTypes.default.oneOf(['flex-start', 'flex-end', 'center', 'space-between', 'space-around']),
|
|
287
|
+
default: 'flex-start'
|
|
288
|
+
},
|
|
289
|
+
alignItems: {
|
|
290
|
+
propType: _propTypes.default.oneOf(['flex-start', 'flex-end', 'center', 'baseline', 'stretch']),
|
|
291
|
+
default: 'stretch'
|
|
292
|
+
},
|
|
293
|
+
alignContent: {
|
|
294
|
+
propType: _propTypes.default.oneOf(['flex-start', 'flex-end', 'center', 'space-between', 'space-around', 'stretch']),
|
|
295
|
+
default: 'stretch'
|
|
296
|
+
},
|
|
297
|
+
order: {
|
|
298
|
+
propType: _propTypes.default.number,
|
|
299
|
+
default: 0
|
|
300
|
+
},
|
|
301
|
+
flexGrow: {
|
|
302
|
+
propType: _propTypes.default.number,
|
|
303
|
+
default: 0
|
|
304
|
+
},
|
|
305
|
+
flexShrink: {
|
|
306
|
+
propType: _propTypes.default.number,
|
|
307
|
+
default: 1
|
|
308
|
+
},
|
|
309
|
+
flexBasis: {
|
|
310
|
+
propType: numberOrString,
|
|
311
|
+
default: 'auto'
|
|
312
|
+
},
|
|
313
|
+
flex: {
|
|
314
|
+
propType: _propTypes.default.string
|
|
315
|
+
},
|
|
316
|
+
alignSelf: {
|
|
317
|
+
propType: _propTypes.default.oneOf(['auto', 'flex-start', 'flex-end', 'center', 'baseline', 'stretch']),
|
|
318
|
+
default: 'auto'
|
|
319
|
+
},
|
|
320
|
+
zIndex: {
|
|
321
|
+
propType: numberOrString,
|
|
322
|
+
default: 'auto'
|
|
323
|
+
},
|
|
324
|
+
textAlign: {
|
|
325
|
+
propType: _propTypes.default.oneOf(['left', 'right', 'center', 'justify', 'justify-all', 'start', 'end', 'match-parent']),
|
|
326
|
+
default: 'start'
|
|
327
|
+
},
|
|
328
|
+
textDecoration: {
|
|
329
|
+
propType: _propTypes.default.oneOf(['none', 'underline', 'overline', 'line-through', 'initial', 'inherit']),
|
|
330
|
+
default: 'initial'
|
|
331
|
+
},
|
|
332
|
+
textTransform: {
|
|
333
|
+
propType: _propTypes.default.oneOf(['none', 'capitalize', 'uppercase', 'lowercase', 'full-width']),
|
|
334
|
+
default: 'none'
|
|
335
|
+
},
|
|
336
|
+
opacity: {
|
|
337
|
+
propType: numberOrString,
|
|
338
|
+
default: 1.0
|
|
339
|
+
},
|
|
340
|
+
userSelect: {
|
|
341
|
+
propType: _propTypes.default.oneOf(['none', 'auto', 'text', 'container', 'all']),
|
|
342
|
+
default: 'auto'
|
|
343
|
+
},
|
|
344
|
+
wordWrap: {
|
|
345
|
+
propType: _propTypes.default.oneOf(['normal', 'break-word', 'inherit', 'initial', 'unset']),
|
|
346
|
+
default: 'normal'
|
|
347
|
+
},
|
|
348
|
+
clear: {
|
|
349
|
+
propType: _propTypes.default.oneOf(['none', 'left', 'right', 'both', 'initial', 'inherit']),
|
|
350
|
+
default: 'none'
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
/*
|
|
354
|
+
* Need support for:
|
|
355
|
+
content
|
|
356
|
+
outline
|
|
357
|
+
border-radius
|
|
358
|
+
box-shadow
|
|
359
|
+
*/
|
|
360
|
+
|
|
361
|
+
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/component-box",
|
|
3
3
|
"description": "Cloudflare Box Component\n\nThis is styling component similar to cf-component-flex which allows for arbitrary styling.\n\n This component should only be used when the built in style doesn't quite fit the bill and when it can't be done with fela. Ideally, cfui components should have the right styling built in for most cases. In the few edge cases that pop up in real world feature development, this is an alternative to wrapping your component in a `<div>` or `<span>` and styling it with css to accomodate one-offs. \n\n Also, note that using Box effectively performs a component level CSS reset, as all props not provided will be pulled from the default theme. These defaults, outlined in propertiesSpec, either match the browser defaults, or are taken from our global styles as defined by cf-style-const.",
|
|
4
|
-
"version": "2.3.
|
|
4
|
+
"version": "2.3.6",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
7
7
|
"author": "James Culveyhouse <jculveyhouse@cloudflare.com>",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@cloudflare/style-const": "^5.0.
|
|
15
|
-
"@cloudflare/style-container": "^7.5.
|
|
16
|
-
"@cloudflare/types": "^6.
|
|
14
|
+
"@cloudflare/style-const": "^5.0.11",
|
|
15
|
+
"@cloudflare/style-container": "^7.5.5",
|
|
16
|
+
"@cloudflare/types": "^6.11.0",
|
|
17
17
|
"fela": "^11.6.1",
|
|
18
18
|
"polished": "^1.9.3",
|
|
19
19
|
"prop-types": "^15.6.0"
|
|
@@ -31,5 +31,6 @@
|
|
|
31
31
|
"test": "stratus test",
|
|
32
32
|
"test-coverage": "stratus test --coverage",
|
|
33
33
|
"test-watch": "stratus test --watch"
|
|
34
|
-
}
|
|
34
|
+
},
|
|
35
|
+
"gitHead": "a1a7ca299c6676e5222e50aee57bc5beedb44882"
|
|
35
36
|
}
|