boxwood 2.3.0 → 2.4.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/index.js CHANGED
@@ -486,7 +486,7 @@ const tag = (a, b, c) => {
486
486
  }
487
487
  const name = a
488
488
  const attributes = b
489
- const children = c || []
489
+ const children = typeof c === "number" ? c : c || []
490
490
  return {
491
491
  name,
492
492
  children,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "boxwood",
3
- "version": "2.3.0",
3
+ "version": "2.4.2",
4
4
  "description": "Compile HTML templates into JS",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -0,0 +1,25 @@
1
+ const { css, component, Div } = require("../..")
2
+
3
+ function Center({ className, style, height, width } = {}, children) {
4
+ const styleObject = {
5
+ display: "flex",
6
+ "justify-content": "center",
7
+ "align-items": "center",
8
+ "flex-direction": "column",
9
+ width: width || "100%",
10
+ height: height || "100dvh",
11
+ }
12
+
13
+ const styles = css`
14
+ .center {
15
+ ${css.create(styleObject).toString()}
16
+ }
17
+ `
18
+
19
+ return [
20
+ Div({ className: [className, styles.center], style }, children),
21
+ styles.css,
22
+ ]
23
+ }
24
+
25
+ module.exports = component(Center)
package/ui/index.js CHANGED
@@ -1,9 +1,11 @@
1
+ const Center = require("./center")
1
2
  const Container = require("./container")
2
3
  const Grid = require("./grid")
3
4
  const Group = require("./group")
4
5
  const Stack = require("./stack")
5
6
 
6
7
  module.exports = {
8
+ Center,
7
9
  Container,
8
10
  Grid,
9
11
  Group,
package/utilities/hash.js CHANGED
@@ -1,12 +1,16 @@
1
- let index = 0
1
+ if (!global.__boxwood_index__) {
2
+ global.__boxwood_index__ = 0
3
+ }
4
+
2
5
  const map = new Map()
3
6
 
4
7
  function createHash(string) {
5
8
  if (map.has(string)) {
6
9
  return map.get(string)
7
10
  }
8
- index++
9
- const hash = "c" + index
11
+
12
+ global.__boxwood_index__++
13
+ const hash = "c" + global.__boxwood_index__
10
14
  map.set(string, hash)
11
15
  return hash
12
16
  }