react-justified-layout-ts 1.0.1 → 1.0.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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +42 -0
  3. package/package.json +3 -2
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Alan19
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 ADDED
@@ -0,0 +1,42 @@
1
+ A TypeScript component similar to Flickr's justified layout.
2
+
3
+ # Usage
4
+
5
+ ---
6
+ Add the `TSJustifiedLayout` component to your code with the following props:
7
+ - `layoutItems: number[];` - An array of aspect ratios for the images you are adding to the grid
8
+ - `itemSpacing?: number;` - The amount of spacing between each image, in pixels. (Default: 10)
9
+ - `rowSpacing?: number;` - The amount of spacing between each row, in pixels. (Default: 10)
10
+ - `targetRowHeight?: number;` - The target row height for a row, in pixels. (Default: 320)
11
+ - `targetRowHeightTolerance?: number;` - The amount the row height could deviate from the target row height, as a percent. (Default: .25)
12
+ - `width: number;` - The width of the container. I would use something like `react-use-measure` if you're trying to make it dynamically take up the size of the parent container.
13
+ - `children: any[];` - The children elements that makes up the grid.
14
+ - `showWidows?: boolean;` - If the last row should be shown. (Default: true)
15
+
16
+ ## Example Usage
17
+ ```typescript jsx
18
+ <TSJustifiedLayout width={width}
19
+ layoutItems={imagesOnPage.map(value => ({
20
+ dimensions: value.aspectRatio || 1
21
+ }))}>
22
+ {imagesOnPage.map(value => <img
23
+ src={value.src}
24
+ alt={value.alt}
25
+ />)}
26
+ </TSJustifiedLayout>
27
+ ```
28
+
29
+ # Install
30
+
31
+ ---
32
+ `npm i react-justified-layout-ts`
33
+
34
+ # Credits
35
+
36
+ ---
37
+ The display logic for the layout and the math used to calculate the row height for each row is adapted from [Flickr's Justified Layout library](https://github.com/flickr/justified-layout).
38
+
39
+ # License
40
+
41
+ ---
42
+ Open Source Licensed under the MIT license.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-justified-layout-ts",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "A component based off Flickr's justified layout that is compatible with Typescript",
5
5
  "main": "./dist/TSJustifiedLayout.js",
6
6
  "types": "./dist/TSJustifiedLayout.d.ts",
@@ -22,5 +22,6 @@
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": "^18.2.0"
25
- }
25
+ },
26
+ "repository": "https://github.com/Alan19/react-justified-layout-ts"
26
27
  }