boxwood 2.2.0 → 2.2.1

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.0",
3
+ "version": "2.2.1",
4
4
  "description": "Compile HTML templates into JS",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/ui/Group/index.js CHANGED
@@ -4,14 +4,20 @@ const {
4
4
  normalizeFlex,
5
5
  normalizeBreakpoint,
6
6
  normalizeWidth,
7
+ normalizeSpacing,
7
8
  } = require("../normalize")
8
9
 
9
- function Group({ align, breakpoint, justify, gap, width, style }, children) {
10
+ function Group(
11
+ { align, className, breakpoint, justify, gap, width, margin, padding, style },
12
+ children
13
+ ) {
10
14
  gap = normalizeGap(gap)
11
15
  align = normalizeFlex(align)
12
16
  justify = normalizeFlex(justify)
13
17
  breakpoint = normalizeBreakpoint(breakpoint)
14
18
  width = normalizeWidth(width)
19
+ margin = normalizeSpacing(margin)
20
+ padding = normalizeSpacing(padding)
15
21
 
16
22
  const styleObject = {
17
23
  display: "flex",
@@ -20,6 +26,8 @@ function Group({ align, breakpoint, justify, gap, width, style }, children) {
20
26
  ...(align && { "align-items": align }),
21
27
  ...(justify && { "justify-content": justify }),
22
28
  ...(width && { width }),
29
+ ...(margin && { margin }),
30
+ ...(padding && { padding }),
23
31
  ...(breakpoint && {
24
32
  [`@media (max-width: ${breakpoint})`]: {
25
33
  "flex-direction": "column",
@@ -33,7 +41,10 @@ function Group({ align, breakpoint, justify, gap, width, style }, children) {
33
41
  }
34
42
  `
35
43
 
36
- return [Div({ className: styles.group, style }, children), styles.css]
44
+ return [
45
+ Div({ className: [styles.group, className], style }, children),
46
+ styles.css,
47
+ ]
37
48
  }
38
49
 
39
50
  module.exports = component(Group)
package/ui/Stack/index.js CHANGED
@@ -1,11 +1,21 @@
1
1
  const { css, component, Div } = require("../..")
2
- const { normalizeGap, normalizeFlex, normalizeWidth } = require("../normalize")
2
+ const {
3
+ normalizeGap,
4
+ normalizeFlex,
5
+ normalizeWidth,
6
+ normalizeSpacing,
7
+ } = require("../normalize")
3
8
 
4
- function Stack({ align, justify, gap, width, style }, children) {
9
+ function Stack(
10
+ { align, className, justify, gap, width, margin, padding, style },
11
+ children
12
+ ) {
5
13
  gap = normalizeGap(gap)
6
14
  align = normalizeFlex(align)
7
15
  justify = normalizeFlex(justify)
8
16
  width = normalizeWidth(width)
17
+ margin = normalizeSpacing(margin)
18
+ padding = normalizeSpacing(padding)
9
19
 
10
20
  const styleObject = {
11
21
  display: "flex",
@@ -14,6 +24,8 @@ function Stack({ align, justify, gap, width, style }, children) {
14
24
  ...(align && { "align-items": align }),
15
25
  ...(justify && { "justify-content": justify }),
16
26
  ...(width && { width }),
27
+ ...(margin && { margin }),
28
+ ...(padding && { padding }),
17
29
  }
18
30
 
19
31
  const styles = css`
@@ -22,7 +34,10 @@ function Stack({ align, justify, gap, width, style }, children) {
22
34
  }
23
35
  `
24
36
 
25
- return [Div({ className: styles.stack, style }, children), styles.css]
37
+ return [
38
+ Div({ className: [styles.stack, className], style }, children),
39
+ styles.css,
40
+ ]
26
41
  }
27
42
 
28
43
  module.exports = component(Stack)
package/ui/normalize.js CHANGED
@@ -58,9 +58,29 @@ function normalizeWidth(width) {
58
58
  return width
59
59
  }
60
60
 
61
+ const SPACING_MAP = {
62
+ xs: "0.25rem",
63
+ sm: "0.5rem",
64
+ md: "1rem",
65
+ lg: "2rem",
66
+ xl: "4rem",
67
+ none: null,
68
+ }
69
+
70
+ function normalizeSpacing(spacing) {
71
+ if (typeof spacing === "number") {
72
+ return `${spacing}px`
73
+ }
74
+ if (SPACING_MAP.hasOwnProperty(spacing)) {
75
+ return SPACING_MAP[spacing]
76
+ }
77
+ return spacing
78
+ }
79
+
61
80
  module.exports = {
62
81
  normalizeFlex,
63
82
  normalizeGap,
64
83
  normalizeBreakpoint,
65
84
  normalizeWidth,
85
+ normalizeSpacing,
66
86
  }