Passed
Push — dev ( 22baca...1bf816 )
by
unknown
04:47 queued 10s
created

resources/assets/js/components/ContextBlock/ContextBlockItem.tsx   A

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 61
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 39
mnd 1
bc 1
fnc 0
dl 0
loc 61
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
import * as React from "react";
2
3
export interface ContextBlockItemProps {
4
  title?: string;
5
  subtext?: string | React.ReactNode;
6
  active?: boolean;
7
  className?: string;
8
  contextId?: string;
9
  backgroundColor?: string;
10
  backgroundOpacity?: string;
11
  padding?: string;
12
  radius?: string;
13
  fontSize?: string;
14
  fontWeight?: string;
15
  wrapperMargin?: string;
16
  titleMargin?: string;
17
}
18
19
const ContextBlockItem: React.FunctionComponent<ContextBlockItemProps> = ({
20
  subtext,
21
  title,
22
  className,
23
  contextId,
24
  backgroundColor,
25
  backgroundOpacity,
26
  padding,
27
  radius,
28
  fontSize,
29
  fontWeight,
30
  wrapperMargin,
31
  titleMargin,
32
  active,
33
}): React.ReactElement => {
34
  return (
35
    <div
36
      className={`${className || ""}${active ? " active" : ""}`}
37
      data-tc-wenv-id={contextId}
38
      data-c-background={
39
        (backgroundColor && `${backgroundColor}(${backgroundOpacity})`) ||
40
        "grey(20)"
41
      }
42
      data-c-padding={padding || "all(normal)"}
43
      data-c-radius={radius || "rounded"}
44
      data-c-margin={wrapperMargin || ""}
45
    >
46
      {title && (
47
        <p
48
          data-c-font-size={fontSize || "small"}
49
          data-c-margin={titleMargin || "bottom(half)"}
50
          data-c-font-weight={fontWeight || "bold"}
51
        >
52
          {title}
53
        </p>
54
      )}
55
      {subtext && <p data-c-font-size={fontSize || "small"}>{subtext}</p>}
56
    </div>
57
  );
58
};
59
60
export default ContextBlockItem;
61