mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-25 03:29:51 +01:00
feat: copy to clipbioard screenshot
This commit is contained in:
1 parent
37a50f8bc1
commit
51f28b5936
2 files changed
+51
-14
No files matched your search
@@ -1,5 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
CameraIcon,
|
CameraIcon,
|
||||||
|
CopyIcon,
|
||||||
|
DownloadIcon,
|
||||||
EnterFullScreenIcon,
|
EnterFullScreenIcon,
|
||||||
ExitFullScreenIcon,
|
ExitFullScreenIcon,
|
||||||
EyeOpenIcon,
|
EyeOpenIcon,
|
||||||
@@ -303,21 +305,56 @@ export function Options({ thicknessRange, canvas }: OptionsProps) {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<Box position="absolute" top="3" right="3">
|
<Box position="absolute" top="3" right="3">
|
||||||
<IconButton
|
<Popover.Root>
|
||||||
size={{ initial: '2', sm: '3' }}
|
<Popover.Trigger>
|
||||||
variant="soft"
|
<IconButton size={{ initial: '2', sm: '3' }} variant="soft">
|
||||||
onClick={() => {
|
<CameraIcon />
|
||||||
if (!canvas.current) return;
|
</IconButton>
|
||||||
|
</Popover.Trigger>
|
||||||
|
|
||||||
const anchor = document.createElement('a');
|
<Popover.Content>
|
||||||
|
<Flex direction="column" gap="2">
|
||||||
|
<Popover.Close>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
if (!canvas.current) return;
|
||||||
|
|
||||||
anchor.setAttribute('download', `${protagonist.name}.png`);
|
const anchor = document.createElement('a');
|
||||||
anchor.setAttribute('href', canvas.current.toDataURL('image/png'));
|
|
||||||
anchor.click();
|
anchor.setAttribute('download', `${protagonist.name}.png`);
|
||||||
}}
|
anchor.setAttribute(
|
||||||
>
|
'href',
|
||||||
<CameraIcon />
|
canvas.current.toDataURL('image/png'),
|
||||||
</IconButton>
|
);
|
||||||
|
anchor.click();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<DownloadIcon />
|
||||||
|
Download
|
||||||
|
</Button>
|
||||||
|
</Popover.Close>
|
||||||
|
<Popover.Close>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
onClick={() => {
|
||||||
|
if (!canvas.current) return;
|
||||||
|
|
||||||
|
canvas.current.toBlob((blob) => {
|
||||||
|
if (!blob) return;
|
||||||
|
|
||||||
|
navigator.clipboard.write([
|
||||||
|
new ClipboardItem({ 'image/png': blob }),
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CopyIcon />
|
||||||
|
Copy
|
||||||
|
</Button>
|
||||||
|
</Popover.Close>
|
||||||
|
</Flex>
|
||||||
|
</Popover.Content>
|
||||||
|
</Popover.Root>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Flex
|
<Flex
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export default async function Layout({
|
|||||||
const title = `${tank.name} - Tier ${TIER_ROMAN_NUMERALS[tank.tier]} ${
|
const title = `${tank.name} - Tier ${TIER_ROMAN_NUMERALS[tank.tier]} ${
|
||||||
(strings.common.nations_adjectives as Record<string, string>)[tank.nation]
|
(strings.common.nations_adjectives as Record<string, string>)[tank.nation]
|
||||||
} ${strings.common.tank_class_short[tank.class]}`;
|
} ${strings.common.tank_class_short[tank.class]}`;
|
||||||
const description = `Statistics, armor, and equipment for ${tank.name} in World of Tanks Blitz | WoTB`;
|
const description = `Statistics, armor, and equipment for ${tank.name} in World of Tanks Blitz (WoTB)`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TankopediaEphemeral.Provider data={tankModelDefinition}>
|
<TankopediaEphemeral.Provider data={tankModelDefinition}>
|
||||||
|
|||||||
Reference in new issue
Block a user