File size: 2,288 Bytes
4e1096a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
66
67
68
69
70
71
72
73
74
75
76
77
78
import { Insets } from '@/types/misc';

interface DoubleBorderProps {
  borderColor: string;
  horizontalGap: number;
  showHeader: boolean;
  showFooter: boolean;
  insets: Insets;
}

const paddingPx = 10;

const DoubleBorder: React.FC<DoubleBorderProps> = ({
  borderColor,
  showHeader,
  showFooter,
  insets,
}) => {
  return (
    <div>
      {/* outter frame */}
      <div
        className={'borderframe pointer-events-none absolute'}
        style={{
          border: `4px solid ${borderColor}`,
          height: `calc(100% - ${insets.top + insets.bottom}px + ${paddingPx * 2}px)`,
          top: `calc(${insets.top}px - ${paddingPx}px)`,
          left: `calc(${insets.left}px - ${paddingPx}px)`,
          right: `calc(${insets.right}px - ${paddingPx}px)`,
        }}
      ></div>
      {/* inner frame */}
      <div
        className={'borderframe pointer-events-none absolute'}
        style={{
          border: `1px solid ${borderColor}`,
          height: `calc(100% - ${insets.top + insets.bottom}px)`,
          top: `${insets.top}px`,
          left: `calc(${insets.left + (showFooter ? 32 : 0)}px`,
          right: `calc(${insets.right + (showHeader ? 32 : 0)}px`,
        }}
      />
      {/* footer */}
      {showFooter && (
        <div
          className={'borderframe pointer-events-none absolute'}
          style={{
            borderTop: `1px solid ${borderColor}`,
            borderBottom: `1px solid ${borderColor}`,
            borderLeft: `1px solid ${borderColor}`,
            width: '32px',
            height: `calc(100% - ${insets.top + insets.bottom}px)`,
            top: `${insets.top}px`,
            left: `calc(${insets.left}px)`,
          }}
        />
      )}
      {/* header */}
      {showHeader && (
        <div
          className={'borderframe pointer-events-none absolute'}
          style={{
            borderTop: `1px solid ${borderColor}`,
            borderBottom: `1px solid ${borderColor}`,
            borderRight: `1px solid ${borderColor}`,
            width: '32px',
            height: `calc(100% - ${insets.top + insets.bottom}px)`,
            top: `${insets.top}px`,
            left: `calc(100% - ${insets.right}px - 32px)`,
          }}
        />
      )}
    </div>
  );
};

export default DoubleBorder;