@datalayer/core
Version:
[](https://datalayer.io)
28 lines (27 loc) • 1.52 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { Link, Tooltip, Button } from '@primer/react';
import { ScreenFullIcon } from '@primer/octicons-react';
import { lazyWithPreload, WithSuspense } from '../../utils';
import { useToast } from '../../hooks';
import { useLayoutStore } from '../../state';
const ScreenCapture = WithSuspense(lazyWithPreload(() => import('../screenshot/ScreenCapture')));
export const ScreenCaptureButton = (props) => {
const { enqueueToast } = useToast();
const { setScreenCapture, hideScreenshot } = useLayoutStore();
const handleScreenCapture = (screenCapture) => {
setScreenCapture(screenCapture);
hideScreenshot();
enqueueToast('Screen is captured.', { variant: 'success' });
};
return (_jsx(ScreenCapture, { onEndCapture: handleScreenCapture, children: ({ onStartCapture }) => (_jsx(Tooltip, { text: "Take a screen capture", direction: "s", children: _jsx(Button, { variant: "invisible", children: _jsx(Link, { href: "javascript: return false;", sx: {
color: 'fg.muted',
':hover, :focus, &[aria-expanded=true]': {
background: 'none !important',
color: 'accent.fg',
},
}, onClick: e => {
e.preventDefault();
onStartCapture();
}, children: _jsx(ScreenFullIcon, {}) }) }) })) }));
};
export default ScreenCaptureButton;