formatting and helpers

This commit is contained in:
Kurt Hutten
2021-08-13 06:38:15 +10:00
parent 7bd3cb44f8
commit 50e9ac61f8
5 changed files with 70 additions and 27 deletions

View File

@@ -76,10 +76,12 @@ const EditableProjectTitle = ({
value={newTitle}
onChange={onTitleChange}
ref={inputRef}
onBlur={() => setTimeout(() => {
onBlur={() =>
setTimeout(() => {
setInEditMode(false)
setNewTitle(projectTitle)
}, 300)}
}, 300)
}
/>
</span>
<div className="flex items-center h-full">

View File

@@ -95,6 +95,8 @@ const IdeHeader = ({
{canEdit && !projectTitle && (
<CaptureButton
canEdit={canEdit}
projectTitle={project?.title}
userName={project?.user?.userName}
shouldUpdateImage={!project?.mainImage}
TheButton={({ onClick }) => (
<TopButton

View File

@@ -1,5 +1,5 @@
import { useState } from 'react'
import { makeStyles } from '@material-ui/core/styles';
import { makeStyles } from '@material-ui/core/styles'
import Dialog from '@material-ui/core/Dialog'
import Tab from '@material-ui/core/Tab'
import Tabs from '@material-ui/core/Tabs'

View File

@@ -208,7 +208,9 @@ const ProjectProfile = ({
className="w-full h-32 rounded shadow-inner outline-none resize-none p-3 bg-ch-gray-600 placeholder-ch-gray-500 font-fira-sans"
placeholder="Have a question about this model, or a helpful tip about how to improve it? Remember, be nice!"
value={comment}
onChange={({ target }) => setComment(target.value)}
onChange={({ target }) =>
setComment(target.value)
}
/>
</div>
<Button
@@ -226,7 +228,8 @@ const ProjectProfile = ({
</>
)}
<ul>
{project?.Comment.map(({ text, user, id, createdAt }) => (
{project?.Comment.map(
({ text, user, id, createdAt }) => (
<li key={id} className="mb-5">
<div className="flex justify-between">
<Link
@@ -247,7 +250,8 @@ const ProjectProfile = ({
{text}
</div>
</li>
))}
)
)}
</ul>
</>
)}

View File

@@ -0,0 +1,35 @@
export const canvasToBlob = async (
threeInstance,
{ width, height }: { width: number; height: number }
): Promise<Blob> => {
const updateCanvasSize = ({
width,
height,
}: {
width: number
height: number
}) => {
threeInstance.camera.aspect = width / height
threeInstance.camera.updateProjectionMatrix()
threeInstance.gl.setSize(width, height)
threeInstance.gl.render(
threeInstance.scene,
threeInstance.camera,
null,
false
)
}
const oldSize = threeInstance.size
updateCanvasSize({ width, height })
const imgBlobPromise: Promise<Blob> = new Promise((resolve, reject) => {
threeInstance.gl.domElement.toBlob(
(blob) => {
resolve(blob)
},
'image/jpeg',
1
)
})
updateCanvasSize(oldSize)
return imgBlobPromise
}