mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-20 22:50:11 -04:00
* start * not for this branch lol * fix dates * fix spacing * revert mistake * progress * blog * improve wording * more blog * more blog moment * moreee blog * cant spell can i * bloggggg * change name * some rambling * sentence meowment * merge * prep * perfect app ui template for landing * updated landing image * fix border * section * fix query param handling * remove apps/snapshot * remove `WindowControls` * Playwright in setup script * `showControls` in a store * better screenshot + fixed stars with fadeout * fix show controls store mistake * begin bento boxes * bento box stuff * taggrid * release blog post: clarifying punctuation & rearrange some sentences (#1097) * landing page wip * Update index.tsx * tweak * Update pnpm-lock.yaml * Update app.webp * better app image + line animation wip * wip * tweak + image * tweaks + 60 fps ball * 60 fps platforms anim * landing updates * static globe * tweaks * device detect and dynamic imports * Accessibility and minor performance improvements from Lh report. * Update globe.webp * Improve randomness of line animation, better cloud image * isMobile vid support * Update index.tsx * new art * docs * docs * Improvements and feedback * Update index.tsx * improvements * quick art tweak * updated art * increase size * SVG animation * animations * convert platforms to arr and framer motion * new section - wip preview * remove border app animation - more animation work * mobile tweaks * tweak * duration adjustment * animation improvements * different floating times for other circles * Pricing page * tweak * optimize images, accessibility values, svg attribute cleanup * launch prep * fix blog link * adding location docs * hover effect * fixes to layout * Update index.tsx * another show controls method * use PageLayoutContext in other file * merge * desktop release download api * update publishing api * hook up desktop releases api to landing page * screenshot stuff * Delete .github/scripts/setup-system.sh * Update october-alpha-release.mdx * rotating screenshots, fixed blog and apple download chooser --------- Co-authored-by: Utku Bakir <74243531+utkubakir@users.noreply.github.com> Co-authored-by: Oscar Beaumont <oscar@otbeaumont.me> Co-authored-by: pr <pineapplerind.info@gmail.com> Co-authored-by: ameer2468 <33054370+ameer2468@users.noreply.github.com> Co-authored-by: Brendan Allan <brendonovich@outlook.com>
71 lines
1.5 KiB
TypeScript
71 lines
1.5 KiB
TypeScript
import * as htmlToImage from 'html-to-image';
|
|
import React, { useEffect, useRef } from 'react';
|
|
|
|
const ScreenshotWrapper = ({
|
|
showControls,
|
|
children
|
|
}: {
|
|
showControls: boolean;
|
|
children: React.ReactNode;
|
|
}) => {
|
|
const domEl = useRef(null);
|
|
|
|
const downloadImage = async () => {
|
|
const style = document.createElement('style');
|
|
style.innerHTML = `
|
|
::-webkit-scrollbar {
|
|
display: none;
|
|
}
|
|
body, .no-scrollbar, .custom-scroll {
|
|
overflow: hidden !important;
|
|
-ms-overflow-style: none;
|
|
scrollbar-width: none;
|
|
}
|
|
`;
|
|
document.head.appendChild(style);
|
|
|
|
if (!domEl.current) return;
|
|
const dataUrl = await htmlToImage.toPng(domEl.current);
|
|
|
|
document.head.removeChild(style);
|
|
|
|
const link = document.createElement('a');
|
|
link.download = 'test.png';
|
|
link.href = dataUrl;
|
|
link.click();
|
|
};
|
|
|
|
useEffect(() => {
|
|
if (showControls) {
|
|
window.document.body.style.backgroundColor = 'black';
|
|
window.addEventListener('keyup', (e) => {
|
|
if (e.key === 'k') {
|
|
downloadImage();
|
|
}
|
|
});
|
|
return () => window.removeEventListener('keyup', downloadImage);
|
|
}
|
|
}, [showControls]);
|
|
|
|
return (
|
|
<div
|
|
ref={showControls ? domEl : null}
|
|
style={
|
|
showControls
|
|
? {
|
|
width: '1278px',
|
|
height: '626px',
|
|
margin: '0 auto',
|
|
position: 'relative',
|
|
overflow: 'hidden'
|
|
}
|
|
: {}
|
|
}
|
|
>
|
|
{children}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default ScreenshotWrapper;
|