react-justified-layout-ts 2.0.2 → 2.0.4

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.
@@ -71,16 +71,19 @@ function TSJustifiedLayout({ children, layoutItems, itemSpacing = 10, rowSpacing
71
71
  */
72
72
  function renderRow(aspectRatio, isLastRow) {
73
73
  childNodeCounter++;
74
- return react_1.default.createElement("div", { style: Object.assign(Object.assign({ maxHeight: '100%', aspectRatio: aspectRatio }, (isLastRow ? {} : { flex: aspectRatio })), containerStyle) }, children[childNodeCounter]);
74
+ return react_1.default.createElement("div", { style: Object.assign({ aspectRatio: aspectRatio, flex: aspectRatio }, containerStyle) }, children[childNodeCounter]);
75
75
  }
76
- return (react_1.default.createElement("div", { style: { width: "100%" } }, rows.map((value, index, array) => {
76
+ // TODO Figure out how to eliminate the tiny gap between div and actual image height
77
+ return (react_1.default.createElement("div", { style: {
78
+ display: 'flex',
79
+ flexDirection: 'column',
80
+ gap: rowSpacing
81
+ } }, rows.map((value, index, array) => {
77
82
  let isLastRow = index === array.length - 1 && showWidows;
78
83
  return react_1.default.createElement("div", { className: 'justified-row', style: {
79
84
  display: "flex",
80
85
  flexDirection: "row",
81
- gap: itemSpacing,
82
- marginBottom: rowSpacing,
83
- aspectRatio: width / value.height
86
+ gap: itemSpacing
84
87
  } }, value.items.map((aspectRatio) => renderRow(aspectRatio, isLastRow)));
85
88
  })));
86
89
  }
@@ -1,3 +1,3 @@
1
1
  .justified-row img {
2
- height: 100%
2
+ width: 100%
3
3
  }
@@ -19,6 +19,6 @@ const TSJustifiedLayout_1 = require("../components/TSJustifiedLayout");
19
19
  const react_1 = __importDefault(require("react"));
20
20
  const ConfiguredJustifiedLayout = (_a) => {
21
21
  var { layoutItems, rowSpacing = 8, width = 1000, itemSpacing = 8, targetRowHeight = 320, targetRowHeightTolerance = 0.10, showWidows = true, children } = _a, props = __rest(_a, ["layoutItems", "rowSpacing", "width", "itemSpacing", "targetRowHeight", "targetRowHeightTolerance", "showWidows", "children"]);
22
- return react_1.default.createElement(TSJustifiedLayout_1.TSJustifiedLayout, Object.assign({ layoutItems: layoutItems, width: width, itemSpacing: itemSpacing, targetRowHeight: 320, targetRowHeightTolerance: targetRowHeightTolerance, rowSpacing: rowSpacing, showWidows: showWidows }, props), children.map((child) => child));
22
+ return react_1.default.createElement(TSJustifiedLayout_1.TSJustifiedLayout, Object.assign({ layoutItems: layoutItems, width: width, itemSpacing: itemSpacing, targetRowHeight: targetRowHeight, targetRowHeightTolerance: targetRowHeightTolerance, rowSpacing: rowSpacing, showWidows: showWidows }, props), children.map((child) => child));
23
23
  };
24
24
  exports.ConfiguredJustifiedLayout = ConfiguredJustifiedLayout;
@@ -203,7 +203,7 @@ const displayedImages = [
203
203
  exports.Primary = {
204
204
  name: "Complex Elements",
205
205
  args: {
206
- width: 847,
206
+ width: 491,
207
207
  showWidows: true,
208
208
  targetRowHeight: undefined,
209
209
  rowSpacing: undefined,
@@ -212,7 +212,7 @@ exports.Primary = {
212
212
  targetRowHeightTolerance: undefined,
213
213
  children: displayedImages.map(value => react_1.default.createElement(react_1.default.Fragment, null,
214
214
  react_1.default.createElement("div", { style: { top: 16, left: 16, position: "absolute" } }, "Testing"),
215
- react_1.default.createElement("img", { src: value.webp }))),
215
+ react_1.default.createElement("img", { src: value.webp || value.src }))),
216
216
  containerStyle: { position: 'relative' }
217
217
  },
218
218
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-justified-layout-ts",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "A component based off Flickr's justified layout that is compatible with Typescript",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -108,15 +108,19 @@ function TSJustifiedLayout({
108
108
  </div>
109
109
  }
110
110
 
111
+ // TODO Figure out how to eliminate the tiny gap between div and actual image height
111
112
  return (
112
- <div style={{width: "100%"}}>
113
+ <div style={{
114
+ display: 'flex',
115
+ flexDirection: 'column',
116
+ gap: rowSpacing
117
+ }}>
113
118
  {rows.map((value, index, array) => {
114
119
  let isLastRow = index === array.length - 1 && showWidows;
115
120
  return <div className={'justified-row'} style={{
116
121
  display: "flex",
117
122
  flexDirection: "row",
118
- gap: itemSpacing,
119
- marginBottom: rowSpacing
123
+ gap: itemSpacing
120
124
  }
121
125
  }>
122
126
  {value.items.map((aspectRatio) => renderRow(aspectRatio, isLastRow))}
@@ -16,7 +16,7 @@ export const ConfiguredJustifiedLayout = ({
16
16
  return <TSJustifiedLayout layoutItems={layoutItems}
17
17
  width={width}
18
18
  itemSpacing={itemSpacing}
19
- targetRowHeight={320}
19
+ targetRowHeight={targetRowHeight}
20
20
  targetRowHeightTolerance={targetRowHeightTolerance}
21
21
  rowSpacing={rowSpacing}
22
22
  showWidows={showWidows} {...props}>