File size: 1,658 Bytes
f91a684
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { LANGUAGE_OPTIONS } from './useCompiler.js';

interface StatusBarProps {
  language: string;
  cursorLine: number;
  cursorCol: number;
  status: string;
}

function getLanguageLabel(value: string) {
  return LANGUAGE_OPTIONS.find((l: any) => l.value === value)?.label ?? value;
}

function statusLabel(status: string) {
  switch (status) {
    case 'running':       return 'Running…';
    case 'success':       return 'Success';
    case 'error':         return 'Error';
    case 'compile_error': return 'Compile Error';
    default:              return 'Ready';
  }
}

export default function StatusBar({ language, cursorLine, cursorCol, status }: StatusBarProps) {
  return (
    <div className="ryp-statusbar">
      <div style={{ display: 'flex', alignItems: 'center', gap: 2 }}>
        <span className="ryp-statusbar__item">{getLanguageLabel(language)}</span>
        <span className="ryp-statusbar__item" style={{ opacity: 0.7 }}>UTF-8</span>
        <span className="ryp-statusbar__item">Ln {cursorLine}, Col {cursorCol}</span>
        <span className="ryp-statusbar__item">
          <span
            className={`ryp-statusbar__dot${
              status === 'error' || status === 'compile_error'
                ? ' ryp-statusbar__dot--error'
                : status === 'running'
                  ? ' ryp-statusbar__dot--running'
                  : ''
            }`}
          />
          {statusLabel(status)}
        </span>
      </div>
      <div style={{ display: 'flex', alignItems: 'center', gap: 2 }}>
        <span className="ryp-statusbar__item" style={{ opacity: 0.7 }}>RYP Engine</span>
      </div>
    </div>
  );
}