masua 0.10.0 → 0.10.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/README.md +12 -2
- package/index.ts +1 -0
- package/package.json +2 -2
- package/react.tsx +15 -3
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# masua
|
|
6
6
|
|
|
7
|
-
Simple masonry layout library in TypeScript.
|
|
7
|
+
Simple masonry layout library in TypeScript. Initially forked from [minimasonry](https://github.com/Spope/MiniMasonry.js) by Spope.
|
|
8
8
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
|
@@ -12,6 +12,16 @@ Simple masonry layout library in TypeScript.
|
|
|
12
12
|
import { grid } from 'masua'
|
|
13
13
|
|
|
14
14
|
grid(document.querySelector('#my-grid'))
|
|
15
|
+
// With configuration options.
|
|
16
|
+
grid(document.querySelector('#my-custom-grid'), {
|
|
17
|
+
gutter: 20,
|
|
18
|
+
baseWidth: 300,
|
|
19
|
+
minify: false,
|
|
20
|
+
surroundingGutter: true,
|
|
21
|
+
ultimateGutter: 10,
|
|
22
|
+
direction: 'rtl',
|
|
23
|
+
wedge: true,
|
|
24
|
+
})
|
|
15
25
|
```
|
|
16
26
|
|
|
17
27
|
## React
|
|
@@ -20,7 +30,7 @@ grid(document.querySelector('#my-grid'))
|
|
|
20
30
|
import { Grid } from 'masua'
|
|
21
31
|
|
|
22
32
|
const MyGrid = () => (
|
|
23
|
-
<Grid>
|
|
33
|
+
<Grid disabled={window.innerWidth < 501}>
|
|
24
34
|
<Box />
|
|
25
35
|
<Box size={3} />
|
|
26
36
|
<Box size={2} />
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "masua",
|
|
3
3
|
"description": "Simple masonry layout library in TypeScript.",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.2",
|
|
5
5
|
"repository": "github:tobua/masua",
|
|
6
6
|
"homepage": "https://tobua.github.io/masua",
|
|
7
7
|
"license": "MIT",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@types/react": "^18.2.
|
|
25
|
+
"@types/react": "^18.2.65",
|
|
26
26
|
"padua": "^4.0.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
package/react.tsx
CHANGED
|
@@ -17,8 +17,11 @@ const configurationProperties = [
|
|
|
17
17
|
'wedge',
|
|
18
18
|
]
|
|
19
19
|
|
|
20
|
+
let instance: any
|
|
21
|
+
|
|
20
22
|
export function Grid({
|
|
21
23
|
disabled = false,
|
|
24
|
+
children,
|
|
22
25
|
...props
|
|
23
26
|
}: JSX.IntrinsicElements['div'] & Partial<ReactConfiguration>) {
|
|
24
27
|
const gridRef = useRef(null)
|
|
@@ -36,8 +39,17 @@ export function Grid({
|
|
|
36
39
|
|
|
37
40
|
useEffect(() => {
|
|
38
41
|
if (disabled) return () => {}
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
if (instance) {
|
|
43
|
+
instance.update()
|
|
44
|
+
return instance.destroy
|
|
45
|
+
}
|
|
46
|
+
instance = grid(gridRef.current, configurationProps)
|
|
47
|
+
return instance.destroy
|
|
48
|
+
}, [children])
|
|
41
49
|
|
|
42
|
-
return
|
|
50
|
+
return (
|
|
51
|
+
<div ref={gridRef} {...props}>
|
|
52
|
+
{children}
|
|
53
|
+
</div>
|
|
54
|
+
)
|
|
43
55
|
}
|