react-justified-layout-ts 1.1.17 → 2.0.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.
|
@@ -8,8 +8,9 @@ export interface TSJustifiedLayoutProps {
|
|
|
8
8
|
targetRowHeight?: number;
|
|
9
9
|
targetRowHeightTolerance?: number;
|
|
10
10
|
width: number;
|
|
11
|
-
children:
|
|
11
|
+
children: React.JSX.Element[];
|
|
12
12
|
showWidows?: boolean;
|
|
13
|
+
containerStyle?: React.CSSProperties;
|
|
13
14
|
}
|
|
14
|
-
declare function TSJustifiedLayout({ children, layoutItems, itemSpacing, rowSpacing, showWidows, targetRowHeight, targetRowHeightTolerance, width }: TSJustifiedLayoutProps): React.JSX.Element;
|
|
15
|
+
declare function TSJustifiedLayout({ children, layoutItems, itemSpacing, rowSpacing, showWidows, targetRowHeight, targetRowHeightTolerance, width, containerStyle }: TSJustifiedLayoutProps): React.JSX.Element;
|
|
15
16
|
export { TSJustifiedLayout };
|
|
@@ -1,32 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
4
|
};
|
|
25
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
6
|
exports.TSJustifiedLayout = void 0;
|
|
27
|
-
const react_1 =
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
28
8
|
require("./layout.css");
|
|
29
|
-
function TSJustifiedLayout({ children, layoutItems, itemSpacing = 10, rowSpacing = 10, showWidows = true, targetRowHeight = 320, targetRowHeightTolerance = .25, width }) {
|
|
9
|
+
function TSJustifiedLayout({ children, layoutItems, itemSpacing = 10, rowSpacing = 10, showWidows = true, targetRowHeight = 320, targetRowHeightTolerance = .25, width, containerStyle }) {
|
|
30
10
|
const minAspectRatio = width / targetRowHeight * (1 - targetRowHeightTolerance);
|
|
31
11
|
const maxAspectRatio = width / targetRowHeight * (1 + targetRowHeightTolerance);
|
|
32
12
|
const rows = [];
|
|
@@ -89,7 +69,7 @@ function TSJustifiedLayout({ children, layoutItems, itemSpacing = 10, rowSpacing
|
|
|
89
69
|
*/
|
|
90
70
|
function renderRow(aspectRatio, isLastRow) {
|
|
91
71
|
childNodeCounter++;
|
|
92
|
-
return
|
|
72
|
+
return react_1.default.createElement("div", { style: Object.assign(Object.assign({ maxHeight: '100%', aspectRatio: aspectRatio }, (isLastRow ? {} : { flex: aspectRatio })), containerStyle) }, children[childNodeCounter]);
|
|
93
73
|
}
|
|
94
74
|
return (react_1.default.createElement("div", { style: { width: "100%" } }, rows.map((value, index, array) => {
|
|
95
75
|
let isLastRow = index === array.length - 1 && showWidows;
|
|
@@ -181,9 +181,10 @@ exports.Primary = {
|
|
|
181
181
|
itemSpacing: undefined,
|
|
182
182
|
layoutItems: displayedImages.map(value => value.aspectRatio),
|
|
183
183
|
targetRowHeightTolerance: undefined,
|
|
184
|
-
children: displayedImages.map(value => react_1.default.createElement(
|
|
184
|
+
children: displayedImages.map(value => react_1.default.createElement(react_1.default.Fragment, null,
|
|
185
185
|
react_1.default.createElement("div", { style: { top: 16, left: 16, position: "absolute" } }, "Testing"),
|
|
186
|
-
react_1.default.createElement("img", { src: value.webp })))
|
|
186
|
+
react_1.default.createElement("img", { src: value.webp }))),
|
|
187
|
+
containerStyle: { position: 'relative' }
|
|
187
188
|
},
|
|
188
189
|
};
|
|
189
190
|
exports.Secondary = {
|
package/package.json
CHANGED
|
@@ -10,8 +10,9 @@ export interface TSJustifiedLayoutProps {
|
|
|
10
10
|
targetRowHeight?: number;
|
|
11
11
|
targetRowHeightTolerance?: number;
|
|
12
12
|
width: number;
|
|
13
|
-
children:
|
|
13
|
+
children: React.JSX.Element[];
|
|
14
14
|
showWidows?: boolean;
|
|
15
|
+
containerStyle?: React.CSSProperties;
|
|
15
16
|
// TODO Implement these
|
|
16
17
|
// maxNumRows?: number;
|
|
17
18
|
// fullWidthBreakoutRowCadence?: number
|
|
@@ -26,7 +27,8 @@ function TSJustifiedLayout({
|
|
|
26
27
|
showWidows = true,
|
|
27
28
|
targetRowHeight = 320,
|
|
28
29
|
targetRowHeightTolerance = .25,
|
|
29
|
-
width
|
|
30
|
+
width,
|
|
31
|
+
containerStyle
|
|
30
32
|
}: TSJustifiedLayoutProps) {
|
|
31
33
|
const minAspectRatio = width / targetRowHeight * (1 - targetRowHeightTolerance);
|
|
32
34
|
const maxAspectRatio = width / targetRowHeight * (1 + targetRowHeightTolerance);
|
|
@@ -95,14 +97,14 @@ function TSJustifiedLayout({
|
|
|
95
97
|
*/
|
|
96
98
|
function renderRow(aspectRatio: ElementDimensions, isLastRow: boolean) {
|
|
97
99
|
childNodeCounter++;
|
|
98
|
-
return
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
100
|
+
return <div style={{
|
|
101
|
+
maxHeight: '100%',
|
|
102
|
+
aspectRatio: aspectRatio,
|
|
103
|
+
...(isLastRow ? {} : {flex: aspectRatio}),
|
|
104
|
+
...containerStyle
|
|
105
|
+
}}>
|
|
106
|
+
{children[childNodeCounter]}
|
|
107
|
+
</div>
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
return (
|
|
@@ -179,11 +179,14 @@ export const Primary: Story = {
|
|
|
179
179
|
targetRowHeight: undefined,
|
|
180
180
|
rowSpacing: undefined,
|
|
181
181
|
itemSpacing: undefined,
|
|
182
|
-
layoutItems:
|
|
182
|
+
layoutItems: displayedImages.map(value => value.aspectRatio),
|
|
183
183
|
targetRowHeightTolerance: undefined,
|
|
184
|
-
children: displayedImages.map(value =>
|
|
185
|
-
|
|
186
|
-
|
|
184
|
+
children: displayedImages.map(value => <>
|
|
185
|
+
<div style={{top: 16, left: 16, position: "absolute"}}>Testing</div>
|
|
186
|
+
<img src={value.webp}/>
|
|
187
|
+
</>
|
|
188
|
+
),
|
|
189
|
+
containerStyle: {position: 'relative'}
|
|
187
190
|
},
|
|
188
191
|
};
|
|
189
192
|
|
|
@@ -195,16 +198,16 @@ export const Secondary: Story = {
|
|
|
195
198
|
targetRowHeight: undefined,
|
|
196
199
|
rowSpacing: undefined,
|
|
197
200
|
itemSpacing: undefined,
|
|
198
|
-
layoutItems:
|
|
201
|
+
layoutItems: displayedImages.slice(1, 5).map(value => value.aspectRatio),
|
|
199
202
|
targetRowHeightTolerance: undefined,
|
|
200
|
-
children: displayedImages.slice(1, 5).map(value => <img src={value.webp}
|
|
203
|
+
children: displayedImages.slice(1, 5).map(value => <img src={value.webp}/>)
|
|
201
204
|
},
|
|
202
205
|
}
|
|
203
206
|
|
|
204
207
|
export const Single: Story = {
|
|
205
208
|
name: "Single Elements",
|
|
206
209
|
args: {
|
|
207
|
-
children: [<img src={'https://alcorsiteartbucket.s3.amazonaws.com/webp/alcor_wow.webp'}
|
|
210
|
+
children: [<img src={'https://alcorsiteartbucket.s3.amazonaws.com/webp/alcor_wow.webp'}/>],
|
|
208
211
|
width: 847,
|
|
209
212
|
showWidows: true,
|
|
210
213
|
targetRowHeight: undefined,
|