boxwood 2.2.2 → 2.2.4

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.2",
3
+ "version": "2.2.4",
4
4
  "description": "Compile HTML templates into JS",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -32,7 +32,7 @@ function Container(
32
32
  width: 100%;
33
33
  }
34
34
 
35
- @media (max-width: ${width + padding * 2 - 1}px) {
35
+ @media (max-width: ${width - 1}px) {
36
36
  .container {
37
37
  max-width: 100%;
38
38
  }
@@ -0,0 +1,49 @@
1
+ const { component, css, Div } = require("../..")
2
+ const { normalizeGap, normalizeBreakpoint } = require("../normalize")
3
+
4
+ function Grid({ className, columns = 3, gap, breakpoint, style }, children) {
5
+ gap = normalizeGap(gap)
6
+ breakpoint = normalizeBreakpoint(breakpoint)
7
+
8
+ const styleObject = {
9
+ "box-sizing": "border-box",
10
+ display: "grid",
11
+ gap,
12
+ ...(typeof columns === "number" && {
13
+ "grid-template-columns": `repeat(${columns}, 1fr)`,
14
+ }),
15
+ ...(typeof columns === "string" && {
16
+ "grid-template-columns": columns,
17
+ }),
18
+ ...(typeof columns === "object" &&
19
+ Object.keys(columns).reduce((object, key) => {
20
+ if (key === "default") {
21
+ object["grid-template-columns"] = columns[key]
22
+ } else {
23
+ object[`@media (min-width: ${key}px)`] = {
24
+ "grid-template-columns": columns[key],
25
+ }
26
+ }
27
+ return object
28
+ }, {})),
29
+ ...(gap && { gap }),
30
+ ...(breakpoint && {
31
+ [`@media (max-width: ${breakpoint})`]: {
32
+ "grid-template-columns": "1fr",
33
+ },
34
+ }),
35
+ }
36
+
37
+ const styles = css`
38
+ .grid {
39
+ ${css.create(styleObject).toString()}
40
+ }
41
+ `
42
+
43
+ return [
44
+ Div({ className: [styles.grid, className], style }, children),
45
+ styles.css,
46
+ ]
47
+ }
48
+
49
+ module.exports = component(Grid)
package/ui/index.js CHANGED
@@ -1,9 +1,11 @@
1
1
  const Container = require("./container")
2
+ const Grid = require("./grid")
2
3
  const Group = require("./group")
3
4
  const Stack = require("./stack")
4
5
 
5
6
  module.exports = {
6
7
  Container,
8
+ Grid,
7
9
  Group,
8
10
  Stack,
9
11
  }