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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "boxwood",
3
- "version": "2.2.1",
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/**/*.test.js\" \"test/**/*.spec.js\"",
14
- "test:debug": "node --test --test-reporter=spec \"test/**/*.test.js\" \"test/**/*.spec.js\"",
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)
@@ -20,6 +20,7 @@ function Group(
20
20
  padding = normalizeSpacing(padding)
21
21
 
22
22
  const styleObject = {
23
+ "box-sizing": "border-box",
23
24
  display: "flex",
24
25
  "flex-direction": "row",
25
26
  ...(gap && { gap }),
package/ui/index.js CHANGED
@@ -1,7 +1,9 @@
1
- const Group = require("./Group")
2
- const Stack = require("./Stack")
1
+ const Container = require("./container")
2
+ const Group = require("./group")
3
+ const Stack = require("./stack")
3
4
 
4
5
  module.exports = {
6
+ Container,
5
7
  Group,
6
8
  Stack,
7
9
  }
@@ -18,6 +18,7 @@ function Stack(
18
18
  padding = normalizeSpacing(padding)
19
19
 
20
20
  const styleObject = {
21
+ "box-sizing": "border-box",
21
22
  display: "flex",
22
23
  "flex-direction": "column",
23
24
  ...(gap && { gap }),