working display panel

This commit is contained in:
caranicas 2022-09-14 18:38:31 -04:00
parent 37592a876e
commit 2a5fcc0846
6 changed files with 97 additions and 46 deletions

View File

@ -1,3 +1,6 @@
.create-layout {
padding: 10px;
}
.panel-box-toggle-btn { .panel-box-toggle-btn {
display: block; display: block;
width: 100%; width: 100%;

View File

@ -0,0 +1,21 @@
.display-panel {
padding:10px;
}
#display-container {
display: flex;
flex-direction: row;
height: 100%;
width: 100%;
overflow: hidden;
}
#previous-images {
margin-left: 30px;
display: flex;
flex:auto;
}
.previous-image {
margin: 0 10px;
}

View File

@ -0,0 +1,20 @@
.generated-image {
position: relative;
}
.image-contain {
position: relative;
}
#save-button {
position: absolute;
top: 10px;
left: 10px;
}
#use-button {
position: absolute;
top: 10px;
right: 10px;
}

View File

@ -2,14 +2,18 @@ import React, { useCallback } from "react";
import { ImageRequest, useImageCreate } from "../../../store/imageCreateStore"; import { ImageRequest, useImageCreate } from "../../../store/imageCreateStore";
import './generatedImage.css';
type GeneretaedImageProps = { type GeneretaedImageProps = {
imageData: string; imageData: string;
metadata: ImageRequest; metadata: ImageRequest;
className?: string;
}; };
export default function GeneratedImage({ export default function GeneratedImage({
imageData, imageData,
metadata, metadata,
className,
}: GeneretaedImageProps) { }: GeneretaedImageProps) {
const setRequestOption = useImageCreate((state) => state.setRequestOptions); const setRequestOption = useImageCreate((state) => state.setRequestOptions);
@ -59,32 +63,21 @@ export default function GeneratedImage({
const _handleUseAsInput = () => { const _handleUseAsInput = () => {
debugger;
setRequestOption("init_image", imageData); setRequestOption("init_image", imageData);
// initImageSelector.value = null
// initImagePreview.src = imgBody
// imgUseBtn.addEventListener('click', function() {
// initImageSelector.value = null
// initImagePreview.src = imgBody
// initImagePreviewContainer.style.display = 'block'
// promptStrengthContainer.style.display = 'block'
// // maskSetting.style.display = 'block'
// randomSeedField.checked = false
// seedField.value = seed
// seedField.disabled = false
// })
}; };
// className={[statusClass, className].join(" ")}
return ( return (
<div className="generated-image">
<p>Your image</p> <div className={["generated-image", className].join(" ")}>
<p>{metadata.prompt}</p>
<div className="image-contain">
<img src={imageData} alt="generated" /> <img src={imageData} alt="generated" />
<button onClick={_handleSave}>Save</button> <button id="save-button" onClick={_handleSave}>Save</button>
<button onClick={_handleUseAsInput}>Use as Input</button> <button id="use-button" onClick={_handleUseAsInput}>Use as Input</button>
</div>
</div> </div>
); );
} }

View File

@ -11,6 +11,8 @@ import AudioDing from "./audioDing";
import GeneratedImage from "./generatedImage"; import GeneratedImage from "./generatedImage";
import './displayPanel.css';
type CompletedImagesType = { type CompletedImagesType = {
id: string; id: string;
data: string; data: string;
@ -81,6 +83,7 @@ export default function DisplayPanel() {
.flat() .flat()
.reverse(); .reverse();
setCompletedImages(temp); setCompletedImages(temp);
debugger;
} else { } else {
setCompletedImages([]); setCompletedImages([]);
} }
@ -89,26 +92,42 @@ export default function DisplayPanel() {
return ( return (
<div className="display-panel"> <div className="display-panel">
<h1>Display Panel</h1> <h1>Display Panel</h1>
<div>
<AudioDing ref={dingRef}></AudioDing> <AudioDing ref={dingRef}></AudioDing>
{completedImages.length > 0 && (
<div id="display-container">
<GeneratedImage
key={completedImages[0].id}
imageData={completedImages[0].data}
metadata={completedImages[0].info}
/>
<div id="previous-images">
{completedImages.map((image, index) => { {completedImages.map((image, index) => {
// if(index == 0){
// return null;
// }
if (void 0 !== image) { if (void 0 !== image) {
if(index == 0){
return null;
}
return ( return (
<GeneratedImage <GeneratedImage
className="previous-image"
key={image.id} key={image.id}
imageData={image.data} imageData={image.data}
metadata={image.info} metadata={image.info}
/> />
); );
} else { } else {
console.warn("image is undefined", image, index); console.warn("image is undefined", image, index);
return null; return null;
} }
})} })}
</div> </div>
</div>
)}
</div> </div>
); );
} }

View File

@ -10,9 +10,4 @@ body {
left: 0; left: 0;
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
/* pointer-events: none; */
/* this are used while we still have the original app code in the index.html */
/* display: none; */
z-index: 1;
} }