File size: 1,562 Bytes
67b042f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import React from 'react';
import { Button, CircularProgress, Tooltip } from '@mui/material';
import GifIcon from '@mui/icons-material/Gif';

interface DownloadGifButtonProps {
  isGenerating: boolean;
  onClick: () => void;
  disabled?: boolean;
}

/**
 * Button to download a GIF replay of the trace
 */
export const DownloadGifButton: React.FC<DownloadGifButtonProps> = ({
  isGenerating,
  onClick,
  disabled = false,
}) => {
  return (
    <Tooltip
      title={
        disabled
          ? "No steps available"
          : "Download GIF replay"
      }
    >
      <span>
        <Button
          variant="outlined"
          size="small"
          onClick={onClick}
          disabled={disabled || isGenerating}
          startIcon={
            isGenerating ? (
              <CircularProgress size={16} />
            ) : (
              <GifIcon sx={{ fontSize: '1.2rem' }} />
            )
          }
          sx={{
            textTransform: 'none',
            fontSize: '0.75rem',
            fontWeight: 600,
            borderRadius: 1,
            px: 1.5,
            py: 0.5,
            borderColor: 'divider',
            color: 'text.primary',
            '&:hover': {
              borderColor: 'primary.main',
              backgroundColor: 'action.hover',
            },
            '&.Mui-disabled': {
              borderColor: 'divider',
              color: 'text.disabled',
            },
          }}
        >
          {isGenerating ? 'Generating...' : 'Download GIF'}
        </Button>
      </span>
    </Tooltip>
  );
};