File size: 1,227 Bytes
3c3f089
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import React from "react";
import dynamic from "next/dynamic";
import { useAppDispatch, useAppSelector } from "../../store/hook";
import { clear_logs } from "../../store/features/editorSlice";

import { theme_state } from "../../store/features/themeSlice";

const Console = dynamic(import("console-feed/lib/Component"), { ssr: false });

interface LogsProps {
  logs: any;
}

const Logs = ({ logs }: LogsProps) => {
  const { theme } = useAppSelector(theme_state);
  const dispatch = useAppDispatch();

  return (
    <div className="text-gray-300 relative h-full">
      <div className="flex items-center justify-between px-3 h-9">
        <button
          onClick={() => dispatch(clear_logs())}
          className="editor-button h-5 mr-3"
        >
          Clear
        </button>
      </div>

      <div className="h-80 overflow-auto">
        <Console
          styles={{
            BASE_FONT_FAMILY: '"Rubik", sans-serif;',
            BASE_FONT_SIZE: 14,
            BASE_BACKGROUND_COLOR: theme.background,
            LOG_BORDER: theme.border,
          }}
          logs={logs}
          variant="dark"
        />
      </div>
    </div>
  );
};

const ConsoleLog = React.memo(Logs);

export default ConsoleLog;