@heliosgraphics/ui 2.0.1-alpha.2 → 2.0.1-alpha.3

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.
@@ -1,6 +1,5 @@
1
- "use client"
2
-
3
- import { type FC, useId, useInsertionEffect } from "react"
1
+ import { Children, type FC } from "react"
2
+ import { Masonry as Plock } from "react-plock"
4
3
  import type { MasonryProps } from "./Masonry.types"
5
4
 
6
5
  export const Masonry: FC<MasonryProps> = ({
@@ -9,40 +8,21 @@ export const Masonry: FC<MasonryProps> = ({
9
8
  gap = [2, 4, 6],
10
9
  breakpoints = [0, 640, 960],
11
10
  }) => {
12
- const reactId = useId()
13
- const id = `masonry${reactId.replace(/:/g, "")}`
14
-
15
- useInsertionEffect(() => {
16
- const style = document.createElement("style")
17
-
18
- style.dataset["masonryId"] = id
19
- style.textContent = `
20
- .${id} { column-count: ${columns[0]}; column-gap: ${gap[0]}px; }
21
- .${id} > * { break-inside: avoid; margin-bottom: ${gap[0]}px; }
22
-
23
- @media (min-width: ${breakpoints[1]}px) {
24
- .${id} { column-count: ${columns[1]}; column-gap: ${gap[1]}px; }
25
- .${id} > * { margin-bottom: ${gap[1]}px; }
26
- }
27
-
28
- @media (min-width: ${breakpoints[2]}px) {
29
- .${id} { column-count: ${columns[2]}; column-gap: ${gap[2]}px; }
30
- .${id} > * { margin-bottom: ${gap[2]}px; }
31
- }
32
- `
33
- document.head.appendChild(style)
34
-
35
- return (): void => {
36
- style.remove()
37
- }
38
- }, [id, columns, gap, breakpoints])
39
-
40
11
  if (!children) return null
41
12
 
13
+ const items = Children.toArray(children)
14
+ const numericGap = gap.map((g) => (g === "px" ? 1 : g)) as Array<number>
15
+
42
16
  return (
43
- <div className={id} data-ui-component="Masonry">
44
- {children}
45
- </div>
17
+ <Plock
18
+ items={items}
19
+ config={{
20
+ columns,
21
+ gap: numericGap,
22
+ media: breakpoints,
23
+ }}
24
+ render={(item, index) => <div key={index}>{item}</div>}
25
+ />
46
26
  )
47
27
  }
48
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heliosgraphics/ui",
3
- "version": "2.0.1-alpha.2",
3
+ "version": "2.0.1-alpha.3",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
6
  "*.css",
@@ -45,7 +45,8 @@
45
45
  "@heliosgraphics/utils": "^6.0.0-alpha.9",
46
46
  "marked": "^17.0.3",
47
47
  "marked-linkify-it": "^3.1.14",
48
- "marked-xhtml": "^1.0.14"
48
+ "marked-xhtml": "^1.0.14",
49
+ "react-plock": "^3.6.1"
49
50
  },
50
51
  "devDependencies": {
51
52
  "@testing-library/react": "^16.3.2",