boxwood 2.2.1 → 2.2.2
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/package.json +3 -3
- package/ui/container/index.js +47 -0
- package/ui/{Group → group}/index.js +1 -0
- package/ui/index.js +4 -2
- package/ui/{Stack → stack}/index.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "boxwood",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"description": "Compile HTML templates into JS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"./ui": "./ui/index.js"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
|
-
"test": "node --test --test-reporter=dot \"test
|
|
14
|
-
"test:debug": "node --test --test-reporter=spec \"test
|
|
13
|
+
"test": "node --test --test-reporter=dot \"**/*.test.js\" \"**/*.spec.js\"",
|
|
14
|
+
"test:debug": "node --test --test-reporter=spec \"**/*.test.js\" \"**/*.spec.js\"",
|
|
15
15
|
"coverage": "c8 npm test",
|
|
16
16
|
"benchmark": "node --test benchmark/index.js",
|
|
17
17
|
"watch": "npm test -- --watch",
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const { css, component, Div } = require("../..")
|
|
2
|
+
|
|
3
|
+
const normalizeValue = (value) => {
|
|
4
|
+
if (typeof value === "string") {
|
|
5
|
+
if (value.endsWith("px")) {
|
|
6
|
+
return parseInt(value, 10)
|
|
7
|
+
}
|
|
8
|
+
if (value.endsWith("rem")) {
|
|
9
|
+
return parseInt(value, 10) * 16
|
|
10
|
+
}
|
|
11
|
+
throw new Error(
|
|
12
|
+
"Width must be a number or a string ending with 'px' or 'rem'"
|
|
13
|
+
)
|
|
14
|
+
}
|
|
15
|
+
return value
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function Container(
|
|
19
|
+
{ className, style, width = 1200, padding = 16 } = {},
|
|
20
|
+
children
|
|
21
|
+
) {
|
|
22
|
+
width = normalizeValue(width)
|
|
23
|
+
padding = normalizeValue(padding)
|
|
24
|
+
const styles = css`
|
|
25
|
+
.container {
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
margin-left: auto;
|
|
28
|
+
margin-right: auto;
|
|
29
|
+
max-width: ${width}px;
|
|
30
|
+
padding-left: ${padding}px;
|
|
31
|
+
padding-right: ${padding}px;
|
|
32
|
+
width: 100%;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@media (max-width: ${width + padding * 2 - 1}px) {
|
|
36
|
+
.container {
|
|
37
|
+
max-width: 100%;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
`
|
|
41
|
+
return [
|
|
42
|
+
Div({ className: [styles.container, className], style }, children),
|
|
43
|
+
styles.css,
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = component(Container)
|
package/ui/index.js
CHANGED