boxwood 2.4.4 → 2.5.0
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 +1 -1
- package/ui/grid/index.js +9 -4
- package/ui/index.js +2 -0
- package/ui/markdown/index.js +40 -0
package/package.json
CHANGED
package/ui/grid/index.js
CHANGED
|
@@ -24,13 +24,18 @@ function Grid({ className, columns = 3, gap, breakpoint, style }, children) {
|
|
|
24
24
|
}),
|
|
25
25
|
...(typeof columns === "object" &&
|
|
26
26
|
Object.keys(columns).reduce((object, key) => {
|
|
27
|
+
const value =
|
|
28
|
+
typeof columns[key] === "number"
|
|
29
|
+
? `repeat(${columns[key]}, 1fr)`
|
|
30
|
+
: columns[key]
|
|
27
31
|
if (key === "default") {
|
|
28
|
-
object["grid-template-columns"] =
|
|
32
|
+
object["grid-template-columns"] = value
|
|
29
33
|
} else if (typeof key === "string") {
|
|
30
|
-
const
|
|
34
|
+
const maxWidth =
|
|
31
35
|
BREAKPOINTS[key] || (key.endsWith("px") ? key : `${key}px`)
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
|
|
37
|
+
object[`@media (max-width: ${maxWidth})`] = {
|
|
38
|
+
"grid-template-columns": value,
|
|
34
39
|
}
|
|
35
40
|
}
|
|
36
41
|
return object
|
package/ui/index.js
CHANGED
|
@@ -3,6 +3,7 @@ const Container = require("./container")
|
|
|
3
3
|
const Grid = require("./grid")
|
|
4
4
|
const Group = require("./group")
|
|
5
5
|
const Stack = require("./stack")
|
|
6
|
+
const Markdown = require("./markdown")
|
|
6
7
|
|
|
7
8
|
module.exports = {
|
|
8
9
|
Center,
|
|
@@ -10,4 +11,5 @@ module.exports = {
|
|
|
10
11
|
Grid,
|
|
11
12
|
Group,
|
|
12
13
|
Stack,
|
|
14
|
+
Markdown,
|
|
13
15
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const { component, H1, H2, H3, H4, H5, H6, P, Blockquote } = require("../..")
|
|
2
|
+
|
|
3
|
+
function Markdown(params, children) {
|
|
4
|
+
if (typeof children === "string") {
|
|
5
|
+
const lines = children
|
|
6
|
+
.trim()
|
|
7
|
+
.split("\n")
|
|
8
|
+
.map((line) => line.trim())
|
|
9
|
+
.filter(Boolean)
|
|
10
|
+
|
|
11
|
+
return lines.map((line) => {
|
|
12
|
+
if (line.startsWith("# ")) {
|
|
13
|
+
const text = line.substring(2)
|
|
14
|
+
return H1(text)
|
|
15
|
+
} else if (line.startsWith("## ")) {
|
|
16
|
+
const text = line.substring(3)
|
|
17
|
+
return H2(text)
|
|
18
|
+
} else if (line.startsWith("### ")) {
|
|
19
|
+
const text = line.substring(4)
|
|
20
|
+
return H3(text)
|
|
21
|
+
} else if (line.startsWith("#### ")) {
|
|
22
|
+
const text = line.substring(5)
|
|
23
|
+
return H4(text)
|
|
24
|
+
} else if (line.startsWith("##### ")) {
|
|
25
|
+
const text = line.substring(6)
|
|
26
|
+
return H5(text)
|
|
27
|
+
} else if (line.startsWith("###### ")) {
|
|
28
|
+
const text = line.substring(7)
|
|
29
|
+
return H6(text)
|
|
30
|
+
} else if (line.startsWith("> ")) {
|
|
31
|
+
const text = line.substring(2)
|
|
32
|
+
return Blockquote(text)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return P(line)
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = component(Markdown)
|