meta-mosaic 1.0.9 → 1.0.11
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/LICENSE +21 -0
- package/README.md +132 -7
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 MetaMosaic Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,12 +1,137 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 🧩 MetaMosaic
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> A simple and responsive React component to create a mosaic grid of images — with background image, custom styles, and click dialog support.
|
|
4
|
+
<img width="1215" height="514" alt="Screenshot 2025-11-09 at 6 42 07 PM" src="https://github.com/user-attachments/assets/fd24e2f8-df1e-4122-84b3-b7cbe1a8a8f9" />
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
---
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
8
|
+
## 🚀 Installation
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
```bash
|
|
11
|
+
npm install meta-mosaic
|
|
12
|
+
# or
|
|
13
|
+
yarn add meta-mosaic
|
|
14
|
+
```
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
Then import it in your project:
|
|
17
|
+
|
|
18
|
+
```jsx
|
|
19
|
+
import { MetaMosaic } from "meta-mosaic";
|
|
20
|
+
import "meta-mosaic/dist/meta-mosaic.css";
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## âš¡ Quick Example
|
|
26
|
+
|
|
27
|
+
```jsx
|
|
28
|
+
import React from "react";
|
|
29
|
+
import { MetaMosaic } from "meta-mosaic";
|
|
30
|
+
import "meta-mosaic/dist/meta-mosaic.css";
|
|
31
|
+
|
|
32
|
+
const images = Array.from({ length: 400 }, (_, i) => ({
|
|
33
|
+
id: i + 1,
|
|
34
|
+
link: `https://picsum.photos/id/${101 + i}/400/300`,
|
|
35
|
+
title: `Image ${i + 1}`,
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
const bgImage = "https://i.etsystatic.com/32237469/r/il/72bad1/4009560313/il_570xN.4009560313_q4ps.jpg";
|
|
39
|
+
|
|
40
|
+
function App() {
|
|
41
|
+
return (
|
|
42
|
+
<MetaMosaic
|
|
43
|
+
images={images}
|
|
44
|
+
size={20}
|
|
45
|
+
bgImageUrl={bgImage}
|
|
46
|
+
gridWrapperClassName="custom-mosaic-wrapper"
|
|
47
|
+
gridWrapperStyle={{ boxShadow: "0 0 1em rgba(255,255,255,0.5)" }}
|
|
48
|
+
bgPosition="center 8px"
|
|
49
|
+
width={{ xs: 350, md: 500, lg: 650 }}
|
|
50
|
+
height={{ xs: 350, md: 500, lg: 650 }}
|
|
51
|
+
setDialog={(img) => (
|
|
52
|
+
<div>
|
|
53
|
+
<h2>{img.id}</h2>
|
|
54
|
+
<h6 style={{ color: "red" }}>{img.title}</h6>
|
|
55
|
+
<img src={img.link} alt={img.title} />
|
|
56
|
+
</div>
|
|
57
|
+
)}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default App;
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## 🧩 Props Guide
|
|
68
|
+
|
|
69
|
+
| Prop | Type | Description |
|
|
70
|
+
| ------------------------ | ---------- | ---------------------------------------------------------------------------------- |
|
|
71
|
+
| **images** | `Array` | List of images to display in mosaic. Each image should have `{ id, link, title }`. |
|
|
72
|
+
| **size** | `number` | Defines number of rows and columns. Example: `size={4}` → 4x4 grid. |
|
|
73
|
+
| **bgImageUrl** | `string` | Background image for the mosaic layout. |
|
|
74
|
+
| **gridWrapperClassName** | `string` | Add your custom class to the grid wrapper. |
|
|
75
|
+
| **gridWrapperStyle** | `object` | Inline CSS styles for grid wrapper. |
|
|
76
|
+
| **bgPosition** | `string` | Adjust the background image position (e.g. `"center 8px"`). |
|
|
77
|
+
| **width** | `object` | Responsive width based on breakpoints: `{ xs, md, lg }`. |
|
|
78
|
+
| **height** | `object` | Responsive height based on breakpoints: `{ xs, md, lg }`. |
|
|
79
|
+
| **setDialog** | `function` | Custom component that opens when clicking a mosaic cell. |
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## 💡 Example: setDialog
|
|
84
|
+
|
|
85
|
+
<img width="1216" height="707" alt="Screenshot 2025-11-09 at 6 42 50 PM" src="https://github.com/user-attachments/assets/0a81379d-e28d-4671-a749-b881ef68519d" />
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
```jsx
|
|
89
|
+
setDialog={(img) => (
|
|
90
|
+
<div>
|
|
91
|
+
<h2>{img.id}</h2>
|
|
92
|
+
<h6 style={{ color: 'red' }}>{img.title}</h6>
|
|
93
|
+
<img src={img.link} alt={img.title} />
|
|
94
|
+
</div>
|
|
95
|
+
)}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
This function runs when a user clicks on a cell. You can render any custom component here.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## 🪄 Responsive Behavior
|
|
103
|
+
|
|
104
|
+
You can set different `width` and `height` values for small, medium, and large screens:
|
|
105
|
+
|
|
106
|
+
```jsx
|
|
107
|
+
width={{ xs: 350, md: 500, lg: 650 }}
|
|
108
|
+
height={{ xs: 350, md: 500, lg: 650 }}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The component adjusts automatically based on screen size.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## 📦 Changelog
|
|
116
|
+
|
|
117
|
+
### v1.0.11 — (2025-11-09)
|
|
118
|
+
|
|
119
|
+
#### ✨ New Features
|
|
120
|
+
|
|
121
|
+
* Added all props: `images`, `size`, `bgImageUrl`, `gridWrapperClassName`, `gridWrapperStyle`, `bgPosition`, `width`, `height`, and `setDialog`.
|
|
122
|
+
* Fully responsive and customizable grid.
|
|
123
|
+
* Clickable mosaic cells with custom dialog support.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## 🧠Tips
|
|
128
|
+
|
|
129
|
+
* Use high-quality images for better visual effect.
|
|
130
|
+
* The `bgImageUrl` should have similar aspect ratio as your grid.
|
|
131
|
+
* Combine `gridWrapperStyle` with `className` for fine-tuned control.
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 📜 License
|
|
136
|
+
|
|
137
|
+
MIT © [MetaMosaic](https://www.npmjs.com/package/meta-mosaic)
|