diff --git a/checkmark.svg b/checkmark.svg new file mode 100644 index 0000000..5d4c32b --- /dev/null +++ b/checkmark.svg @@ -0,0 +1,3 @@ + + + diff --git a/web/src/components/IdeCascadeStudio/IdeCascadeStudio.js b/web/src/components/IdeCascadeStudio/IdeCascadeStudio.js index f911887..a85bc22 100644 --- a/web/src/components/IdeCascadeStudio/IdeCascadeStudio.js +++ b/web/src/components/IdeCascadeStudio/IdeCascadeStudio.js @@ -75,14 +75,29 @@ const IdeCascadeStudio = ({ part, saveCode, loading }) => { onCapture={ async () => { // Get the canvas image as a Data URL const imgBlob = await CascadeController.capture(threejsViewport.environment) - const imgURL = window.URL.createObjectURL(imgBlob) - // TODO: Upload the image to Cloudinary - // uploadToCloudinary(imgBlob) + // // Upload the image to Cloudinary + // const cloudinaryImg = await uploadToCloudinary(imgBlob) - // TODO: Save the screenshot as the mainImage if none has been set - // If it has been set, pass along the Blob without uploading - // onSave(part?.id, { ...input, mainImage: cloudinaryPublicId }) + // // TODO: Save the screenshot as the mainImage if none has been set + // // If it has been set, pass along the Blob without uploading + // if (!part.mainImage) { + // saveCode({ + // input: { + // code, + // title: part?.title, + // userId: currentUser?.sub, + // description: part?.description, + // mainImage: cloudinaryImg.public_id, + // }, + // id: part.id, + // isFork: !canEdit, + // }) + // } else { + // console.log('not saving, passing back into IDE', cloudinaryImg) + // } + + return imgBlob }} /> diff --git a/web/src/components/IdeToolbar/IdeToolbar.js b/web/src/components/IdeToolbar/IdeToolbar.js index 73f70c1..4f8ab54 100644 --- a/web/src/components/IdeToolbar/IdeToolbar.js +++ b/web/src/components/IdeToolbar/IdeToolbar.js @@ -31,6 +31,7 @@ const IdeToolbar = ({ const { isAuthenticated, currentUser } = useAuth() const showForkButton = !(canEdit || isDraft) const [title, setTitle] = useState('untitled-part') + const [captureState, setCaptureState] = useState(false) const { user } = useUser() useKeyPress((e) => { const rx = /INPUT|SELECT|TEXTAREA/i @@ -106,7 +107,18 @@ const IdeToolbar = ({ } const captureScreenshot = async () => { - console.log({ forkPart, onCapture: onCapture() }) + setCaptureState(await onCapture()) + // console.log({ onCapture: onCapture() }) + } + + const handleDownload = (imgBlob) => { + const aTag = document.createElement('a') + document.body.appendChild(aTag) + const url = URL.createObjectURL(imgBlob) + aTag.href= url + aTag.style.display = 'none' + aTag.download = `CodeCad_${ Date.now() }.jpg` + aTag.click() } const anchorOrigin = { @@ -227,9 +239,9 @@ const IdeToolbar = ({ {/* Capture Screenshot link. Should only appear if part has been saved and is editable. */} { !isDraft && canEdit &&
+
+ + } } diff --git a/web/src/components/Svg/Svg.js b/web/src/components/Svg/Svg.js index 0636b53..4456a9b 100644 --- a/web/src/components/Svg/Svg.js +++ b/web/src/components/Svg/Svg.js @@ -53,6 +53,17 @@ const Svg = ({ name, className: className2, strokeWidth = 2 }) => { stroke-linecap="round"/> ), + 'checkmark': ( + + + ), 'chevron-down': (