Skip to content

Commit def6771

Browse files
committed
Use flexbox for better centering; Fix document modal wrap in FF
1 parent 80ecc37 commit def6771

File tree

2 files changed

+42
-22
lines changed

2 files changed

+42
-22
lines changed

app/src/App.css

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@
115115
display: none;
116116
}
117117

118+
#imgGrid {
119+
display: flex;
120+
flex-direction: row;
121+
flex-wrap: wrap;
122+
align-content: center;
123+
justify-content: center;
124+
align-items: center;
125+
}
126+
118127
.modalContent {
119128
outline: none;
120129
}
@@ -125,8 +134,17 @@
125134
max-width: 95%;
126135
}
127136

137+
#imgGrid, #modalImgGrid {
138+
display: flex;
139+
flex-direction: row;
140+
flex-wrap: wrap;
141+
align-content: center;
142+
justify-content: center;
143+
align-items: center;
144+
}
145+
128146
.moreDocument pre {
129-
text-wrap: wrap;
147+
white-space: pre-wrap;
130148
word-break: break-word;
131149
}
132150

app/src/GetImages.jsx

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ export default function GetImages() {
233233
<span title="Random" className={`sortOption ${sort == "random" ? "highlight" : ""}`} onClick={() => handleSortChange("random")}>R</span>
234234
</div>
235235
</div>
236-
<div>
236+
<div id="imgGrid">
237237
{loading && <div className="lds-ellipsis"><div></div><div></div><div></div><div></div></div>}
238238
{error && <h2>There was an error loading the images.</h2>}
239239
{!loading && !error && images.map((image, index) => (
@@ -256,26 +256,28 @@ export default function GetImages() {
256256
{moreLoading && <div className="lds-ellipsis"><div></div><div></div><div></div><div></div></div>}
257257
{moreError && <h2>There was an error during loading.</h2>}
258258
{!moreLoading && !moreError && images[moreIndex] && moreImages[0] && !moreDocument && <div className="modalHeader" style={{width: `calc(224px * ${moreImages.length})`} /*adjust header size for # of images until max width*/}>{images[moreIndex].path + images[moreIndex].filename}</div>}
259-
{!moreLoading && !moreError && images[moreIndex] && moreImages[0] && !moreDocument && moreImages.map((image, index) => (
260-
<div key={index+1000000} className="imgCard" onClick={() => {navigator.clipboard.writeText(images[moreIndex].prompt)}}>
261-
<img width="224" height="336"
262-
src={"http://localhost:3000/" + image.path + encodeURIComponent(image.filename)}
263-
loading={index <= 60 ? "eager" : "lazy"}
264-
title={image.filename}
265-
/>
266-
</div>
267-
))}
268-
{!moreLoading && !moreError && moreDocument && images[moreIndex] &&
269-
<div className="moreDocument">
270-
<pre>
271-
File: {images[moreIndex].filename}{<br />}
272-
{type != "styles" && `Keywords: ${images[moreIndex].keywords}\n`}
273-
{type != "styles" && `Weight: ${images[moreIndex].weight}`}
274-
{type == "styles" && `Prompt: ${images[moreIndex].prompt}`}
275-
</pre>
276-
<pre>{moreDocument}</pre>
277-
</div>
278-
}
259+
<div id="modalImgGrid">
260+
{!moreLoading && !moreError && images[moreIndex] && moreImages[0] && !moreDocument && moreImages.map((image, index) => (
261+
<div key={index+1000000} className="imgCard" onClick={() => {navigator.clipboard.writeText(images[moreIndex].prompt)}}>
262+
<img width="224" height="336"
263+
src={"http://localhost:3000/" + image.path + encodeURIComponent(image.filename)}
264+
loading={index <= 60 ? "eager" : "lazy"}
265+
title={image.filename}
266+
/>
267+
</div>
268+
))}
269+
{!moreLoading && !moreError && moreDocument && images[moreIndex] &&
270+
<div className="moreDocument">
271+
<pre>
272+
File: {images[moreIndex].filename}{<br />}
273+
{type != "styles" && `Keywords: ${images[moreIndex].keywords}\n`}
274+
{type != "styles" && `Weight: ${images[moreIndex].weight}`}
275+
{type == "styles" && `Prompt: ${images[moreIndex].prompt}`}
276+
</pre>
277+
<pre>{moreDocument}</pre>
278+
</div>
279+
}
280+
</div>
279281
</div>
280282
</ReactModal>
281283
</div>

0 commit comments

Comments
 (0)